1+ org 7C00h
2+ bits 16
3+ cpu 386
4+
5+ jmp short Start
6+
7+ db "FlopBird" ; OEM String
8+ dw 0x200 ; bytes per sector
9+ db 1 ; sectors per cluster
10+ dw 1 ; ;of reserved sectors
11+ db 2 ; ;of FAT copies
12+ dw 224 ; size of root directory
13+ dw 2880 ; total # of sectors if over 32 MB
14+ db 0xF0 ; media Descriptor
15+ dw 9 ; size of each FAT
16+ dw 9 ; sectors per track
17+ dw 2 ; number of read-write heads
18+ dd 0 ; number of hidden sectors
19+ dd 0 ; ; sectors for over 32 MB
20+ db 0 ; holds drive that the boot sector came from
21+ db 0 ; reserved, empty
22+ db 0x29 ; extended boot sector signature
23+ db "seri" ; disk serial
24+ db "Floppy Bird" ; volume label
25+ db "FAT16 " ; file system type
26+
27+ %define STACK_BASE_ADDR 1000h
28+ %define PROGRAM_LOAD_ADDR 1000h
29+ %define SEGMENTS_TO_LOAD 4
30+
31+ startMsg db "Starting loader" , 0
32+ jumpingToProgramMsg db "Jumping to program.." , 0
33+ programLoadFailedMsg db "Program load failed" , 0
34+ currentDrive db 0
35+
36+ Start:
37+ jmp 0000 :Start2
38+ Start2:
39+ cli
40+ xor ax , ax
41+ mov ss , ax
42+ mov ds , ax
43+ mov es , ax
44+ mov fs , ax
45+ mov gs , ax
46+ sti
47+ cld
48+ mov [ currentDrive ], dl
49+ mov bp , STACK_BASE_ADDR
50+ mov sp , STACK_BASE_ADDR
51+
52+ mov bh , al ; page 0
53+ mov bl , 0Fh ; color 15 (white)
54+ mov dl , al ; DL - cursor x
55+ mov dh , al ; DH - cursor y
56+
57+ mov ax , startMsg
58+ call printString
59+
60+ push bx
61+ push dx
62+ mov ah , 2
63+ mov al , SEGMENTS_TO_LOAD
64+ xor ch , ch
65+ mov cl , 2
66+ xor dh , dh
67+ mov dl , [ currentDrive ]
68+ mov bx , PROGRAM_LOAD_ADDR
69+ int 0x13
70+ pop dx
71+ pop bx
72+ jc short LoadFailature
73+
74+ inc dh
75+ xor dl , dl
76+ mov ax , jumpingToProgramMsg
77+ call printString
78+ inc dh
79+
80+ mov dl , [ currentDrive ]
81+ ; dh - cursor y
82+ jmp PROGRAM_LOAD_ADDR
83+
84+ LoadFailature:
85+ inc dh
86+ xor dl , dl
87+ mov ax , programLoadFailedMsg
88+ call printString
89+
90+ IdleLoop:
91+ hlt
92+ jmp IdleLoop
93+
94+ %include "commonSubroutines.nasm"
95+
96+ times 0200h - 2 - ($ - $$) db 0 ; zerofill up to 510 bytes
97+ dw 0AA55h ; Boot Sector signature
0 commit comments