我在上一个问题中看到了这个示例代码。我对 int add(int a, int b)
的参数如何自动出现在 esi 和 edi 中感到困惑?这是默认调用约定吗?我在哪里可以找到更多此类信息。
.globl _add // make it global so that others can find this symbol
....
_add: // int add(int a, int b)
movl %esi, %eax
addl %edi, %eax
ret
最佳答案
System V AMD64 ABI 的调用约定在 Solaris、Linux、FreeBSD、OS X 上得到遵循,[16] 并且是 Unix 和类 Unix 操作系统中的事实标准。前六个整数或指针参数在寄存器 RDI、RSI、RDX、RCX(Linux 内核接口(interface)中的 R10[17]:124)、R8 和 R9 中传递,而 XMM0、XMM1、XMM2、XMM3、XMM4、XMM5、 XMM6 和 XMM7 用于某些浮点参数。
关于c - 在汇编中调用符号时函数参数是如何传递的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39437681/