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.
okay, I'll answer my own question, I accidentally
set my my stack segment to code which prevents
the cpu from writing data to it. That's why it reboots
You could just modify the contents of the GDT...BUT
you can not modify an entry which is beyond the limit specified in your GDTR, for example, you've set up your limit to be at 63, which is around 8 GDT entries, you cannot add an entry to make int a total of 9. I have not tried modifying an entry in which its corresponding selector is being used (CS for example) though.
If you add entries to the GDT, and therefore change the limits, you will need to reload it using LGDT. If you change entries, you don't need to reload the GDT, but you will have to reload any segment registers that refer to the changed descriptors. This is because you need to refresh the descriptor caches that the CPU keeps.
I'm having problems setting up the initial GDT because when I get to that part on the boot, my computer restarts. I can't figure out what is causing this. Can you?
The GDT is just a normal variable in memory. Think of it as an array of 8-byte structures. To modify it in C, I'd recommend that you set up a structure definition as per the Intel documentation. To modify it from assembler, obtain the address of a descriptor by multiplying the index of your descriptor by 8. Then modify the various fields relative to that. The layout is all documented in the Intel manual; other than that, it's just basic assembly.
If you're having problems switching to protected mode, I'd advise you to start debugging under Bochs. It won't stop your code triple-faulting, but it will tell you why and where your code failed.
Can you point me to this "Bochs" tool? It might come in handy and I'll try the debug thing. Although, I may need some guidance on how to debug with this "Bochs". Thanks!