1

I am trying to make a small ping pong game in nasm assembly(thats the way i learn languages :) ) but i am having a problem ,i cant access any item of a list

my code:

mov eax,counter                  ;counter=2 double checked 
mov esi,bitmap_data+eax*4        ;copy the 2nd item of the array in to esi

bitmap data is in.bss section

bitmap_data:    resd 100 

tried:

mov eax,2                         
mov esi,[bitmap_data+eax*4]       ;copy the 2nd item of the array in to esi

this is not saving in the esi the correct (2th) element of the list while the following is doing it right

mov esi,[bitmap_data+2*4]      

but i need to be able to change the item that i am getting by using a variable

4

2 回答 2

0

将内存访问括在方括号中,如下所示:

mov esi,[bitmap_data+eax*4]

这应该让汇编程序高兴。

根据您的更新进行更新: 尝试稍微分解一下您的说明。尝试:

mov eax, counter
shl eax, 2
add eax, bitmap_data
mov esi, [eax]

任何改变?

于 2013-03-05T17:23:31.860 回答
0

是什么counter?你很可能想要:

mov eax, [counter]
mov esi, [bitmap_data + eax * 4]

eax当= 0 时,数组中的“第一个”(第零个)项将显示。当eax= 2 时,您将获得数组中的“第三个”项。你在找哪一个?

于 2013-03-05T21:50:29.273 回答