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 worksThe GDT holds segment descriptors describing base, limit, and access rights. A flat model maps code and data to the full 4 GB space with base 0 and limit 4 GB using granularity bit. For example, entry 1 (selector 0x08) is ring-0 code and entry 2 (selector 0x10) is ring-0 data.
nasmLoading…
Setting the D/B bit in the granularity byte marks a code segment as 32-bit default operand size. Data segments need the writable bit set or stores fault. Limit 0xFFFFF with granularity 4K yields a 4 GB span with base 0, which is the textbook flat model. Reload SS with the data selector after entering protected mode before any push instructions execute.
You will encode and decode the 8-byte descriptors themselves: the same packing the assembler's dq directives perform, and derive selectors from index, TI, and RPL. This exercise requires correct limit/base encoding and selectors 0x08/0x10 for code and data segments.
Implement GDT descriptor encoding/decoding in C, driven by a command script on stdin.
Protocol (numbers in hex):
Process every command on stdin until EOF, printing one line per command.