Page 1 of 1

Help with magic number for segment offset after loading gdt

Posted: Sat May 28, 2011 10:16 am
by StevensOsDevAccount
I've managed to decode the magic numbers for several of the kernel boot things.
For example.
Making a global descriptor now looks like this,

Code: Select all

gdt[2]=makeGlobalDescriptor(
  0,
  0xFFFFFFFF,
  memoryPresent
  |ringZero
  |dataSegment
  |writableData
  ,mode32Bits|fourKiloByteBlocks
  );
Instead of something like this

Code: Select all

gdt[2]=makeGlobalDescriptor(
  0,
  0xFFFFFFFF,
  memoryPresent
  0x92 // Noobs don't bother learning anything, just say the magic words
  ,0x9F
  );
In Bran's kernel development tutorial after the global descriptor table is loaded he changes the data in the segment registers.
He loads 0x08 into the code segment register and 0x10 into the data segment register.
Please explain these magic numbers.

Re: Help with magic number for segment offset after loading

Posted: Sat May 28, 2011 10:35 am
by Combuster
Worse, you didn't read the tutorial. it's in there.

Edit: hint:
mov ax, 0x10 ; 0x10 is the offset in the GDT to our data segment

Re: Help with magic number for segment offset after loading

Posted: Sat May 28, 2011 10:51 am
by Chandra
This clearly is the insult of our Wiki.
Pathetic.