Page 1 of 1

pmode error

Posted: Mon Oct 18, 2004 12:49 pm
by McZ
well, I have been trying to get my bootcode into pmode and this DOES not work :(

the Virtual PC resets when I do the long jump after I have set the pmode bit

mov eax, cr0
or eax, 1
mov cr0, eax

jmp 08bh:FLUSH <- if I comment this line and down to the line before hlt it won't restart else it does before hlt I write a P to the video mem, as in the example/tutorials I have found

[BITS 32]
FLUSH:
; set the stack pointer etc.
...

hlt

Re:pmode error

Posted: Mon Oct 18, 2004 12:59 pm
by Curufir
McZ wrote: jmp 08bh:FLUSH
Well 0x8b isn't going to be a descriptor no matter how you've set up your GDT. It actually points to memory some 17.375 entries into the GDT, so it's not hugely surprising the processor doesn't like what it finds there.

Re:pmode error

Posted: Tue Oct 19, 2004 4:31 am
by ManOfSteel
jmp 08bh:FLUSH
Well 0x8b isn't going to be a descriptor no matter how you've set up your GDT. It actually points to memory some 17.375 entries into the GDT, so it's not hugely surprising the processor doesn't like what it finds there.
In other words, it should be:

Code: Select all

jmp 08h:FLUSH
'08h' (or '8') being your code segment.

Re:pmode error

Posted: Tue Oct 19, 2004 5:04 am
by Candy
Curufir wrote:
McZ wrote: jmp 08bh:FLUSH
Well 0x8b isn't going to be a descriptor no matter how you've set up your GDT. It actually points to memory some 17.375 entries into the GDT, so it's not hugely surprising the processor doesn't like what it finds there.
Well, imo, not. It points to the 17th entry (counting from zero and up), and it loads it with a PL=3. Check your books.

If it were 0x8c or higher it'd be an LDT entry of 17, with cpl = code - 0x8c. Of course, LDT makes no real sense nowadays, nor does having LDT entries at CPL=0.

When you're jumping to pmode you most certainly want to use cpl0 or you're tying yourself up after locking out all help. Sounds like suicide.

Re:pmode error

Posted: Tue Oct 19, 2004 6:55 am
by McZ
thank you :) finally it doesn't restart...

but I still have some problems, how do I write to screen in pmode using nasm? all I can find in the tutorials I have is this lines:

mov 0b8000h, 'P' ; The letter P
mov 0b8001h, 1bh ; with some attribute

but this generates an error when I compile it.. how should I do it with nasm?

Re:pmode error

Posted: Tue Oct 19, 2004 7:37 am
by Candy
McZ wrote: thank you :) finally it doesn't restart...

but I still have some problems, how do I write to screen in pmode using nasm? all I can find in the tutorials I have is this lines:

mov 0b8000h, 'P' ; The letter P
mov 0b8001h, 1bh ; with some attribute

but this generates an error when I compile it.. how should I do it with nasm?
The error probably is that you don't specify the size. You actually don't.

Suggestions:

Code: Select all

movb [0b8000h], 'P'
mov [0b8001h], byte 1bh
The second will work, the first might work (does in AT&T, might in nasm).

You probably understand how to extrapolate this to the full screen. There's 8000 of those entries right after another.

[edit] wake up man... [/edit]

Re:pmode error

Posted: Tue Oct 19, 2004 7:58 am
by Ytinasni
McZ wrote: thank you :) finally it doesn't restart...

but I still have some problems, how do I write to screen in pmode using nasm? all I can find in the tutorials I have is this lines:

mov 0b8000h, 'P' ; The letter P
mov 0b8001h, 1bh ; with some attribute

but this generates an error when I compile it.. how should I do it with nasm?
you probably want

mov [0b8000h], 'P' ; The letter P
mov [0b8001h], 1bh ; with some attribute

(square brackets meaning 'memory at this location')