summaryrefslogtreecommitdiff
path: root/src/user/runtimes/c/entry.asm
diff options
context:
space:
mode:
authorBenji Dial <benji6283@gmail.com>2020-09-19 14:53:29 -0400
committerBenji Dial <benji6283@gmail.com>2020-09-19 14:53:29 -0400
commitde20d7430df08731d9108acb83e1234ba7f1fe16 (patch)
tree8646f3d1bae3d30391df34766e3e58c0c2af8aab /src/user/runtimes/c/entry.asm
parent20853582d5385d12421433d21910e783caa00764 (diff)
downloadportland-os-de20d7430df08731d9108acb83e1234ba7f1fe16.tar.gz
file manager
Diffstat (limited to 'src/user/runtimes/c/entry.asm')
-rw-r--r--src/user/runtimes/c/entry.asm42
1 files changed, 42 insertions, 0 deletions
diff --git a/src/user/runtimes/c/entry.asm b/src/user/runtimes/c/entry.asm
new file mode 100644
index 0000000..bba8060
--- /dev/null
+++ b/src/user/runtimes/c/entry.asm
@@ -0,0 +1,42 @@
+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