I have very serious doubts. I have two very simple C codes and their assembler codes:
program 1:
main() { int temp1, temp2, temp3; char temp5, temp6, temp7, temp8, temp9; temp1 = 5; temp1 = 9 - temp1; }
Assembly:
0x080483b4 <+0>: push ebp 0x080483b5 <+1>: mov ebp,esp 0x080483b7 <+3>: sub esp,0x20 0x080483ba <+6>: mov DWORD PTR [ebp-0xc],0x5 0x080483c1 <+13>: mov eax,0x9 0x080483c6 <+18>: sub eax,DWORD PTR [ebp-0xc] 0x080483c9 <+21>: mov DWORD PTR [ebp-0xc],eax 0x080483cc <+24>: leave 0x080483cd <+25>: ret
Program 2:
main() { int temp1, temp2, temp3; char temp5, temp6, temp7, temp8, temp9; temp1 = 5; temp1 = 9 + temp1; }
Assembly:
0x080483b4 <+0>: push ebp 0x080483b5 <+1>: mov ebp,esp 0x080483b7 <+3>: sub esp,0x20 0x080483ba <+6>: mov DWORD PTR [ebp-0xc],0x5 0x080483c1 <+13>: add DWORD PTR [ebp-0xc],0x9 0x080483c5 <+17>: leave 0x080483c6 <+18>: ret
Why, in the case of subtraction, it is necessary to use the eax register, and not in the case of addition. Can not be:
0x080483c1 <+13>: sub DWORD PTR [ebp-0xc],0x9
instead
0x080483c1 <+13>: mov eax,0x9 0x080483c6 <+18>: sub eax,DWORD PTR [ebp-0xc]