What is the difference between retq and ret?

前端 未结 1 1232
别那么骄傲
别那么骄傲 2021-02-12 09:37

Let\'s consider the following program, which computes an unsigned square of the argument:

.global foo
.text
foo:
    mov %rdi, %rax
    mul %rdi
    ret
<         


        
相关标签:
1条回答
  • 2021-02-12 10:34

    In long (64-bit) mode, you return (ret) by popping a quadword address from the stack to %rip.

    In 32-bit mode, you return (ret) by popping a dword address from the stack to %eip.

    Some tools like objdump -d call the first one retq. It's just a name, the instruction encoding is the same either way (C3).

    0 讨论(0)
提交回复
热议问题