2

dump of assembler code for function main:

0x0000000100000de6 <main+0>:    push   %rbp
0x0000000100000de7 <main+1>:    mov    %rsp,%rbp
0x0000000100000dea <main+4>:    sub    $0x30,%rsp
0x0000000100000dee <main+8>:    mov    %edi,-0x14(%rbp)

I learned mov %rsp,%rbp means move the value of rsp to rbp
But I knew in Intel architecture, that would mean move the value of rbp to rsp According to Intel manual(Intel Architecture Software Developer's Manual. Volume 2. 3-104 MOV instruction), mov a, b should mean move b to a

Next sub instuction is the same. I knew sub a,b means a = a-b. But here sub $0x30, %rsp means rsp = rsp - 0x30

What's wrong with me?

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
plhn
  • 5,017
  • 4
  • 47
  • 47
  • 2
    `%` everywhere, nonsensical memory syntax, and an instruction that should be impossible. All points to AT&T syntax. – harold Sep 23 '12 at 13:35

1 Answers1

3

Nothing's wrong with you. What you have presented here is assembly code in AT&T syntax (google it up), in which the operand order is the opposite to what you see in the Intel manuals.

Alexey Frunze
  • 61,140
  • 12
  • 83
  • 180
  • Thank you very much Alexey! From your help, I googled this document. http://stackoverflow.com/questions/972602/att-vs-intel-syntax-and-limitations Thank you again! – plhn Sep 23 '12 at 13:04