Page 1 of 1

Can't access real mode memory after pmode?

Posted: Sun Jul 21, 2002 11:00 pm
by Anon
Heres the simple code...

mov ax, 0x7000
mov

Oops, forget that last post... read this...

Posted: Sun Jul 21, 2002 11:00 pm
by Anon
The code is:

mov ax, 0x7000
mov es, ax
mov bx, 0x0000

mov dword [es:bx], [code]

mov bx, 0x0004

mov dword [es:bx], [code + 4]

jmp short aftercode

code:
mov byte [gs:0xB8002], 'C'    ; this ends up compiled as 8 bytes

aftercode:
;code to switch to pmode, then...

jmp 0x70000

jmp short $

; gdt, idt, etc...



when it jumps to the code (in pmode), it should print the letter C as the second character on screen... but it just triple-faults... Got any ideas?


Anon

RE:Oops, forget that last post... read this...

Posted: Mon Jul 22, 2002 11:00 pm
by anton
First, did you set up GDT or LDT.
Second, where does gs poit to.
Third, (if you did set up GDT or LDT and gs is valid data segment), is the code "mov byte..."
compiled correctly for the setted up descriptor(16 or 32 bit).
PS you should also put a loop after "mov byte ...",or it is probobly triple-faults after "mov ..."

RE:Oops, forget that last post... read this...

Posted: Mon Jul 22, 2002 11:00 pm
by Anon
GDT, IDT are set up. First part is [BITS 16], after pmode is [BITS 32] gs is LINEAR_SEL, which has base 0. It doesn't seem that 0x70000 is the correct mem for 0x7000:0x0000.

Anon

RE:Oops, forget that last post... read this...

Posted: Mon Jul 22, 2002 11:00 pm
by anton
jmp 0x70000 should be 16 bit if there was no change of controll before it(jmp or call) after setting
the pmode bit.

RE:Oops, forget that last post... read this...

Posted: Mon Jul 22, 2002 11:00 pm
by Anon
It goes to full pmode and resets the registers.

Anon

FIXED IT

Posted: Mon Jul 22, 2002 11:00 pm
by Anon
There was really nothing wrong... The selector wasn't set as executable! If anyone else ever has this problem, check if the selector is executable! (Man, why didn't I think of that before?)

Thanks anyway,
Anon

RE:FIXED IT

Posted: Tue Jul 23, 2002 11:00 pm
by carbonBased
Huh!?  Last I checked, there was no "executable" bit in a descriptor...?

Anyway, glad to hear all's fixed!  Believe me, dude, those kinda tiny mistakes are the basis of OS Development, I swear! :)  Makes it all the more interesting, though, eh? ;)

Jeff