简体   繁体   English

关于AT&T汇编语法(%esp,1)

[英]about AT&T assembly syntax (%esp,1)

When I read some disassembly code, for I am not up on AT&T syntax, I do not know what some code like (%esp,1) means. 当我阅读一些反汇编代码时,因为我不熟悉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>

Could someone tell what it does mean? 有人可以告诉我这是什么意思吗? Thank you! 谢谢!

                              ; 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

It seems that the compiler knows that a is equal to 1 , and that it already has adjusted the stack pointer downward to make room for the arguments. 似乎编译器知道a等于1 ,并且它已经向下调整了堆栈指针以为参数留出空间。 Perhaps it combined pushing space onto the stack with the function prologue. 也许它结合了函数序言将空间压入堆栈。

In general, the addressing modes look like... 通常,寻址模式如下所示:

r    ; register
(r)  ; memory, register contains the address
8(r) ; memory, displacement of 8 off the register

This wikibook seems to have some information about the GNU assembler and its AT&T syntax: 该Wikibook似乎具有有关GNU汇编程序及其AT&T语法的一些信息:

http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax http://en.wikibooks.org/wiki/X86_Assembly/GAS_Syntax

I also found these two sources of documentation on Gas, but they don't seem to be very clear or useful: 我还找到了有关Gas的以下两个文档来源,但它们似乎不太清楚或没有用:

  1. http://webster.cs.ucr.edu/AsmTools/Gas/GasDoc/as_toc.html http://webster.cs.ucr.edu/AsmTools/Gas/GasDoc/as_toc.html
  2. http://sourceware.org/binutils/docs-2.17/as/index.html http://sourceware.org/binutils/docs-2.17/as/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM