VOGONS


First post, by ThatGuy2244@live.com

User metadata
Rank Newbie
Rank
Newbie

I am trying to make a DOS program that is 32-bit, but when I try to enter 32-bit mode I get an error from DOSbox ("exit on error: JMP Invalid Descriptor Type 0"). I have tried different things to try to fix or isolate this problem and it seems to have nothing to do with the descriptors I set up, but only has a problem with my JMP instruction to a 32-bit descriptor. My code for entering the 32-bit environment is:

cli
lgdt [GDT]
mov eax, cr0
or eax, 1
mov cr0, eax
sti
jmp 0x08:PMode

GDT:
dw GDTEnd - GDTStart - 1
dd GDTStart

GDTStart:
dd 0x00000000 ;Descriptor 0 Null
dd 0x00000000
dw 0xffff ;Descriptor 1 Code
dw 0x0000
db 0x00
db 10011010b
db 11001111b
db 0x00
dw 0xffff ;Descriptor 2 Data
dw 0x0000
db 0x00
db 10010010b
db 11001111b
db 0x00
GDTEnd:

My descriptors are set up to be a flat memory model for data and code.

Reply 1 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

Can you attach the compiled executable as well?

Reply 2 of 6, by ThatGuy2244@live.com

User metadata
Rank Newbie
Rank
Newbie

Sure, it's attached also I attached part of my source code and after the switch to 32-bit mode I just made the program idle the computer so just shut down DOSbox to exit the program. Also this program is meant to run as a .com file and was assembled with nasm.

-- I reran the program and the error is actually: "Exit to error: JMP Invalid Descriptor Type 10" It used to be Type 0, but it seems to be Type 10 now.

Reply 3 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The GDT is wrong, the setup is limit(word) and base(dword) but your executable has
the offset of the label at that adress only. If you use the dosbox debugger to step through
your code you can use GDT right after the LGDT instruction to check the contents.

Reply 4 of 6, by ThatGuy2244@live.com

User metadata
Rank Newbie
Rank
Newbie

How do I use the DOSbox debugger--do I download it or is it built in, if so how do I enable it?

Reply 5 of 6, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

If you can compile dosbox from sources you can enable it through a configure
switch
or in config.h (you'll need the curses library for that). The dev forum may have
a pre-built executable.

Reply 6 of 6, by ThatGuy2244@live.com

User metadata
Rank Newbie
Rank
Newbie

Ok, I have DOSbox debugger v.7.2 and I'll take a look at how to set up a GDT again, thanks.