summaryrefslogtreecommitdiff
path: root/interface
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-10-11 12:33:38 +0200
committerMiguel <m.i@gmx.at>2018-10-11 12:33:38 +0200
commit1e5c0baa8cd59f651985ac3a7b41ab2ecbe90b5e (patch)
tree9da3bc1effa2b9da6762620971faedf00f7a6247 /interface
parent8b33f268b67455ded8d35f3c198425562173fa2e (diff)
c++ global constructors calling from crt
Diffstat (limited to 'interface')
-rw-r--r--interface/crt0.s50
1 files changed, 37 insertions, 13 deletions
diff --git a/interface/crt0.s b/interface/crt0.s
index 65123b7..914a99d 100644
--- a/interface/crt0.s
+++ b/interface/crt0.s
@@ -1,11 +1,8 @@
.global _start
-.global myinit //temporary quickfix / test
_start:
-// ALIGN stack
-
-//push %ebx
+//push %ebx // do we need to persist them???
//push %ecx
//cmp $0,_impure_ptr
@@ -22,7 +19,8 @@ _start:
//skipzero:
-/*
+// move impure pointer to our special page (check if not htere already!)
+
mov _impure_ptr,%eax
mov $0xf5000000,%ebx
@@ -34,11 +32,30 @@ add $4, %eax
cmp $0xf5001000,%ebx
jne copy
-*/
-
movl $0xf5000000, _impure_ptr
-//call _init
+call _init // constructors
+
+// constructors from array_init
+mov $__init_array_start,%eax
+
+nextctor:
+
+//cmp (__init_array_end),%eax
+cmp $__init_array_end,%eax
+je finctor
+
+push %eax
+call *(%eax)
+pop %eax
+
+add $4, %eax
+jmp nextctor
+
+finctor:
+
+//pop %ecx
+//pop %ebx
# environment adress was passed on stack
@@ -61,15 +78,22 @@ call main
and $-16,%esp
sub $4,%esp
+push %eax
+
+call _fini //desctructors
+
+// pop programmm return value
+pop %eax
+
+// ALIGN stack
+and $-16,%esp
+sub $4,%esp
+
# push exit code and pass to _exit syscall
push %eax
call exit
-# this should never be reached!
+# and this should never be reached!!
.wait:
hlt
jmp .wait
-
-myinit:
-call _init
-ret