Skip to content

Commit 71730cd

Browse files
author
0xZangetsueth
committed
more instructions for bootloader for a FAT12 file system
1 parent fe0e454 commit 71730cd

File tree

6 files changed

+58
-11
lines changed

6 files changed

+58
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Understanding low level programming in C and Assembly through system programming : building an OS from scratch
1+
Understanding low level programming in C and Assembly through system programming : building an OS from scratch (thanks to youtube series from @nanobyte)

build/bootloader.bin

512 Bytes
Binary file not shown.

build/kernel.bin

512 Bytes
Binary file not shown.

build/main_floppy.img

0 Bytes
Binary file not shown.

docs/bootloader.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
bdb_oem: db 'MSWIN4.1': This defines a label bdb_oem followed by a data declaration (db). It assigns the ASCII string "MSWIN4.1" to this label. This is typically used to identify the OEM or operating system associated with the bootloader.
2+
3+
bdb_bytes_per_sector: dw 512: This declares a label bdb_bytes_per_sector followed by a data declaration (dw). It assigns the value 512 to this label, representing the number of bytes per sector in the file system.
4+
5+
bdb_sectors_per_cluster: db 1: This declares a label bdb_sectors_per_cluster followed by a data declaration (db). It assigns the value 1 to this label, representing the number of sectors per cluster in the file system.
6+
7+
bdb_reserved_sectors: dw 1: This declares a label bdb_reserved_sectors followed by a data declaration (dw). It assigns the value 1 to this label, indicating the number of reserved sectors in the file system.
8+
9+
bdb_fat_count: db 2: This declares a label bdb_fat_count followed by a data declaration (db). It assigns the value 2 to this label, specifying the number of File Allocation Tables (FATs) in the file system.
10+
11+
bdb_dir_entries_count: dw 0E0h: This declares a label bdb_dir_entries_count followed by a data declaration (dw). It assigns the value 0E0h (hexadecimal) to this label, representing the number of directory entries or file entries in the root directory.
12+
13+
bdb_total_sectors: dw 2880: This declares a label bdb_total_sectors followed by a data declaration (dw). It assigns the value 2880 to this label, indicating the total number of sectors in the file system.
14+
15+
bdb_media_descriptor_type: db 0F0h: This declares a label bdb_media_descriptor_type followed by a data declaration (db). It assigns the value 0F0h (hexadecimal) to this label, representing the media descriptor type for the floppy disk.
16+
17+
bdb_sectors_per_fat: dw 9: This declares a label bdb_sectors_per_fat followed by a data declaration (dw). It assigns the value 9 to this label, indicating the number of sectors per FAT in the file system.
18+
19+
bdb_sectors_per_track: dw 18: This declares a label bdb_sectors_per_track followed by a data declaration (dw). It assigns the value 18 to this label, representing the number of sectors per track on the storage device.
20+
21+
bdb_heads: dw 2: This declares a label bdb_heads followed by a data declaration (dw). It assigns the value 2 to this label, indicating the number of heads or surfaces on the storage device.
22+
23+
bdb_hidden_sectors: dd 0: This declares a label bdb_hidden_sectors followed by a data declaration (dd). It assigns the value 0 to this label, representing the number of hidden sectors before the partition.
24+
25+
bdb_large_sector_count: dd 0: This declares a label bdb_large_sector_count followed by a data declaration (dd). It assigns the value 0 to this label, indicating the large sector count for the file system.
26+
27+
ebr_drive_number: db 0: This declares a label ebr_drive_number followed by a data declaration (db). It assigns the value 0 to this label, representing the drive number (0 for floppy, 0x80 for HDD).
28+
29+
ebr_signature: db 12h, 34h, 56h, 78h: This declares a label ebr_signature followed by a data declaration (db). It assigns the byte sequence 12h, 34h, 56h, 78h to this label, which can be used as a signature or identification.
30+
31+
ebr_volume_id: db 'ARIA OS': This declares a label ebr_volume_id followed by a data declaration (db). It assigns the ASCII string "ARIA OS" to this label, representing the volume ID or name.
32+
33+
ebr_system_id: db 'FAT12': This declares a label ebr_system_id followed by a data declaration (db). It assigns the ASCII string "FAT12" to this label, indicating the file system type.
34+
35+
start: jmp main: This is the start label followed by an unconditional jump instruction that transfers control to the main label. It serves as the entry point for the execution of the bootloader.

src/bootloader/boot.asm

+22-10
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,32 @@ bits 16
44
%define ENDL 0x0D, 0x0A
55

66

7-
# FAT12 header
7+
;FAT12 header
88

99
jmp short start
1010
nop
1111

12-
bdb_oem: db 'MSWIN4.1' ; 8bytes
13-
bdb_bytes_per_sector: dw 512
14-
bdb_sectors_per_cluster: db 1
15-
bdb_reserved_sectors: dw 1
16-
17-
18-
19-
20-
12+
;all of these are explicated in docs/bootloader.md
13+
bdb_oem: db 'MSWIN4.1' ; 8bytes
14+
bdb_bytes_per_sector: dw 512
15+
bdb_sectors_per_cluster: db 1
16+
bdb_reserved_sectors: dw 1
17+
bdb_fat_count: db 2
18+
bdb_dir_entries_count: dw 0E0h
19+
bdb_total_sectors: dw 2880 ; 2880 * 512 = 1.44MB
20+
bdb_media_descriptor_type: db 0F0h ; F0 = 3.5* floppy disk
21+
bdb_sectors_per_fat: dw 9 ; 9 sectors/fat
22+
bdb_sectors_per_track: dw 18
23+
bdb_heads: dw 2
24+
bdb_hidden_sectors: dd 0
25+
bdb_large_sector_count: dd 0
26+
27+
;extended boot record
28+
ebr_drive_number: db 0 ; 0x00 floppy, 0x80 hdd
29+
db 0 ; reserved
30+
ebr_signature: db 12h, 34h, 56h, 78h ; serial number
31+
ebr_volume_id: db 'ARIA OS' ; 11 bytes
32+
ebr_system_id: db 'FAT12' ; 8 bytes
2133

2234

2335
start:

0 commit comments

Comments
 (0)