im making my own programming language and i wanted to call some functions from libc (es strcat and printf) but im unsure on how to call them correctly(i dont which cpu registry to use and if i have to actually use them to pass arguments), by now i got printf to work following a git hub example. (https://gist.github.com/jamichaels/a5e770105615d9e32b18)
This is how i ended up printing stuff:
SECTION .data
endLine db 0Ah, 0
integer_printf: db '%d', 10,0
float_printf db '%f', 10,0
string_format db '%s', 10,0
var db "test",0
SECTION .text
extern printf
global main
printInt:
mov rdi,integer_printf
xor rax,rax
call printf
ret
printFloat:
mov rdi,float_printf
call printf
ret
printStr:
mov rdi,string_format
xor rax,rax
call printf
ret
exit_program:
mov rax, 60
syscall
main:
mov rsi, var
call printStr
MOV rdi, 30
call exit_program
nasm -f elf64 -o test.o main.asm && gcc -o test test.o -lc -no-pie
thanks in advice for any help