Skip to content

Commit c3f8250

Browse files
committed
feat: Start from MBR
1 parent 81d8cad commit c3f8250

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed

boot/mbr.S

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
BITS 16
2+
3+
start:
4+
mov ax, 07C0h ; Set up 4K stack space after this bootloader
5+
add ax, 32 ; 512 / 16 bytes per paragraph
6+
mov ss, ax
7+
mov sp, 4096
8+
9+
mov ax, 07C0h ; Set data segment to where we're loaded
10+
mov ds, ax
11+
12+
13+
mov si, text_string ; Put string position into SI
14+
call print_string ; Call our string-printing routine
15+
16+
jmp $ ; Jump here - infinite loop!
17+
18+
19+
text_string db 'Hello cocotiOS!', 0
20+
21+
22+
print_string: ; Routine: output string in SI to screen
23+
mov ah, 3
24+
mov bh, 0
25+
int 0x10
26+
27+
.repeat:
28+
29+
lodsb ; Get character from string
30+
31+
32+
mov ah, 09h ;
33+
mov bl, 02h ; green text
34+
mov bh, 0
35+
mov cx, 1h
36+
37+
cmp al, 0
38+
je .done ; If char is zero, end of string
39+
int 10h ; Otherwise, print it
40+
41+
add dl, 1
42+
mov ah, 02h
43+
int 10h
44+
45+
jmp .repeat
46+
47+
.done:
48+
ret
49+
50+
51+
times 510-($-$$) db 0 ; Pad remainder of boot sector with 0s
52+
dw 0xAA55 ; The standard PC boot signature

boot/mbr.bin

512 Bytes
Binary file not shown.

img/cocotiOS.img

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)