From bce944d1498eaa3b6940ee234c863b3548a66b37 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 24 Jan 2021 12:00:11 -0500 Subject: graphics! --- src/user/runtimes/c/elf.ld | 1 + src/user/runtimes/c/entry.asm | 42 ---------------------------------------- src/user/runtimes/c/pcrt.asm | 45 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 42 deletions(-) delete mode 100644 src/user/runtimes/c/entry.asm create mode 100644 src/user/runtimes/c/pcrt.asm (limited to 'src/user/runtimes') diff --git a/src/user/runtimes/c/elf.ld b/src/user/runtimes/c/elf.ld index f321be2..3e9a034 100644 --- a/src/user/runtimes/c/elf.ld +++ b/src/user/runtimes/c/elf.ld @@ -11,6 +11,7 @@ SECTIONS { .__pcrt_before_main : { __pcrt_before_main_start = .; *(.__pcrt_before_main) + *(.init_array) __pcrt_before_main_end = .; } diff --git a/src/user/runtimes/c/entry.asm b/src/user/runtimes/c/entry.asm deleted file mode 100644 index bba8060..0000000 --- a/src/user/runtimes/c/entry.asm +++ /dev/null @@ -1,42 +0,0 @@ -bits 32 - -global __pcrt_entry -global __pcrt_quit - -extern main -extern __pcrt_before_main_start -extern __pcrt_before_main_end -extern __pcrt_before_quit_start -extern __pcrt_before_quit_end - -section .text -__pcrt_entry: - mov esp, stack - push edx - - mov ebx, __pcrt_before_main_start -.before_main_loop: - cmp ebx, __pcrt_before_main_end - je .call_main - call dword [ebx] - add ebx, 4 - jmp .before_main_loop - -.call_main: - call main - -__pcrt_quit: - mov ebx, __pcrt_before_quit_start -.before_quit_loop: - cmp ebx, __pcrt_before_quit_end - je .end_task - call dword [ebx] - add ebx, 4 - jmp .before_quit_loop - -.end_task: - int 0x38 - -section .stack nobits alloc noexec write align=16 -resb 4096 -stack: \ No newline at end of file diff --git a/src/user/runtimes/c/pcrt.asm b/src/user/runtimes/c/pcrt.asm new file mode 100644 index 0000000..85c898c --- /dev/null +++ b/src/user/runtimes/c/pcrt.asm @@ -0,0 +1,45 @@ +bits 32 + +global __pcrt_entry +global __pcrt_quit +global calling_task +global stdio_task + +extern main +extern __pcrt_before_main_start +extern __pcrt_before_main_end +extern __pcrt_before_quit_start +extern __pcrt_before_quit_end + +section .text +__pcrt_entry: + mov dword [calling_task], esi + mov dword [stdio_task], edi + push edx + + mov ebx, __pcrt_before_main_start +.before_main_loop: + cmp ebx, __pcrt_before_main_end + je .call_main + call dword [ebx] + add ebx, 4 + jmp .before_main_loop + +.call_main: + call main + +__pcrt_quit: + mov ebx, __pcrt_before_quit_start +.before_quit_loop: + cmp ebx, __pcrt_before_quit_end + je .end_task + call dword [ebx] + add ebx, 4 + jmp .before_quit_loop + +.end_task: + int 0x38 + +section .bss +calling_task resd 1 +stdio_task resd 1 \ No newline at end of file -- cgit v1.2.3