Reputation: 167
I try to modify some of arguments passed to my assembly function in C program. I have tried it already in x86 assembly but in x64 it doesn't seem to work anymore.
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
Upvotes: 0
Views: 1080
Reputation: 843
The way arguments are passed to a function in C depends on the calling convention.
Here, the way you modify arguments use the x86 calling convention properties (arguments are passed via the stack). But in x86_64, the calling convention is different (and may differ depending on your compiler). Arguments are generally passed via registers so modifying the stack does not modify arguments.
You can see the list of x86 calling convention on Wikipedia
Upvotes: 1