From 08af048d767f4e3179cbf94ed7be86d309364f92 Mon Sep 17 00:00:00 2001 From: wullie Date: Sun, 8 Feb 2026 15:45:17 +0000 Subject: [PATCH] Upload files to "/" --- Read.md | 21 +++++++++++++++ funcs.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++ main.c | 27 +++++++++++++++++++ stdWullie.h | 45 ++++++++++++++++++++++++++++++++ 4 files changed, 168 insertions(+) create mode 100644 Read.md create mode 100644 funcs.c create mode 100644 main.c create mode 100644 stdWullie.h diff --git a/Read.md b/Read.md new file mode 100644 index 0000000..cd99bab --- /dev/null +++ b/Read.md @@ -0,0 +1,21 @@ +# StdWullie +*** + +this lib is an attempt to make some better functions without the use of glibC + +## features + +- print: just prints text to console +- ColorPrint: changes the foreground color of text to an ANSI color +- BackgroundPrint: changs the background color of text to an ANSI color + +*** +## how to build + +to build all thats needed is the gcc compiler and a version of linux + +### commands + +- gcc -c -fPIC main.c func.c -o stdwullie.o +- gcc -shared -o libstdWullie.so stdWullie.o + diff --git a/funcs.c b/funcs.c new file mode 100644 index 0000000..66333d2 --- /dev/null +++ b/funcs.c @@ -0,0 +1,75 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie.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(;;){} +} + + +// handles the length of a string for print +long unsigned strlen(char *string){ + char *cursor = string; + while(*cursor){ + cursor++; + } + long unsigned result = cursor - string; + return result; +} + + +// print +void print(char *string){ + syscall3(SYS_write, 1, (long)string, strlen(string)); +} + +// it can do everythig print can but better +void ColorPrint(char *string, const 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){ + 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); +} + diff --git a/main.c b/main.c new file mode 100644 index 0000000..f529af9 --- /dev/null +++ b/main.c @@ -0,0 +1,27 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#include "stdWullie.h" + +int main(){ + print("look Ma no stdlib\n"); + ColorPrint("NOW WITH COLORS\n", RED); + BackgroundPrint("and backgrounds\n", BBLUE); + return 0; +} + +// #I say softly to myself "FUCK YOUR STDLIB"# +// handles the main loop +__attribute__((naked)) void _start(){ + __asm__ __volatile__( + "xor %ebp, %ebp\n" + "mov (%rsp), %rdi\n" + "lea 8(%rsp), %rsi\n" + "and $-16, %rsp\n" + "call main\n" + "mov %rax, %rdi\n" + "call exit\n" + ); + +} diff --git a/stdWullie.h b/stdWullie.h new file mode 100644 index 0000000..94f40dc --- /dev/null +++ b/stdWullie.h @@ -0,0 +1,45 @@ +// this code is licenced under Wrathmark licence +// © 2026 wullie wulliestudio.com +// please see attached licence for full usage and rights + +#ifndef MIAN_h +#define MAIN_h + +// ANSI colors +// foreground +#define BLACK "\x1b[30m" +#define RED "\x1b[31m" +#define GREEN "\x1b[32m" +#define YELLOW "\x1b[33m" +#define BLUE "\x1b[34m" +#define MAGENTA "\x1b[35m" +#define CYAN "\x1b[36m" +#define WHITE "\x1b[37m" +#define NORMAL "\x1b[m" + +// background +#define BBLACK "\x1b[40m" +#define BRED "\x1b[41m" +#define BGREEN "\x1b[42m" +#define BYELLOW "\x1b[43m" +#define BBLUE "\x1b[44m" +#define BMAGENTA "\x1b[45m" +#define BCYAN "\x1b[46m" +#define BWHITE "\x1b[47m" + +// SYS calls +#define SYS_write 1 +#define SYS_exit 60 + + +// funcs +void ColorPrint(char *string, const char *color); +void BackgroundPrint(char *string, const char *Bcolor); + +// basic funcs +void exit(int code); +long unsigned strlen(char *string); +void print(char *string); + +#endif +