mirror of
https://github.com/JannisHeydemann/BoredOS.git
synced 2026-05-30 10:26:59 +00:00
Kernel V3.0.0
This commit is contained in:
26
src/kernel/userland/crt0.asm
Normal file
26
src/kernel/userland/crt0.asm
Normal file
@@ -0,0 +1,26 @@
|
||||
; userland/crt0.asm
|
||||
global _start
|
||||
extern main
|
||||
extern sys_exit
|
||||
|
||||
section .text
|
||||
_start:
|
||||
; The kernel loads the ELF and jumps here.
|
||||
; RSP should point to the 0x800000 stack.
|
||||
|
||||
; Align the stack to 16 bytes for C functions (System V ABI)
|
||||
and rsp, -16
|
||||
|
||||
; Call main(argc, argv)
|
||||
; We don't have argc or argv yet, pass 0
|
||||
xor rdi, rdi
|
||||
xor rsi, rsi
|
||||
call main
|
||||
|
||||
; If main returns, call exit(status)
|
||||
mov rdi, rax ; Pass main's return value to exit syscall
|
||||
call sys_exit
|
||||
|
||||
; Fallback halt if exit miraculously returns
|
||||
.hang:
|
||||
jmp .hang
|
||||
Reference in New Issue
Block a user