我正在阅读Assembly x86_64的一些示例,并点击了这张幻灯片:https://imgur.com/7torqTR 或万一链接断开:
void multstore
(long x, long y, long *dest) {
long t = mult2(x, y);
*dest = t;
}
long mult2(long a, long b)
{
long s = a * b;
return s;
}
0000000000400540 <multstore>:
400540: push %rbx # Save %rbx
400541: mov %rdx,%rbx # Save dest
400544: callq 400550 <mult2> # mult2(x,y)
400549: mov %rax,(%rbx) # Save at dest
40054c: pop %rbx # Restore %rbx
40054d: retq # Return
0000000000400550 <mult2>:
400550: mov %rdi,%rax # a
400553: imul %rsi,%rax # a * b
400557: retq # Return
我不明白的是在400541中为什么作者保存了DEST,这是怎么回事-我可以使用%rdx来处理工作:
mulstore:
push %rbx
callq mult2
mov %rax, (%rdx)
retq
这更简单吗?还是我错过了重要的东西? TY。