Upload files to "src"
This commit is contained in:
45
src/funcs.c
45
src/funcs.c
@@ -3,41 +3,11 @@
|
|||||||
// please see attached licence for full usage and rights
|
// please see attached licence for full usage and rights
|
||||||
|
|
||||||
#include "stdWullie.h"
|
#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
|
// our own exit LINUX ONLY
|
||||||
void exit(int code){
|
void exit(int code){
|
||||||
|
|
||||||
syscall1(SYS_exit, code);
|
syscall1(SYS_exit, code);
|
||||||
for(;;){}
|
for(;;){}
|
||||||
}
|
}
|
||||||
@@ -60,16 +30,25 @@ void print(char *string){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// it can do everythig print can but better
|
// 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)color, strlen(color));
|
||||||
syscall3(SYS_write, 1, (long)string, strlen(string));
|
syscall3(SYS_write, 1, (long)string, strlen(string));
|
||||||
syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1);
|
syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
// instead of changing the foreground it changes the background
|
// 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)Bcolor, strlen(Bcolor));
|
||||||
syscall3(SYS_write, 1, (long)string, strlen(string));
|
syscall3(SYS_write, 1, (long)string, strlen(string));
|
||||||
syscall3(SYS_write, 1, (long)NORMAL, sizeof(NORMAL)-1);
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,11 +3,13 @@
|
|||||||
// please see attached licence for full usage and rights
|
// please see attached licence for full usage and rights
|
||||||
|
|
||||||
#include "stdWullie.h"
|
#include "stdWullie.h"
|
||||||
|
#include "localheader.h"
|
||||||
|
|
||||||
int main(){
|
int main(){
|
||||||
print("look Ma no stdlib\n");
|
print("look Ma no stdlib\n");
|
||||||
ColorPrint("NOW WITH COLORS\n", RED);
|
ColorPrint("NOW WITH COLORS\n", RED);
|
||||||
BackgroundPrint("and backgrounds\n", BBLUE);
|
BackgroundPrint("and backgrounds\n", BBLUE);
|
||||||
|
ColorPrint("NOW WITH COLORS", RED);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
src/syscall.c
Normal file
63
src/syscall.c
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user