instruction's argument order
Question
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?
Solution
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.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow