when I disassembled following simple program in C:
int main ()
{
int a = 'a';
return 0;
}
I got this:
Dump of assembler code for function main:
0x0000000100000f20 <main+0>: push rbp
0x0000000100000f21 <main+1>: mov rbp,rsp
0x0000000100000f24 <main+4>: mov BYTE PTR [rbp-0x9],0x61
0x0000000100000f28 <main+8>: mov DWORD PTR [rbp-0x8],0x0
0x0000000100000f2f <main+15>: mov eax,DWORD PTR [rbp-0x8]
0x0000000100000f32 <main+18>: mov DWORD PTR [rbp-0x4],eax
0x0000000100000f35 <main+21>: mov eax,DWORD PTR [rbp-0x4]
0x0000000100000f38 <main+24>: pop rbp
0x0000000100000f39 <main+25>: ret
End of assembler dump.
- why rsp is not setted (sub rep 0xa)
- why there is assignment 0 -> [rbp-0x8] -> eax -> [rbp-0x4] -> eax