montaj

2014-06-18 35 views
6

içinde işlem kodu ikili Aşağıdaki kod var (intel 80x86 için yazılmış listeleme dosyası, üreten sonra):montaj

1         global _start 
2         
3         section .data 
4 00000000 03000000    x: dd 3 
5         
6         ;section .text 
7         
8         _start: 
9 00000004 8B0D[00000000]    mov ecx, [x] 
10 0000000A 000D[16000000]   r: add byte [l+6], cl 
11 00000010 C605[00000000]30  l: mov byte [x], 48 
12 00000017 51       push ecx 
13 00000018 B804000000     mov eax, 4  ; For "Write" system call 
14 0000001D BB01000000     mov ebx, 1  ; to standard output 
15 00000022 B9[00000000]    mov ecx, x  ; "buffer" 
16 00000027 BA01000000     mov edx, 1  ; byte counter 
17 0000002C CD80      int 0x80 
18 0000002E 59       pop ecx 
19 0000002F E2D9      loop r, ecx 
20          
21 00000031 BB00000000     mov ebx, 0 
22 00000036 B801000000     mov eax, 1  ; For "exit" system call 
23 0000003B CD80      int 0x80 

Ben satırda 19 şimdi konsantre oldum ve tamamen anlamıyorum o. Opcode 'loop' ikiliinin E2 olduğunu anlıyorum.

Ancak D9 baytından nereden geliyorsunuz? nasıl hesaplandı?

+0

o kayıt belirtmek olmaz Ayrıca bkz? Neden değeri değiştirmiyorsunuz ve sökmenin nasıl değiştiğini görüyoruz? – sashoalm

+0

D9'u ikişer tamamlayıcı gösterim olarak davranın ... –

cevap

9

19 0000002F E2D9 loop r, ecx

ikinci işlemkodu (D9) nereden geliyor?

(bu durumda 0xD9) ikinci işlemkodu iki bilgisayarın tamamlayıcı yılında göreceli hedef adresi - eğer geriye atlama olduğundan, bu durumda negatif:

0x00000031 (The address following the loop instruction) 
+ 0xFFFFFFD9 (Signed-extended representation of 0xD9 - actually a negative number, -39 decimal) 
============ 
    0x0000000A (The address of the r label) 

Not hedef olduğunu adres, döngü komutundan sonra adresine göre hesaplanır.

http://www.mathemainzel.info/files/x86asmref.html#loop

+2

Oturum açma uzantısı ile 0xFFFFFFD9. – diapir

+0

Teşekkürler! şimdi çok açık. – Mickey