From 4130562b1555cabe441efe9420cebe12e7ed8d39 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sat, 13 Jan 2024 16:43:49 -0500 Subject: application loading --- stdlib/entry.cpp | 14 ++++++++++++++ stdlib/syscall.asm | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 stdlib/entry.cpp create mode 100644 stdlib/syscall.asm (limited to 'stdlib') diff --git a/stdlib/entry.cpp b/stdlib/entry.cpp new file mode 100644 index 0000000..5557c8a --- /dev/null +++ b/stdlib/entry.cpp @@ -0,0 +1,14 @@ +int main(int argc, char **argv); + +extern "C" [[noreturn]] void _entry() { + //TODO: get command line via system call and populate argc and argv. + int argc = 0; + char **argv = 0; + + int result = main(argc, argv); + + //TODO: exit via system call and return result. + (void)result; + while (1) + ; +} diff --git a/stdlib/syscall.asm b/stdlib/syscall.asm new file mode 100644 index 0000000..eba7ec0 --- /dev/null +++ b/stdlib/syscall.asm @@ -0,0 +1,35 @@ +bits 64 + +global encode_color +global get_framebuffer +global draw_framebuffer + +section .text + +encode_color: + mov rax, 0 + syscall + ret + +get_framebuffer: + push rcx + push rdx + push rsi + push rdi + mov rax, 1 + syscall + pop rcx + mov qword [rcx], rax + pop rcx + mov dword [rcx], edi + shr rdi, 32 + pop rcx + mov dword [rcx], edi + pop rcx + mov dword [rcx], esi + ret + +draw_framebuffer: + mov rax, 2 + syscall + ret -- cgit v1.2.3