Update src/syscall.c

This commit is contained in:
2026-08-11 21:06:51 +00:00
parent 26e1056597
commit 7443de7152
+56
View File
@@ -0,0 +1,56 @@
// this code is licenced under Wrathmark licence
// © 2026 wullie wulliestudio.com
// please see attached licence for full usage and rights
#include "LocalHeader.h"
// look at me I am the handler now
// each numbered syscall take that amount of arguments eg syscall1 takes one arg
long syscall1(long number, long arg1){
long result;
__asm__ __volatile(
"syscall"
: "=a"(result)
: "a"(number), "D"(arg1)
: "rcx", "r11", "memory"
);
return result;
}
long syscall2(long number, long arg1, long arg2){
long result;
__asm__ __volatile(
"syscall"
: "=a"(result)
: "a"(number), "D"(arg1), "S"(arg2)
: "rcx", "r11", "memory"
);
return result;
}
long syscall3(long number, long arg1, long arg2, long arg3){
long result;
__asm__ __volatile(
"syscall"
: "=a"(result)
: "a"(number), "D"(arg1), "S"(arg2), "d"(arg3)
: "rcx", "r11", "memory"
);
return result;
}
long syscall4(long number, long arg1, long arg2, long arg3, long arg4){
long result;
register long r10 __asm__("r10") = arg4;
__asm__ __volatile(
"syscall"
: "=a"(result)
: "a"(number), "D"(arg1), "S"(arg2), "d"(arg3), "r"(r10)
: "rcx", "r11", "memory"
);
return result;
}