and sorry for the title, i couldn't imagine a way to express this in english. So i'm writing a little game in assembly for a course, and, inside of two for loops, i copy the pixel data from the "bomb" vector of pixels, to the "area" vector of pixels, which will later be drawn to the screen. In C, it should look like this:
int x, y;
for(int i=0;i<32;i++)
for(int j=0;j<32;j++)
area[x+i][y+j]=bomb[i][j];
Using masm assembler and notepad++ to write the code, i got
mov ecx, 0 ; my i
outerloop:
cmp ecx, 32
je done
mov esi, 0 ; my j
innerloop:
mov ebx, sprite_width ; sprite_width=32
mov eax, ecx
mul ebx
add eax, esi
shl eax, 2
mov edi, bomb
add edi, eax
mov pixel, edi ; pixel = bomb[i][j]
mov ebx, area_width
mov eax, y
add eax, ecx
mul ebx
add eax, x
add eax, esi
shl eax, 2
mov edi, area
add edi, eax
mov eax, [pixel]
mov dword ptr [edi], eax ; should be area[x+i][y+j] = pixel
cmp esi, 32
je innerloopdone
inc esi
jmp innerloop
innerloopdone:
inc ecx
jmp outerloop
done:
After this, the 32x32 area in the screen should look like a bomb, because of how the bomb vector is written, however i only see some green and some blue. Blue is not even in the bomb vector at all. Is there any mistake in the loop/logic?