I am confused of the add instruction in x86
.
this is the original c
code:
int a = 1;
int b = 2;
int c = 0;
void add() {
c = a + b;
}
I translated it to assembly language and got this:
add:
pushl %ebp
movl %esp, %ebp
movl a, %edx
movl b, %eax
addl %edx, %eax // add instruction
movl %eax, c // why is it stored in eax?
popl %ebp
ret
Isn't the result of edx+eax
supposed to be stored in edx
?
Why is it stored in eax
?
Or could it be that my compiler handles things differently?