boot/boot.s (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
.section .text
# disable interrupts
cli
# canonicalize %CS:%EIP to a known value
ljmp $0, $start
start:
# setup segments
mov $0x0000, %ax
mov %ax, %ss
mov %ax, %ds
mov %ax, %es
mov %ax, %fs
# setup stack
mov $0x9000, %ax
mov %ax, %bp
mov %ax, %sp
# select display page 0
mov $0, %al
mov $0x05, %ah
int $0x10
# print hello world
mov $message, %si
mov $0x0000, %bx
mov $0x0E, %ah
print_loop:
lodsb
or %al, %al
jz print_end
int $0x10
jmp print_loop
print_end:
# TODO:
# - load kernel into memory starting at adress 0x10000
# (NOTE: this code can only be jumped to after loading the global descriptor table
# because it uses absolute adresses larger than 16 bit)
# - load global descriptor table and far jump into protected mode
# - activate A20 gate
# - jump to low kernel code
# loop forever
loop:
jmp loop
# some data
message:
.ascii " Hello World!"
.byte 0x00
end:
.=510
.byte 0x55
.byte 0xAA