protected mode problem

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.
Post Reply
tyler

protected mode problem

Post by tyler »

For some reason, as soon as I set the first bit of cr0 to enter protected mode, my computer restarts.  Gereral protection error?  Any help would be greatly appreciated.

Thanks,

Tyler
tyler

RE:protected mode problem

Post by tyler »

lgdt [gSize] ; load GDTR with base and limit address

mov eax, cr0
or eax, 1 ; set first bit to 1 (pmode)
mov cr0, eax ; move value into cr0

ret ; return for now

gdt: ; create gdt (this label marks start of gdt)

null_descriptor: ; first descriptor in gdt needs to be null

dw 0x0
dw 0x0
dw 0x0
dw 0x0

code_descriptor: ; code descriptor

dw 0xffff ; segment base address
dw 0x0000 ; segment limit
db 0x0 ; base
db 10011010b
db 11001111b
db 0x0

data_descriptor ; data descriptor

dw 0xffff ; segment base address
dw 0x0000 ; segment limit
db 0x0 ; base
db 10010010b
db 11001111b
db 0x0

gdt_end:

gSize: ; these values loaded into gdtr with lgdtr

dw (3*8)-1 ; 16 bit limit address
dd gdt ; 32 bit base address
ASHLEY4

RE:protected mode problem

Post by ASHLEY4 »

Do you do this in your code "cli" (clear interrutpt flag) before go into pmode ?.

ASHLEY4.
tyler

RE:protected mode problem

Post by tyler »

Thanks for your prompt reply..

I do clear interrupts before enabling protected mode...

Maybe it has to do with my enabling my 21'st address line incorrectly?

Thanks again.

Tyler
Post Reply