/
sbos.asm
61 lines (61 loc) · 1.01 KB
/
sbos.asm
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
bits 16
org 0x7c00
start:
; setup segments
xor ax, ax
mov ds, ax
mov es, ax
mov ss, ax
mov sp, kernel_stack
loop:
; execution falls through to here
; overwrite the timer handler because otherwise the previous handler will mess with it
mov ax, 0x20
mov word [ax], cs
add ax, 0x2
mov word [ax], timer_handler
; loop
jmp $
timer_handler:
pusha
push ds
push es
push fs
push gs
push ax
xor ax, ax
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
pop ax
panic:
mov si, panic_msg
call print_line
print:
; prints string in si
.print_repeat:
lodsb
cmp al, 0
je .print_end
mov ah, 0x0e
int 0x10
jmp .print_repeat
.print_end:
ret
print_newline:
mov ah, 0x0e
mov al, 0x0d ; carriage return
int 0x10
mov ah, 0x0e
mov al, 0x0a ; newline
int 0x10
ret
print_line:
call print
call print_newline
ret
kernel_stack: equ 0x7b00
panic_msg: db "Panic", 0
times 510-($-$$) db 0
dw 0xaa55