horizon wrote:
I suspect this might be due to an error in setting up my GDT, but I'm not sure where I went wrong.
Have you tried using a debugger? The problem you have now is most likely something simple, so it would be great practice. Popular choices include Bochs with its built-in debugger, and qemu with gdb. For this particular issue, I'd start by examining the contents of the GDT right after lgdt.
You might also be able to get some hints from the logs of your emulator or VM. In particular, look for the location and type of fault to narrow down the possibilities.
Unfortunately, I haven't spotted the bug with a quick look at your code.