41 lines
1.4 KiB
ArmAsm
41 lines
1.4 KiB
ArmAsm
|
; Definition of the MBR (Master Boot Record). This is basically our bootloader and
|
||
|
; is located in the first 512 bytes of the drive we're booting from. From here, we
|
||
|
; do some basic setup and then call into the kernel
|
||
|
|
||
|
[org 0x7c00] ; Address where the code expects to be loaded in. The BIOS always loads us here
|
||
|
[bits 16] ; All x86 CPUs start in 16 bit (aka "real") mode, so we tell nasm to emit 16-bit code
|
||
|
|
||
|
; We print a simple startup message using the ISRs
|
||
|
; from the BIOS
|
||
|
mov si, startup_msg
|
||
|
call print
|
||
|
|
||
|
|
||
|
; Now we setup the stack by setting the
|
||
|
; base pointer to address 0x8000. The
|
||
|
; address itself doesn't matter as long
|
||
|
; as it's far enough away from memory already
|
||
|
; in use by the BIOS
|
||
|
mov bp, 0x8000
|
||
|
mov sp, bp ; The stack starts out empty, so sp == bp
|
||
|
|
||
|
|
||
|
jmp $ ; Keeps jumping at the current address (loops forever)
|
||
|
|
||
|
; These two lines never execute (for now), but they might once
|
||
|
; we jump into the kernel, so we disable interrupts and halt the
|
||
|
; CPU, just in case
|
||
|
cli
|
||
|
hlt
|
||
|
|
||
|
; Now we include our "function definitions" (after the halting, so
|
||
|
; they're never executed unless explicitly called)
|
||
|
%include "src/bootloader/util/tty.s"
|
||
|
|
||
|
; Here we define our variables: They need to be defined after the
|
||
|
; halting because otherwise they will be executed as code!
|
||
|
startup_msg: db "TSOS - Bootloader: Starting up", 0xA, 0xD, 0x0
|
||
|
|
||
|
; padding and magic number
|
||
|
times 510 - ($-$$) db 0
|
||
|
dw 0xaa55
|