jankos/loader.asm
Medium Fries 88fad3c56e merging from remote
Mainly adding support in write_cell() to use logical character indexes vs direct memory offsets
2019-01-23 17:45:00 -08:00

47 lines
1.2 KiB
NASM

; since we have no stack we have to create one for the OS
global loader
MAGIC_NUMBER equ 0x1BADB002
FLAGS equ 0x0
CHECKSUM equ -MAGIC_NUMBER
; size in bytes of stack
KERNEL_STACK_SIZE equ 4096
; external labels(cdecl) calling convention
extern yote
section .bss
align 4 ; aligning to bytes for x86(32-bit) reasons
; because this is the first thing we actually do (virual)address 0x00000000 will
; contain 4KB of memory for our stack
kernel_stack:
resb KERNEL_STACK_SIZE ; reserver bytes instruction
; point to what will be bottom of stack
; which will grow down towards (virtual)address 0x00000000
mov esp, kernel_stack + KERNEL_STACK_SIZE
section .text
; align all instructions to 4 byte boundary by the x86 instruction set law
align 4
; dropping our magic and other things into memory
dd MAGIC_NUMBER
dd FLAGS
dd CHECKSUM
loader:
call yote
.loop:
jmp .loop
; section for our kernel stack
KERNEL_STACK_SIZE equ 4096
section .bss
align 4 ; aligned to 4 bytes for performance
kernel_stack:
; (res)erve (b)ytes x
resb KERNEL_STACK_SIZE ; 4k of stack size in mem
; now we setup the stack pointer for our kernel
mov esp, kernel_stack + KERNEL_STACK_SIZE