I am creating code that calls a C function that gets the square root of an integer. The C function is external and in my folder. When calling it, i do not know how to give it a parameter so it knows what to calculate
I am using NASM Intel x86_64, Assembler is gcc, i do not know the current edition. I am using Linux
Currently my code is:
xor rsi, rsi ;just clears rsi
mov rsi, r15 ;r15 held the value that is supposed to be the parameter
call square
It currently just prints out a 0 as it is not taking a correct value.
How do i get it to take in the parameter?
Thank you.
According to the System V AMD64 ABI calling convention the first argument should be in the rdi
register.
You need to copy the value to rdi
instead of rsi
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.