Master the fundamental concepts of boot sector development through this focused micro-challenge.
You have read the whole brief, and the concepts above stay free on every task. Writing and running the code needs a plan.
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 worksStage one fits in 512 bytes: enable A20, load sectors, maybe print status. Stage two holds filesystem logic, ELF parsing, or mode switches. For example, stage one reads sectors 2-17 to 0x7E00 and executes jmp 0x0000:0x7E00 after verifying a magic constant at the buffer start.
cLoading…
Stage two can be assembled with ORG 0x7E00 so labels match the runtime address. If you use a higher load address, fix up relocations or use position-independent code for data references. Store a magic value at the front of stage two so stage one can detect a failed read before jumping into garbage. Serial debug output in stage one costs bytes but saves hours when LBA math is wrong.
You will load and jump to a second-stage image stored contiguously on disk. This exercise requires coordinating load address, entry jump, and register conventions between stages.
Simulate the stage-1 -> stage-2 handoff math in C.
Input (stdin, one line): cylinder head sector count SEG:OFF: the exact register values stage 1 puts in CH/CL/DH/AL before INT 0x13, plus the segment:offset pair used for the far jump (segment parsed as hex). Sector, head and cylinder are 1-based in the BIOS CHS convention.
Requirements:
Output exactly these lines: first_lba=<decimal> last_lba=<decimal> load_linear=0x<hex uppercase> load_end_byte=0x<hex uppercase> bytes_to_load=<decimal> boot_sector_overlap=yes|no