summaryrefslogtreecommitdiff
path: root/interface/crt0.s
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-09-13 14:40:09 +0200
committerMiguel <m.i@gmx.at>2018-09-13 14:40:09 +0200
commit3bba2df34be1680777ff85ad4fbc43717609ec75 (patch)
tree983e3c2b5667e3aa150502f59453ecebeeeba63a /interface/crt0.s
parentf844fafd324fbf4c7a986df2f0814f2e2d93bcd8 (diff)
thinking about syscalls and newlib ...
Diffstat (limited to 'interface/crt0.s')
-rw-r--r--interface/crt0.s40
1 files changed, 40 insertions, 0 deletions
diff --git a/interface/crt0.s b/interface/crt0.s
new file mode 100644
index 0000000..ad9884f
--- /dev/null
+++ b/interface/crt0.s
@@ -0,0 +1,40 @@
+.global _start
+
+_start:
+
+# copy reent to this page
+push %ebx
+push %ecx
+
+mov _impure_ptr,%eax
+mov $0xf5000000,%ebx
+copy:
+mov (%eax),%ecx
+mov %ecx,(%ebx)
+add $4, %ebx
+add $4, %eax
+cmp $0xf5001000,%ebx
+jne copy
+
+pop %ecx
+pop %ebx
+
+# environment adress was passed on stack
+
+movl $0xf5000000, _impure_ptr
+
+pop %eax
+mov %eax, environ
+
+
+# call main (argc and argv are on the stack)
+call main
+
+# push exit code and pass to _exit syscall
+push %eax
+call _exit
+
+# this should never be reached!
+.wait:
+ hlt
+jmp .wait