A simple and VERY compact bootsector, which lets you load your bootloader or kernel from a file.
Build using attached script.
Notice: Don't read this, read the source code. It is commented, so all the info is there
Here it is, step by step:
- Check if BIOS supports extended Disk operation
- Looks for first active FAT32 partition
- Looks for your file on that partition(in root directory)
- Loads it into memory
- Executes it
Your code is loaded at 0x1000:0x0000(segment:offset), or 0x10000(linear).
Most of registers are not "zeroed" and garbage is assigned to them
Only those have valid values:
- CS:IP - 0x1000:0x0000 (assigned to loaded file)
- DS - 0x1000 (also assigned to loaded file)
- SS:SP - 0x0000:0xFFFF (stack in first segment)
- DL - drive number(for bios interrupts)
(all offsets are specified in source code)
- 0x7C00 - current disk(device number), FAT address, first data sector address and similar info.
- 0x7E00 - BPB sector of that partition
- It's all in real mode so maximum size of file shouldn't be bigger than a few hundred Kilobytes
- File must be in root directory of selected partition
- Filename - Bootsector searches for file with 8.3 filename
To install use:
- On ubuntu compatible systems use Install.sh script
- On Windows use Fat32-bootsector.exe
Notice Windows version does not use letters for partitions, but phisycal partitions(not logical), so: It may be more difficult to match partition-letter, but on the other hand it supports multi partition usb drives
When error occurs bootsector draws error code on the screen.
0 - extended BIOS functions not availble
1 - Bootable partition not found
2 - Bootable partition is not FAT32
3 - File not found
4 - Can't load sectors (BIOS interrupt error)