从 C 程序调用的英特尔 x64 汇编函数如何修改通过引用传递的参数

Intel x64 assembly function called from C program how to modify arguments passed by reference

我尝试在 C 程序中修改传递给我的汇编函数的一些参数。 我已经在 x86 汇编中尝试过了,但在 x64 中它似乎不再起作用了。

section .text
global f
f:
  push rbp
  mov rbp, rsp
  ;[rbp+8]  bitmap beginning address (unsigned*) ?
  ;[rbp+12] bitmap width (int*) ?
  ;[rbp+16] bitmap height (int*) ?
  ;[rbp+20] current X pos (double*) ?
  ;[rbp+24] current Y pos (double*) ?

  mov rax, [rbp+12]

  mov rcx, [rax]
  inc rcx
  mov [rax], rcx 

  mov rsp, rbp
  pop rbp
  ret

在 C 中将参数传递给函数的方式取决于调用约定

在这里,您修改参数的方式使用 x86 调用约定属性(参数通过堆栈传递)。但在 x86_64 中,调用约定不同(并且可能因您的编译器而异)。参数通常通过寄存器传递,因此修改堆栈不会修改参数。

您可以看到 list of x86 calling convention on Wikipedia