Made printf() good!

This commit is contained in:
2024-05-30 10:30:39 +02:00
parent f4e8435603
commit 75410d3a6c
5 changed files with 91 additions and 45 deletions
+5 -4
View File
@@ -2,17 +2,18 @@
#define STDLIB_H
#include <stdint.h>
#include <syscall.h>
void* malloc(const uint32_t size) { // Use Syscall(3) - Malloc()
void* malloc(const uint32_t size) {
void* ptr = 0;
__asm__ volatile ("int $0x80" : : "a"(3), "b"(size));
__asm__ volatile ("int $0x80" : : "a"(SYS_MALLOC), "b"(size));
__asm__ volatile ("movl %%eax, %0" : "=r"(ptr));
return ptr;
}
void free(const void* ptr) { // Use Syscall(4) - Free()
__asm__ volatile ("int $0x80" : : "a"(4), "b"(ptr));
void free(const void* ptr) {
__asm__ volatile ("int $0x80" : : "a"(SYS_FREE), "b"(ptr));
}
#endif