|
|
@ -0,0 +1,39 @@
|
|
|
1
|
BITS 16
|
|
|
2
|
|
|
|
3
|
start:
|
|
|
4
|
;; set up 4k stack space after this boot loader (this has something to do with the evil "segment registers")
|
|
|
5
|
mov ax, 0x07c0
|
|
|
6
|
add ax, 288 ; (4096 + 512) / 16 bytes per paragraph (4096 = 4K, 512b for the boot loader, paragraph?)
|
|
|
7
|
mov ss, ax ; ss = stack space?
|
|
|
8
|
mov sp, 4096 ; sp = stack pointer?
|
|
|
9
|
|
|
|
10
|
;; set data segment to where we're loaded
|
|
|
11
|
mov ax, 0x07c0
|
|
|
12
|
mov ds, ax
|
|
|
13
|
|
|
|
14
|
;; put string position into si
|
|
|
15
|
mov si, text_string
|
|
|
16
|
call print_string
|
|
|
17
|
|
|
|
18
|
;; jump here, infinite loop!
|
|
|
19
|
jmp $
|
|
|
20
|
|
|
|
21
|
text_string db 'This is my very first OS!', 0
|
|
|
22
|
|
|
|
23
|
print_string: ; output string in `si` to screen
|
|
|
24
|
mov ah, 0x0e ; int 0x10 'print char' function
|
|
|
25
|
|
|
|
26
|
.repeat:
|
|
|
27
|
;; get character from string
|
|
|
28
|
lodsb ; lodsb = load string byte (loads a byte from `si` and stores it in `al`, which is the lower byte of `ax`)
|
|
|
29
|
cmp al, 0
|
|
|
30
|
je .done ; if char is zero, we have reached the end of the string
|
|
|
31
|
int 10h ; otherwise, print it (e.g. ask the bios to do this)
|
|
|
32
|
jmp .repeat
|
|
|
33
|
|
|
|
34
|
.done:
|
|
|
35
|
ret
|
|
|
36
|
|
|
|
37
|
;; make this recognizable as a flobby disk boot sector (510b + 0xaa55 at the end = 510b)
|
|
|
38
|
times 510-($-$$) db 0 ; pad remainder of boot sector with 0s
|
|
|
39
|
dw 0xaa55 ; standard pc boot signature (dw = define word, 2 bytes)
|