Newer
Older
CubeCactusCpp / os / boot / boot.S
@agalyaramadoss agalyaramadoss on 6 Dec 809 bytes fixed keyboard serial mode
; Boot loader entry point for CubeCactusOS
; Multiboot-compliant boot code (NASM syntax)

MBALIGN  equ 1 << 0
MEMINFO  equ 1 << 1
FLAGS    equ MBALIGN | MEMINFO
MAGIC    equ 0x1BADB002
CHECKSUM equ -(MAGIC + FLAGS)

section .multiboot
align 4
    dd MAGIC
    dd FLAGS
    dd CHECKSUM

section .text
global _start
extern main

_start:
    ; Set up stack
    mov esp, stack_top
    
    ; Reset EFLAGS
    push 0
    popf
    
    ; Write 'OK' to top-left of screen (VGA 0xB8000) to show we booted
    mov word [0xB8000], 0x074B    ; 'K' with white on black
    mov word [0xB8002], 0x074F    ; 'O' with white on black
    
    ; Call kernel main
    call main
    
    ; Hang if kernel returns
    cli
.hang:
    hlt
    jmp .hang

section .bss
align 16
stack_bottom:
    resb 16384  ; 16 KiB stack
stack_top: