summaryrefslogtreecommitdiff
path: root/ulib/entry.S
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2025-04-03 12:31:21 -0400
committerFreya Murphy <freya@freyacat.org>2025-04-03 12:31:21 -0400
commita524eb3846aac4d1b38f08cba49ff3503107042f (patch)
treedbe81fccf975f646a681e4fdcebd227cdfb98774 /ulib/entry.S
parentnew libs (diff)
downloadcomus-a524eb3846aac4d1b38f08cba49ff3503107042f.tar.gz
comus-a524eb3846aac4d1b38f08cba49ff3503107042f.tar.bz2
comus-a524eb3846aac4d1b38f08cba49ff3503107042f.zip
move old kernel code (for now) into kernel/old, trying to get long mode
Diffstat (limited to 'ulib/entry.S')
-rw-r--r--ulib/entry.S25
1 files changed, 25 insertions, 0 deletions
diff --git a/ulib/entry.S b/ulib/entry.S
new file mode 100644
index 0000000..87ad9c7
--- /dev/null
+++ b/ulib/entry.S
@@ -0,0 +1,25 @@
+//
+// user-level startup routine
+//
+ .text
+ .globl _start
+ .globl main
+ .globl exit
+
+// entry point - this is where the kernel starts us running
+_start:
+ // we immediately call main()
+ call main
+
+ // if we come back from that, it means the user
+ // program didn't call exit(), in which case the
+ // value returned from main() is the exit status
+
+ // push that value onto the stack and call exit()
+ subl $12, %esp
+ pushl %eax
+ call exit
+
+ // if we come back from that, something bad has
+ // happened, so we just lock up
+1: jmp 1b