Master the fundamental concepts of protected mode transition 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 worksPaging translates linear addresses through page directories and tables. Set CR0.PG only after CR3 points to a valid page directory and identity-mapped regions cover the current instruction pointer. For example, map the first 4 MB identically so code at 0x100000 keeps executing after paging turns on.
nasmLoading…
If CR0.PG triggers fault 14 immediately, your identity map probably does not cover the instruction pointer or stack. Map at least the first 4 MB before enabling paging, then expand maps for kernel heap later. Zero the page directory first so empty entries are not present. Use 4 KB pages in two levels for the classic 32-bit setup exercise.
You will build the translation machinery itself: split a linear address into PDE index, PTE index, and offset; install 4 KB mappings; and walk them to physical addresses, including the identity map that keeps the kernel alive when CR0.PG turns on. This exercise requires CR3 setup before PG bit and verified mappings for stack and code regions.
Implement 32-bit two-level paging (4 KiB pages) translation in C, driven by a command script on stdin.
Protocol (all numbers in hex):
Process every command on stdin until EOF, printing one line per command.