Help with magic number for segment offset after loading gdt

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Locked
StevensOsDevAccount
Posts: 5
Joined: Fri May 27, 2011 8:07 pm

Help with magic number for segment offset after loading gdt

Post 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.
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: Help with magic number for segment offset after loading

Post 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
Last edited by Combuster on Sat May 28, 2011 1:36 pm, edited 1 time in total.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Help with magic number for segment offset after loading

Post by Chandra »

This clearly is the insult of our Wiki.
Pathetic.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Locked