What is the "-4" for in assembler: movl $1, -4(%rbp)

1k views Asked by At
int x=1;
int y=2;
int z=3;

turns into

movl    $1, -4(%rbp)
movl    $2, -8(%rbp)
movl    $3, -12(%rbp)

What is the -4,-8,-12 for ? Why is it going by 4's? 4 bytes = 32 bits?

1

There are 1 answers

0
DevSolar On BEST ANSWER

-4 / -8 / -12 bytes relative to the address held in rbp, which is the pointer to the top of the stack (which grows downward). 4 bytes / 32 bits because that is the size of int on your machine.