Master the fundamental concepts of protected mode transition through this focused micro-challenge.
The 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 author a three-entry GDT and load it with LGDT before mode switch. This exercise requires correct limit/base encoding and selectors 0x08/0x10 for code and data segments.
Implement a flat GDT setup in C.
Requirements:
Test:
Three hints are available for this task, revealed one at a time inside the code workspace so you can struggle productively before seeing them.
All starter code and reference implementations are available for your local setup.
View on Github