Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ### Multiboot header section ###
- section .multiboot
- MODULEALIGN equ 1 << 0
- MEMINFO equ 1 << 1
- FLAGS equ MODULEALIGN | MEMINFO
- MAGIC equ 0x1BADB002
- CHECKSUM equ -(MAGIC + FLAGS)
- ; Fill constants into memory (dwords)
- align 4
- dd MAGIC
- dd FLAGS
- dd CHECKSUM
- ; ### Code section ###
- section .text
- global loader
- ; Linker script variables:
- ; Represents first free address after kernel memory
- extern endKernel
- ; Start/end of the constructors in memory
- extern startConstructors
- extern endConstructors
- ; Startup method in Kernel.cpp
- extern createKernel
- ; Defines the kernels stack size
- STACKSIZE equ 0x4000
- ; Calls all constructors and then starts the kernel
- loader:
- ; Store the given values for later usage in createKernel
- mov esp, stack + STACKSIZE
- push eax ; Magic number
- push ebx ; Additional information
- push esp ; Push stack
- push endKernel ; Push stack head
- ; Execute the constructor calling loop
- mov ebx, startConstructors
- jmp loopConstructors
- ; Calls the next constructor
- callConstructor:
- call [ebx]
- add ebx, 4
- ; Loops through the constructors
- loopConstructors:
- cmp ebx, endConstructors
- jb callConstructor
- ; Starts the kernel
- callKernel:
- call createKernel
- ; Hang the system after kernel execution
- hang:
- hlt
- jmp hang
- ; ### Empty data segment ###
- section .bss
- ; Align the location of the following res-commands
- align 4
- ; Reserves space for the initial kernel stack
- stack:
- resb STACKSIZE
Advertisement
Add Comment
Please, Sign In to add comment