2 c assembly gcc x86-64 instruction-set
下面是我的代码:
代码
// this function might look weird, just for demo purpose
void func4(int x, int y, int z) {
int t = z - y;
int k = t >> 31;
t = (t + k) >> 1;
k = t + y;
if(k <= x) {
t = 0;
if(k >= 1) {
return;
}else {
y = k + 1;
func4(x, y, z);
}
}else {
z = k - 1;
func4(x, y, z);
}
}
Run Code Online (Sandbox Code Playgroud)
组装代码:
// only show relevant code
func4:
subq $8, %rsp // decrement %rsp by 8, but why?
movl %edx, %eax
subl %esi, %eax
... // all operations on registers
addq $8, %rsp
ret
Run Code Online (Sandbox Code Playgroud)
所以既然每个操作都可以通过寄存器来完成,没有任何东西被压入堆栈,不涉及指针,那么为什么首先%rsp
要减少 8 呢?是为了对齐/偏移吗?
归档时间: |
|
查看次数: |
97 次 |
最近记录: |