From 1195ca0bd84693fd56f6d34a9f2de3107b9820bf Mon Sep 17 00:00:00 2001 From: Miguel Date: Thu, 13 Sep 2018 23:26:47 +0200 Subject: ext2 review --- userspace/crt0.s | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) mode change 120000 => 100644 userspace/crt0.s (limited to 'userspace') diff --git a/userspace/crt0.s b/userspace/crt0.s deleted file mode 120000 index 8d17c13..0000000 --- a/userspace/crt0.s +++ /dev/null @@ -1 +0,0 @@ -../newlib/crt0.s \ No newline at end of file diff --git a/userspace/crt0.s b/userspace/crt0.s new file mode 100644 index 0000000..ad9884f --- /dev/null +++ b/userspace/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 -- cgit v1.2.3