]> wirehaze git hosting - lifeboot.git/blob - lifeboot.asm

wirehaze git hosting

7a70c62d1573d2260374be1c4c66319ceee07f22
[lifeboot.git] / lifeboot.asm
1 bits 16
2 org 0x7c00
3
4 %define ORG 0x7c00 ; where we are loaded initially
5
6 %define VGA_SEG 0xb800 ; video memory starts at 0xb8000
7 %define VGA_COL 80
8 %define VGA_ROW 25
9 %define VGA_LENW VGA_COL * VGA_ROW
10
11 %define FILL_CHAR ' '
12 %define PRINT_COLOR 0x07 ; grey on black
13
14 ; entry point -----------------------------------------------------------------
15
16 ; initialize segment registers
17 xor ax, ax
18 mov ds, ax
19 mov es, ax
20 mov ss, ax
21
22 ; set stack pointers
23 mov sp, ORG
24 mov bp, ORG
25
26 ; clear screen ----------------------------------------------------------------
27
28 ; disable cursor
29 mov ch, 0x3f
30 mov ah, 0x01
31 int 0x10
32
33 ; clear video memory
34 mov cx, VGA_LENW
35 mov ax, VGA_SEG
36 mov es, ax
37 xor di, di
38 mov ax, (PRINT_COLOR << 8) | FILL_CHAR
39
40 rep stosw ; fill cx words at es:di with ax
41
42 ; errors ----------------------------------------------------------------------
43
44 hello:
45 mov si, str.hello
46
47 ; print the error message string in si and halt
48 ; note: we assume es = VGA_SEG and ds = 0
49 printerr:
50 xor di, di
51 mov ah, PRINT_COLOR
52
53 ; es:di = video memory
54 ; ds:si = error message
55 ; al = current char
56 ; ah = color attribute
57
58 write_char:
59 lodsb ; al = [ds:si], si += 1
60 or al, al ; on null terminator,
61 jz halt ; halt
62 stosw ; [es:di] = ax, di += 2
63 jmp write_char
64
65 halt:
66 cli ; disable interrupts
67 hlt
68 jmp halt
69
70 ; data ------------------------------------------------------------------------
71
72 str:
73 .hello:
74 db "lifeboot", 0
75
76 times 510 - ($ - $$) db 0 ; fill remaining bytes with zeroes
77 dw 0xaa55 ; mbr magic byte