This is the code snippet that i am looking
#include <cstdint>
int main() {
unsigned int i = 0x11111111;
unsigned int j = 0xFFFFFFFF;
uint64_t k = 0xFFFFFFFF11111111;
}
0000000140001000 sub rsp,18h
0000000140001004 mov dword ptr [rsp],11111111h
000000014000100B mov dword ptr [rsp+4],0FFFFFFFFh
0000000140001013 mov rax,0FFFFFFFF11111111h
000000014000101D mov qword ptr [rsp+8],rax
0000000140001022 xor eax,eax
0000000140001024 add rsp,18h
0000000140001028 ret
We are using rax
register to carry uint64_t
value.
Why we are not using eax
or some other 32 bit register for int
?
>Solution :
Since you’re not compiling with optimization, it is not using registers to hold any of your variables — they’re all in the stack frame (at rsp, rsp+4,and rsp+8)
rax here is just used here to temporarily hold the constant 0xFFFFFFFF11111111 as there’s no single instruction to write a 64 bit value to memory. There is an instruction to write a 32-bit value to memory, so that is used for the unsigned int initializations