Quiz Entry - updated: 2026.07.06
What does movl $0x1, (%rsp) vs movl $0x1, %eax do differently?
The first writes 1 to memory at the address in %rsp (the parentheses mean dereference); the second puts 1 straight into the %eax register.
# Write 1 to memory at address rsp
movl $0x1, (%rsp)
# Put 1 in the eax register
movl $0x1, %eax
When you see movl $value, offset(%rsp): It's initializing a local variable on the stack.
# Initialize local vars on stack
movl $0, (%rsp)
movl $1, 4(%rsp)
movl $2, 8(%rsp)
This is like:
int a = 0;
int b = 1;
int c = 2;
The size suffix matters here:
movlwrites 4 bytes (int)movqwrites 8 bytes (long/pointer)movbwrites 1 byte (char)movwwrites 2 bytes (short)
Go deeper: