c code: return a + b + BASE;
000012a0 <add>:
12a0: f3 0f 1e fb endbr32
12a4: 8b 44 24 08 mov 0x8(%esp),%eax
12a8: 03 44 24 04 add 0x4(%esp),%eax
12ac: 83 c0 32 add $0x32,%eax
12af: c3 ret
0000000000001210 <add>:
1210: f3 0f 1e fa endbr64
1214: 8d 44 37 32 lea 0x32(%rdi,%rsi,1),%eax
1218: c3 retq
1219: 0f 1f 80 00 00 00 00 nopl 0x0(%rax)
In the 32 bit compilation,
- we move the 1st operand from stack to eax
- add 2nd operand from stack to the eax
- add the BASE value to it
In the 64 bit compilation in a single instruction we are able to do 0x32+rdi+rsi*1 and save in eax
question is whether this single instruction execution is achieved because we use lea or whats the significance of 64bit compilation here.