2013-11-26 88 views
-1

我的問題是一個學術任務我已經asigned: 會有什麼的edx程序的這個片段後的內容:彙編代碼建設

linie dd 421, 422, 443 
     dd 442, 444, 427, 432 

---------------- 
     mov esi, (OFFSET linie)+4 
     mov ebx, 4 
     mov edx, [ebx][esi] 

我有兩個問題:

  1. mov edx, [ebx][esi]是什麼意思?
  2. 調試程序後,爲什麼我的edx中有000001bb?
+0

這是家庭作業。你應該做更多的研究。 –

+1

看起來,這個特殊的同類作品是在去年發佈的,可能是由其他學生完成了最後一次課程分配的任務:/ http://stackoverflow.com/q/9855299/3011009 –

回答

1

首先,mov edx, [ebx] [esi]裝置一樣mov edx, [ebx + esi] - 它是指ADRESS的存儲單元,其是總和ebxesi寄存器 。

完成程序後,您的edx註冊將會有443(1bb,十六進制)。首先,讓我們注意到,在linie中,您定義了dwords 這是32位字。

mov esi, (OFFSET linie)+4 ;sends the adress of the begining of the linie 
          ;area plus 4 bytes(32 bits) 
          ; the esi will point to 422 in the linie array 
mov ebx, 4    ;simple asigning 4 to ebx 
mov edx, [ebx][esi]  ;move the content of a memory cell of 
          ;adress 4+ the adress of 422 
          ; in other words - move the third element of the 
          ;linie array to edx. 
+0

好的,我們怎麼知道+4是指字節而不是雙字? – Simon

+0

就是這樣構建的 - 存儲器單元是字節 – Simon

+0

因爲地址和偏移量始終以1字節的粒度指定。 –

0
mov esi, (OFFSET linie)+4 
    mov ebx, 4 
    mov edx, [ebx][esi] 

這將從[ebx + esi]讀出的值,即[linie+4+4]。這對應於linie的第三個元素(因爲每個元素是DWORD,在x86上是4個字節),並且該元素是443十進制== 0x1bb十六進制。