What is the “-4” for in assembler: movl $1, -4(%rbp) [duplicate]

我怕爱的太早我们不能终老 提交于 2020-12-15 07:06:37

问题


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:


-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.



来源:https://stackoverflow.com/questions/64122235/what-is-the-4-for-in-assembler-movl1-4rbp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!