You need to add 0x2000000
to the call number using a syscalls.master
file. I'm using the XNU bds/kern/syscalls.master file. Here's a function in the syscalls.master
file that I'm going to call:
4 AUE_NULL ALL { user_ssize_t write(int fd, user_addr_t cbuf, user_size_t nbyte); }
In terms of which registers to pass arguments to, it's the same as 64-bit Linux. Arguments are passed through the rdi
, rsi
, rdx
, r10
, r8
and r9
registers, respectively. The write
function takes three arguments, which are described in the following assembly:
mov rax, 0x2000004 ; sys_write call identifier
mov rdi, 1 ; STDOUT file descriptor
mov rsi, myMessage ; buffer to print
mov rdx, myMessageLen ; length of buffer
syscall ; make the system call