retq和ret有什么区别? [英] What is the difference between retq and ret?
本文介绍了retq和ret有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
让我们考虑以下程序,该程序计算参数的无符号平方:
Let's consider the following program, which computes an unsigned square of the argument:
.global foo
.text
foo:
mov %rdi, %rax
mul %rdi
ret
此文件已由as
正确编译,但反汇编为
This is properly compiled by as
, but disassembles to
0000000000000000 <foo>:
0: 48 89 f8 mov %rdi,%rax
3: 48 f7 e7 mul %rdi
6: c3 retq
ret
和retq
之间是否有区别?
推荐答案
在长(64位)模式下,通过从堆栈中弹出一个四字地址到%rip
,您将返回(ret
).
In long (64-bit) mode, you return (ret
) by popping a quadword address from the stack to %rip
.
在32位模式下,通过从堆栈中将双字地址弹出到%eip
来返回(ret
).
In 32-bit mode, you return (ret
) by popping a dword address from the stack to %eip
.
某些工具,例如objdump -d
调用第一个retq
.只是一个名字,指令编码是相同的(C3
).
Some tools like objdump -d
call the first one retq
. It's just a name, the instruction encoding is the same either way (C3
).
这篇关于retq和ret有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文