Made malloc() and free()! They're in header stdlib.h as syscalls 3 & 4.

This commit is contained in:
2024-05-24 18:08:33 +02:00
parent f009bbdac9
commit f879ca122f
7 changed files with 211 additions and 15 deletions
+18
View File
@@ -0,0 +1,18 @@
#ifndef STDLIB_H
#define STDLIB_H
#include <stdint.h>
void* malloc(const uint32_t size) { // Use Syscall(3) - Malloc()
void* ptr = 0;
__asm__ volatile ("int $0x80" : : "a"(3), "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));
}
#endif