From a4dea4148157a94a9143dbbd92fdd88b4358676c Mon Sep 17 00:00:00 2001 From: Alexey Gavrilov Date: Sat, 20 Dec 2025 19:39:05 +0700 Subject: Global variables initialization implementation User implementation of C runtime library objects (`crti.s` and `crtn.s`) for initialization (termination functionality are ignored). Changing files order passed to the linker. Rough order is: boot.s crti.o crtbegin.o other-link-objects.o crtend.o crtn.o Signed-off-by: Alexey Gavrilov --- kernel/boot.s | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'kernel/boot.s') diff --git a/kernel/boot.s b/kernel/boot.s index 281e1ca..11175af 100644 --- a/kernel/boot.s +++ b/kernel/boot.s @@ -1,11 +1,16 @@ section .text -extern main -extern _estack -global _start:function (_start.end - _start) +extern main, _estack, _init +global _start:function _start: - mov esp, _estack + ; Stack setup + mov eax, _estack + ; Align stack to odd address + and eax, 0xFFFFFFFE + mov esp, eax + + call _init call main cli .hang: hlt jmp .hang -.end: +; .end: -- cgit v1.2.3