summaryrefslogtreecommitdiff
path: root/src/user/runtimes/c/pcrt.asm
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
committerBenji Dial <benji6283@gmail.com>2021-01-24 12:00:11 -0500
commitbce944d1498eaa3b6940ee234c863b3548a66b37 (patch)
treeea40c087ab4f0f236aee8d158cf68550f5209f72 /src/user/runtimes/c/pcrt.asm
parentca731aa747214919df7b3dfe3478dbe787ce5b68 (diff)
downloadportland-os-bce944d1498eaa3b6940ee234c863b3548a66b37.tar.gz
graphics!
Diffstat (limited to 'src/user/runtimes/c/pcrt.asm')
-rw-r--r--src/user/runtimes/c/pcrt.asm45
1 files changed, 45 insertions, 0 deletions
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