Can't access real mode memory after pmode?

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
Anon

Can't access real mode memory after pmode?

Post by Anon »

Heres the simple code...

mov ax, 0x7000
mov
Anon

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

Post 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
anton

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

Post 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 ..."
Anon

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

Post 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
anton

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

Post 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.
Anon

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

Post by Anon »

It goes to full pmode and resets the registers.

Anon
Anon

FIXED IT

Post 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
carbonBased

RE:FIXED IT

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