Master the fundamental concepts of bios & uefi programming through this focused micro-challenge.
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
Every task includes starter code, theory, and hidden tests so you can implement and verify locally in the browser.
How it worksINT 0x13 reads and writes sectors through firmware abstractions. Boot sectors use it to pull the next stage from disk when 512 bytes is not enough. For example, extended read function AH=0x42 uses a Disk Address Packet (DAP) in memory to load 64 sectors starting at LBA 1 into 0x7E00.
nasmLoading…
AH holds statusDAP layout: size byte, sector count, buffer offset/segment, starting LBA quadword.
The Disk Address Packet should live in memory below 1 MB and preferably not cross a 64 KB segment boundary for oldest BIOS builds. Sector counts above what the controller supports return error 0x01. For floppy images in QEMU, DL is often 0x00; for hard disk images use -hda and expect 0x80. Logging the returned sector count field in the DAP confirms partial reads.
You will implement the exact CHS-to-LBA arithmetic the AH=0x42 DAP performs, converting in both directions between a cylinder/head/sector triple and a linear block number. This exercise requires getting the geometry math right, including the 1023/15/63 CHS that capped BIOS addressing at the classic 8 GB limit.
The BIOS disk services (INT 13h) address sectors either by geometry, CHS, or by a flat number, LBA. Convert between the two:
cLoading…
HPC is heads per cylinder and SPT is sectors per track. Sector numbers are 1-based in CHS and LBA is 0-based, which is where the - 1 comes from. Going back:
cLoading…
One command:
lba C H S HPC SPT: convert CHS to LBA.chs LBA HPC SPT: convert LBA to CHS.All values are non-negative integers.
lba: LBA n, for example LBA 1032191 for lba 1023 15 63 16 63 (the classic 8 GB BIOS limit).chs: C c H h S s, for example C 0 H 0 S 1 for chs 0 16 63 (LBA 0 is the boot sector).