Page 1 of 1

Why 0x10?

Posted: Sat Apr 13, 2002 11:00 pm
by The Legend
This codepiece is taken from GazOS:

"lgdtl (loadgdt) \n" /* Load our own GDT */
"movw $0x10,%%ax \n" /* Init data registers with flat_data */
"movw %%ax,%%ds \n"
"movw %%ax,%%es \n"
"movw %%ax,%%fs \n"
"movw %%ax,%%gs \n"
"movw %%ax,%%ss \n" /* ... and the stack, too */

I don't understand what 0x10 means here, the GDT
has only three entries ...

Thanks in advance,
The Legend

RE:Why 0x10?

Posted: Sat Apr 13, 2002 11:00 pm
by Gertfaller
>On 2002-04-14 07:45:08, The Legend wrote:
>This codepiece is taken from GazOS:
>
>"lgdtl (loadgdt) \n" /* Load our own GDT */
>"movw $0x10,%%ax \n" /* Init data registers with flat_data */
>"movw %%ax,%%ds \n"
>"movw %%ax,%%es \n"
>"movw %%ax,%%fs \n"
>"movw %%ax,%%gs \n"
>"movw %%ax,%%ss \n" /* ... and the stack, too */
>
>I don't understand what 0x10 means here, the GDT
>has only three entries ...
>
>Thanks in advance,
>The Legend

Each entry is 8 bytes long so :
offset 0x00 in GTD : null descriptor
offset 0x08 in GTD : code segment
offset 0x10( = 16 decimal) in GTD : data segment

RE:Why 0x10?

Posted: Sat Apr 13, 2002 11:00 pm
by The Legend
>On 2002-04-14 08:04:18, Gertfaller wrote:
>>On 2002-04-14 07:45:08, The Legend wrote:
>>This codepiece is taken from GazOS:
>>
>>"lgdtl (loadgdt) \n" /* Load our own GDT */
>>"movw $0x10,%%ax \n" /* Init data registers with flat_data */
>>"movw %%ax,%%ds \n"
>>"movw %%ax,%%es \n"
>>"movw %%ax,%%fs \n"
>>"movw %%ax,%%gs \n"
>>"movw %%ax,%%ss \n" /* ... and the stack, too */
>>
>>I don't understand what 0x10 means here, the GDT
>>has only three entries ...
>>
>>Thanks in advance,
>>The Legend
>
>Each entry is 8 bytes long so :
>offset 0x00 in GTD : null descriptor
>offset 0x08 in GTD : code segment
>offset 0x10( = 16 decimal) in GTD : data segment

Oh, thanks

RE:Why 0x10? (another small question)

Posted: Sat Apr 13, 2002 11:00 pm
by The Legend
>On 2002-04-14 08:04:18, Gertfaller wrote:
>>On 2002-04-14 07:45:08, The Legend wrote:
>>This codepiece is taken from GazOS:
>>
>>"lgdtl (loadgdt) \n" /* Load our own GDT */
>>"movw $0x10,%%ax \n" /* Init data registers with flat_data */
>>"movw %%ax,%%ds \n"
>>"movw %%ax,%%es \n"
>>"movw %%ax,%%fs \n"
>>"movw %%ax,%%gs \n"
>>"movw %%ax,%%ss \n" /* ... and the stack, too */
>>
>>I don't understand what 0x10 means here, the GDT
>>has only three entries ...
>>
>>Thanks in advance,
>>The Legend
>
>Each entry is 8 bytes long so :
>offset 0x00 in GTD : null descriptor
>offset 0x08 in GTD : code segment
>offset 0x10( = 16 decimal) in GTD : data segment
And why doesn't this code piece load a value for cs (0x8 then)?

The Legend

RE:Why 0x10? (another small question)

Posted: Sat Apr 13, 2002 11:00 pm
by GertFaller
>On 2002-04-14 10:41:13, The Legend wrote:
>>On 2002-04-14 08:04:18, Gertfaller wrote:
>>>On 2002-04-14 07:45:08, The Legend wrote:
>>>This codepiece is taken from GazOS:
>>>
>>>"lgdtl (loadgdt) \n" /* Load our own GDT */
>>>"movw $0x10,%%ax \n" /* Init data registers with flat_data */
>>>"movw %%ax,%%ds \n"
>>>"movw %%ax,%%es \n"
>>>"movw %%ax,%%fs \n"
>>>"movw %%ax,%%gs \n"
>>>"movw %%ax,%%ss \n" /* ... and the stack, too */
>>>
>>>I don't understand what 0x10 means here, the GDT
>>>has only three entries ...
>>>
>>>Thanks in advance,
>>>The Legend
>>
>>Each entry is 8 bytes long so :
>>offset 0x00 in GTD : null descriptor
>>offset 0x08 in GTD : code segment
>>offset 0x10( = 16 decimal) in GTD : data segment
>And why doesn't this code piece load a value for cs (0x8 then)?
>
>The Legend
cs can't de loaded directly.
It is loaded when you jump to the code
to be executed.
Here it's with :

"ljmp $0x08,$next\n"
"nop\n"
"nop\n"
"next: \n" /* Continue here

then cs points to the code segment.

RE:Why 0x10? (another small question)

Posted: Sun Apr 14, 2002 11:00 pm
by The Legend
>On 2002-04-14 17:33:05, GertFaller wrote:
>>On 2002-04-14 10:41:13, The Legend wrote:
>>>On 2002-04-14 08:04:18, Gertfaller wrote:
>>>>On 2002-04-14 07:45:08, The Legend wrote:
>>>>This codepiece is taken from GazOS:
>>>>
>>>>"lgdtl (loadgdt) \n" /* Load our own GDT */
>>>>"movw $0x10,%%ax \n" /* Init data registers with flat_data */
>>>>"movw %%ax,%%ds \n"
>>>>"movw %%ax,%%es \n"
>>>>"movw %%ax,%%fs \n"
>>>>"movw %%ax,%%gs \n"
>>>>"movw %%ax,%%ss \n" /* ... and the stack, too */
>>>>
>>>>I don't understand what 0x10 means here, the GDT
>>>>has only three entries ...
>>>>
>>>>Thanks in advance,
>>>>The Legend
>>>
>>>Each entry is 8 bytes long so :
>>>offset 0x00 in GTD : null descriptor
>>>offset 0x08 in GTD : code segment
>>>offset 0x10( = 16 decimal) in GTD : data segment
>>And why doesn't this code piece load a value for cs (0x8 then)?
>>
>>The Legend
>cs can't de loaded directly.
>It is loaded when you jump to the code
>to be executed.
>Here it's with :
>
> "ljmp $0x08,$next\n"
> "nop\n"
> "nop\n"
> "next: \n" /* Continue here
>
>then cs points to the code segment.
>
Okay, thank you!

The Legend