summaryrefslogtreecommitdiff
path: root/interface
diff options
context:
space:
mode:
Diffstat (limited to 'interface')
-rw-r--r--interface/crt0.s40
1 files changed, 20 insertions, 20 deletions
diff --git a/interface/crt0.s b/interface/crt0.s
index 914a99d..88e316e 100644
--- a/interface/crt0.s
+++ b/interface/crt0.s
@@ -1,6 +1,6 @@
.global _start
-_start:
+_start: // in the beginning...
//push %ebx // do we need to persist them???
//push %ecx
@@ -19,11 +19,10 @@ _start:
//skipzero:
-// move impure pointer to our special page (check if not htere already!)
-
+///////////////////////////////////////////////////////////////////////
+// move impure pointer to our special page (todo: check if not htere already!)
mov _impure_ptr,%eax
mov $0xf5000000,%ebx
-
copy:
mov (%eax),%ecx
mov %ecx,(%ebx)
@@ -31,16 +30,16 @@ add $4, %ebx
add $4, %eax
cmp $0xf5001000,%ebx
jne copy
-
movl $0xf5000000, _impure_ptr
+////////////////////////////////////////////////////////////////////////
-call _init // constructors
+call _init // constructors from .ctors
-// constructors from array_init
+///////////////////////////////////////////////////////////////////////
+// constructors from array_init ////////////////////////////
mov $__init_array_start,%eax
nextctor:
-
//cmp (__init_array_end),%eax
cmp $__init_array_end,%eax
je finctor
@@ -52,40 +51,41 @@ pop %eax
add $4, %eax
jmp nextctor
-finctor:
+finctor: // ready with global ctors
+////////////////////////////////////////////////////////////////////////
//pop %ecx
//pop %ebx
+###############################################
# environment adress was passed on stack
-
pop %eax
mov %eax, environ
+###############################################
-pop %ecx
-pop %ebx
+pop %ecx //argc
+pop %ebx //& argv
-and $-16,%esp
+and $-16,%esp //align stack
sub $8,%esp
-push %ebx
-push %ecx
+push %ebx //argv
+push %ecx //& argc
-# call main (argc and argv are on the stack)
+# call main (argc and argv are on the (realigned) tack)
call main
-// ALIGN stack
+// ALIGN stack again (todo: do we need this!??!!)
and $-16,%esp
sub $4,%esp
push %eax
-
-call _fini //desctructors
+call _fini //desctructors from .dtors
// pop programmm return value
pop %eax
-// ALIGN stack
+// ALIGN stack (???)
and $-16,%esp
sub $4,%esp