I have created a sample code because I am trying to get myself into assembly. I declare and initalize an integer on the stack, and also do the same for one that is on the heap. When looking at the assembly code both of them produce pretty lookalike code:
mov dword ptr [ebp-8],0 ; this is on the stack
mov dword ptr [ebp-14h],0 ; this is on the stack
mov eax,dword ptr [ebp-20h] ; this is on the heap
mov dword ptr [eax],0 ; this is on the heap
Can you please shed some light on this what am I overlooking?
Relevant part of the disassembly can be found underneath:
int x = 0;
00111848 mov dword ptr [ebp-8],0
int y = 0;
0011184F mov dword ptr [ebp-14h],0
int* z = new int;
00111856 push 4
00111858 call 00111325
0011185D add esp,4
00111860 mov dword ptr [ebp+FFFFFF14h],eax
00111866 mov eax,dword ptr [ebp+FFFFFF14h]
0011186C mov dword ptr [ebp-20h],eax
*z = 0;
0011186F mov eax,dword ptr [ebp-20h]
00111872 mov dword ptr [eax],0