pmode error

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
McZ

pmode error

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

Re:pmode error

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

Re:pmode error

Post 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.
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:pmode error

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

Re:pmode error

Post 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?
User avatar
Candy
Member
Member
Posts: 3882
Joined: Tue Oct 17, 2006 11:33 pm
Location: Eindhoven

Re:pmode error

Post 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]
Ytinasni

Re:pmode error

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