Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It's actually an 8-byte entry in the global descriptor table. It creates a descriptor addressing the entire 4G address space as a selector.</p> <p>The <code>equ $-gdt</code> sets up a value in the assembler equal to the difference between this location (<code>$</code>) and the <code>gdt</code> label. In other words, it's the offset of this entry within the GDT itself.</p> <p>The structure of a GDT entry is as follows:</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://i.stack.imgur.com/wirfC.png" alt="alt text"></p> <p>where the individual parts are explained below.</p> <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src="https://i.stack.imgur.com/uExcu.png" alt="alt text"></p> <p>For your specific values:</p> <pre><code>(a) dw FFFFh (b) dw 0 (c) db 0 (d) db 92h ; present, ring 0, data, expand-up, writable (e) db CFh ; page-granular (4 gig limit), 32-bit (f) db 0 </code></pre> <ol> <li><p>The base address is calculated from the <code>f</code>, <code>c</code> and <code>b</code> fields, from most significant to least - because these are all zero, the base is at zero.</p></li> <li><p>The selector limit is calculated from the rightmost 4 bits of <code>e</code> and all of <code>a</code>, to give <code>0xfffff</code> in this case. This has 1 added to it to give <code>0x100000</code>. See point 3 below for what this means.</p></li> <li><p>The top 4 bits of <code>e</code> (the flags) set the granularity (4K rather than 1 byte) and the operand size (32-bit). With a granularity of 4K (12 bits) and page count of <code>0x100000</code> (20 bits), that gives you your full 32-bit (4G) address space.</p></li> <li><p>The <code>d</code> field is the access byte and sets the following properties based on <code>0x92</code>:</p> <ul> <li><code>Pr</code> present (in-memory) bit to true.</li> <li><code>Privl</code> privelege level to 0 (need to be ring 0 to get access).</li> <li><code>Ex</code> executable bit 0 (data selector).</li> <li><code>DC</code>, direction bit is 0, segment grows up.</li> <li><code>RW</code> of 1, memory is writable.</li> <li><code>Ac</code> accessed bit set to 0.</li> </ul></li> </ol>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload