Upload files to "/"
This commit is contained in:
21
Read.md
Normal file
21
Read.md
Normal file
@@ -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
|
||||
|
||||
75
funcs.c
Normal file
75
funcs.c
Normal file
@@ -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);
|
||||
}
|
||||
|
||||
27
main.c
Normal file
27
main.c
Normal file
@@ -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"
|
||||
);
|
||||
|
||||
}
|
||||
45
stdWullie.h
Normal file
45
stdWullie.h
Normal file
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user