當我讀了一些反彙編代碼,因爲我不起來AT & T語法,我不知道什麼樣的一些代碼(%ESP,1)表示。有關AT&T彙編語法(%ESP,1)
11 printf("%x", a);
0x401386 <main+182>: movl $0x1,0x4(%esp,1)
0x40138e <main+190>: movl $0x40300d,(%esp,1)
0x401395 <main+197>: call 0x401810 <printf>
有人能說出它的含義嗎?謝謝!
當我讀了一些反彙編代碼,因爲我不起來AT & T語法,我不知道什麼樣的一些代碼(%ESP,1)表示。有關AT&T彙編語法(%ESP,1)
11 printf("%x", a);
0x401386 <main+182>: movl $0x1,0x4(%esp,1)
0x40138e <main+190>: movl $0x40300d,(%esp,1)
0x401395 <main+197>: call 0x401810 <printf>
有人能說出它的含義嗎?謝謝!
這維基似乎有關於GNU彙編器和AT & T語法的一些信息:
http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax
我還發現燃氣文檔的這兩個來源,但他們似乎並不很清晰或有用:
; Decompiled, sort of, back to C
; ==============================
movl $0x1,0x4(%esp,1) ; %esp[1] = 1 (the "1" really means, "add 4")
movl $0x40300d,(%esp,1) ; %esp[0] = "%x"
call 0x401810 <printf> ; push return address and branch to printf
看來,編譯器知道一個等於,而且它已經調整了堆棧指針向下騰出空間的參數。也許它結合了功能序言將空間推到堆棧上。
一般來說,尋址模式看起來像......
r ; register
(r) ; memory, register contains the address
8(r) ; memory, displacement of 8 off the register
謝謝!但是......「,1」沒用? – runningair
x86具有索引尋址模式,「1」不是必需的,但可能是2或4使用了索引功能。這只是反彙編沒有靈感。 – DigitalRoss
因此,0x4(%esp,2)表示*(%esp + 2 * 0x4),0x4(%esp,4)表示*(%esp + 4 * 0x4),0x4(%esp,3)被禁止? – runningair
'爲0x4(%ESP,1)'是相同'[ESP * 1個+爲0x4]'在Intel語法。 –
但是......似乎[esp + 0x4 * 1]更常見? - 爲我可憐的英語打扮。 0x4(%esp,2)似乎沒有實際意義? – runningair
常見的類似'[esp + eax * 4 + 16]'(其中'eax'是位於'esp + 16'的32位整數數組的索引]。這就是尋址模式中存在「縮放」的原因。 –