sum: sum:
pushl %ebp
movl %esp, %ebp
subl $16, %esp
reg1 = b movl 12(%ebp), %eax
add a, reg1 addl 8(%ebp), %eax
mov reg1, ans movl %eax, -4(%ebp)
mov ans, reg1 movl -4(%ebp), %eax
return leave
ret
-
One of the operands of mov must be a register or an immediate value, not a memory location.
-
Moving the value in %eax to memory location for ans and then moving it back to a register (actually the same register), would be avoided with optimization level 2.