why using 8 byte register to carry 8 byte type but not using 4 byte register for 4 byte type

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… Read More why using 8 byte register to carry 8 byte type but not using 4 byte register for 4 byte type

why int& as function parameter uses QWORD(8 byte) memory but int parameter uses DWORD

In the code below, int firstFunction(int& refParam) { std::cout << "Type of refParam is: " << typeid(refParam).name() << ‘\n’; return refParam; } int secondFunction(int param) { std::cout << "Type of param is: " << typeid(param).name() << ‘\n’; return param; } int main() { int firstVar{ 1 }; int secondVar{ firstFunction(firstVar) }; int thirdVar{ secondFunction(firstVar) };… Read More why int& as function parameter uses QWORD(8 byte) memory but int parameter uses DWORD

do all variables are automatically get stored in starting with rax register as code execute as stuff start happening on variables

I have a simple C program that I assume generate simple assembly code this is my C program char *a="ba"; char x; void main(){x=a[0];} There is nothing especial about the generated assembly except these lines # test.c:4: void main(){x=a[0];} movq a(%rip), %rax # a, a.0_1 movzbl (%rax), %eax # *a.0_1, _2 # test.c:4: void main(){x=a[0];}… Read More do all variables are automatically get stored in starting with rax register as code execute as stuff start happening on variables