From 2a40ef8c27680d42900e9b51696f95b61af8fe82 Mon Sep 17 00:00:00 2001 From: wullie Date: Fri, 20 Feb 2026 15:26:23 +0000 Subject: [PATCH] Upload files to "src" --- src/funcs.c | 45 ++++++++++-------------------------- src/main.c | 2 ++ src/syscall.c | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 src/syscall.c diff --git a/src/funcs.c b/src/funcs.c index 66333d2..9bccd80 100644 --- a/src/funcs.c +++ b/src/funcs.c @@ -3,41 +3,11 @@ // please see attached licence for full usage and rights #include "stdWullie.h" +#include "localheader.h" -// syscall1 -long syscall1(long number, long arg1){ - long result; - - // asm for a system call with one arg - __asm__ __volatile( - "syscall" - : "=a"(result) - : "a"(number), "D"(arg1) - : "rcx", "r11", "memory" - ); - - return result; -} - -// syscall3 -long syscall3(long number, long arg1, long arg2, long arg3){ - - long result; - - // asm for a system call with 3 args - __asm__ __volatile( - "syscall" - : "=a"(result) - : "a"(number), "D"(arg1), "S"(arg2), "d"(arg3) - : "rcx", "r11", "memory" - ); - - return result; -} // our own exit LINUX ONLY void exit(int code){ - syscall1(SYS_exit, code); for(;;){} } @@ -60,16 +30,25 @@ void print(char *string){ } // it can do everythig print can but better -void ColorPrint(char *string, const char *color){ +void ColorPrint(char *string, char *color){ syscall3(SYS_write, 1, (long)color, strlen(color)); syscall3(SYS_write, 1, (long)string, strlen(string)); syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1); } // instead of changing the foreground it changes the background -void BackgroundPrint(char *string, const char *Bcolor){ +void BackgroundPrint(char *string, char *Bcolor){ syscall3(SYS_write, 1, (long)Bcolor, strlen(Bcolor)); syscall3(SYS_write, 1, (long)string, strlen(string)); syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1); } +// it should be set to W for wumbo +long Wopen(const char *pathname, int flags, int mode){ + syscall3(SYS_open, (long)pathname, flags, mode); +} + +// named like this to not cause compat issues with glibc +long closeFile(long fd){ + syscall2(SYS_close, fd); +} diff --git a/src/main.c b/src/main.c index f529af9..0efd1af 100644 --- a/src/main.c +++ b/src/main.c @@ -3,11 +3,13 @@ // please see attached licence for full usage and rights #include "stdWullie.h" +#include "localheader.h" int main(){ print("look Ma no stdlib\n"); ColorPrint("NOW WITH COLORS\n", RED); BackgroundPrint("and backgrounds\n", BBLUE); + ColorPrint("NOW WITH COLORS", RED); return 0; } diff --git a/src/syscall.c b/src/syscall.c new file mode 100644 index 0000000..b4254a5 --- /dev/null +++ b/src/syscall.c @@ -0,0 +1,63 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "localheader.h" + +// syscall1 +long syscall1(long number, long arg1){ + long result; + + // asm for a system call with one arg + __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 for system call with 2 args + __asm__ __volatile( + "syscall" + : "=a"(result) + : "a"(number), "D"(arg1), "S"(arg2) + : "rcx", "r11","memory" + ); + return result; +} + + +// syscall3 +long syscall3(long number, long arg1, long arg2, long arg3){ + + long result; + + // asm for a system call with 3 args + __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; + __asm__ __volatile( + "syscall" + : "=a"(result) + : "a"(number), "D"(arg1), "S"(arg2), "d"(arg3), "b"(arg4) + : "rcx", "r11", "memory" + + ); + return result; +} +