Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- global loader ; the entry symbol for ELF
- extern main
- section .__mbHeader
- align 0x4
- mboot:
- MODULEALIGN equ 1<<0 ; align loaded modules on page boundaries
- MEMINFO equ 1<<1 ; provide memory map
- MAGIC_NUMBER equ 0x1BADB002 ; define the magic number constant
- FLAGS equ MODULEALIGN | MEMINFO ; multiboot flags
- CHECKSUM equ -(MAGIC_NUMBER + FLAGS) ; calculate the checksum
- ; (magic number + checksum + flags should equal 0)
- KERNEL_STACK_SIZE equ 4096 ; size of stack in bytes
- ; the code must be 4 byte aligned
- dd MAGIC_NUMBER ; write the magic number to the machine code,
- dd FLAGS ; the flags,
- dd CHECKSUM ; and the checksum
- section .text ; start of the text (code) section
- loader: ; the loader label (defined as entry point in linker script)
- mov esp, kernel_stack + KERNEL_STACK_SIZE ; point esp to the start of the stack (end of memory area)
- call main
- .loop:
- jmp .loop ; loop forever
- section .bss
- align 4 ; align at 4 bytes
- kernel_stack: ; label points to beginning of memory
- resb KERNEL_STACK_SIZE ; reserve stack for the kernel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement