According to the description of https://c9x.me/x86/html/file_module_x86_id_5.html:
Adds the first operand (destination operand) and the second operand (source operand) and stores the result in the destination operand.
However in my test, it seems different.
test environment is: Ubuntu 18.04.3 LTS, 4.9.184-linuxkit x86_64 gcc 7.5.0
source code:
int base = 12;
int add(int a, int b){
int c = a+b;
return c-33;
}
the result of gcc -S
is:
...
add:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl %edi, -20(%rbp)
movl %esi, -24(%rbp)
movl -20(%rbp), %edx
movl -24(%rbp), %eax
addl %edx, %eax
movl %eax, -4(%rbp)
movl -4(%rbp), %eax
subl $33, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
Isn't this shows that the addl
stores the result in the latter operand:%eax?And so does the "subl" instruction?