Master the fundamental concepts of protected mode transition 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 worksProtected mode unlocks 32-bit operands, privilege levels, and optional paging. The CPU stays in real mode until CR0.PE is set, but the prefetch queue still holds real-mode decode until a far jump loads CS from the GDT. For example, after LGDT and setting PE, jmp 0x08:protected_entry flushes the pipeline with the new code selector.
nasmLoading…
After the far jump, execute only 32-bit instructions; mixing 16-bit operands requires operand-size prefixes. Load ESP before calling any pushed-argument function. If video output still uses VGA text at 0xB8000, identity mapping must cover that region. Take a snapshot of GDT and IDT pointers in a struct for later long-mode upgrades.
You will simulate the transition on paper: a GDT descriptor, CR0.PE, the far jump, and segment reloads, driven by a boot-step script from stdin. This exercise requires the exact order: disable interrupts, load GDT, set PE, far jump, reload segments, and it faults exactly where real silicon faults.
Simulate the real-mode to protected-mode transition in C, driven by a boot-step script on stdin.
Protocol (all commands one per line, numbers in hex unless noted):
After all steps (or the first fault), print the summary: MODE=REAL|PROTECTED CS=0x%04X DS=0x%04X A20=%u RESULT=OK|TRIPLE_FAULT|GP_FAULT