bits 32 section .startup extern _bss_start extern _bss_size extern kmain MB_MAGIC equ 0x1badb002 MB_FLAGS equ 0 global start start: jmp .skip_mboot_hdr ; multiboot header align 4 dd MB_MAGIC dd MB_FLAGS dd -(MB_MAGIC + MB_FLAGS) ; checksum times 5 dd 0 .skip_mboot_hdr: ; init temporary kernel stack at the top of conventional memory mov esp, 0xa0000 ; clear .bss (if it's not empty) ; due to the ALIGN(4) statements in the linker script, it's guaranteed ; that _bss_start and _bss_end will be 32bit-aligned, so we can use ; rep stosd to clear it mov ecx, _bss_size test ecx, ecx jz .skip_bss xor eax, eax mov edi, _bss_start shr ecx, 2 ; _bss_size is in bytes, we need count in "dwords" rep stosd .skip_bss: call kmain ; kmain shouldn't ever return, but we'll enter a hlt loop just in case .inf: hlt jmp .inf ; vi:ft=nasm: