我不记得 masm32 使用的确切指令,但基本结构应该是这样的:
mov edi, addr tiles ; might be called offset, some assemblers (notably gas) would use something like lea edi, [tiles] instead
mov ecx, 12 ; the count, this could be gotten from an equ, read from a variable etc.
for_loop:
add byte ptr [edi], 2 ; tiles[i] += 2
inc edi ; move to next tile
dec ecx ; count--
jnz for_loop ; if (count != 0) goto for_loop
或者,如果您希望它的结构更像 c# 代码:
mov edi, addr tiles
sub ecx, ecx ; ecx = 0
for_loop:
cmp ecx, 12 ; ecx < tiles.Length ?
jnl done ; jump not less
add byte ptr [edi+ecx], 2 ; tiles[i] += 2
inc ecx ; i++
jmp for_loop
done:
请注意,如果您更改tiles
某些代码的类型,则必须更改(edi
特别是涉及的代码)。