Help with activating pmode
I think I made a mistake. That 500h is not always right. It depends also on your realmode-segments. Is it true in realmode your segment-registers are 0 and your code is loaded at address 0x500? If that's true, what I told you about adding 0x500 is not true, in that case you need to remove the +500h.
And that print-function?
Did you try without it?
I see you don't use int 10h which is good. The problem is your print-function is part of the 16-bit code. Move your print-function in the 32-bit part, otherwise it won't work.
And that print-function?
Did you try without it?
I see you don't use int 10h which is good. The problem is your print-function is part of the 16-bit code. Move your print-function in the 32-bit part, otherwise it won't work.
Code: Select all
;;;; ========16 bit part ===========
; put your 16 bit stuff here
;being 32 bit stuff
bits 32
Kernel:
;-------------------------------;
; Set registers ;
;-------------------------------;
mov ax, 0x10
mov ds, ax
mov ss, ax
mov es, ax
mov fs, ax
mov gs, ax
mov esi, msg
mov edi, 0xb8000
call Print
hlt
msg db "HELLO WORLD!", 0
; (control chars like 0x0A and 0x0D make no
; sense when writing directly to video memory)
Print: cld
mov ah,0x0f ; color
nextchar: lodsb ; get char and increase si
or al,al ; if char= 0 then stop print.
jz screen.print.finish
stosw ; put the char+color on the screen and increase di with 2
jmp short nextchar ; countione (sry for my bad spelling)
screen.print.finish:
ret
Last edited by svdmeer on Sun May 25, 2008 5:32 pm, edited 1 time in total.
Please answer svdmeer's question, and do not call your routine.tadada wrote:It prints "loading the kernel" in all its glory under realmode but It won't print anything under pmode.
Also, it may not work if the routine is 16 bit not 32 bit. i.e., If the routine is within the 16 bit code segment, it may not work. (I had hit and mess with this before.)
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
I thought the GDT was supposed to total 8 bytes for each entry. and with
2 DWs and 4 DBs it totals 8 bytes (unless I don't know my DWs and such) I know it has just as many bytes as the other entries and the jmp works so that means at leaast the SYS_CODE_SEL is alligned properly.
2 DWs and 4 DBs it totals 8 bytes (unless I don't know my DWs and such) I know it has just as many bytes as the other entries and the jmp works so that means at leaast the SYS_CODE_SEL is alligned properly.
My OS: SOS (Simple Operating System).
- thepowersgang
- Member
- Posts: 734
- Joined: Tue Dec 25, 2007 6:03 am
- Libera.chat IRC: thePowersGang
- Location: Perth, Western Australia
- Contact:
`tadada wrote:sorry about that. No when I replace the call line with the line you supplied nothing happened. Also I moved the "bits 32" so it comes before the routine.
It becomes weird..it looks like 0xb8000 isn't your videosegment.
Are you in textmode?
The function cannot work in realmode, because address 0xb8000 isn't addressable with only a offset-register. You must have a segment-register set, for example es=b800, es:[0] -> first char.
Does:
mov ax,0xb800
mov es,ax
mov word es:[0],0x5050
work in realmode?
iirc, the text mode video segment can begin at either 0xb8000 or 0xb0000--Try both of them and see what happens.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
the video ram is 0xb800 in real mode. Moving 0x5050 into the ram during real mode works (a black "P" on a purple background appears), but in pmode it doesn't.
I was using the code:
with this code:
nasm gives me an error
In real mode none of the following works: b800, b000, b8000, b0000
BTW: How do I insert a break point?
I was using the code:
Code: Select all
mov ax,0xb800
mov es,ax
mov word [es:0],0x5050
Code: Select all
mov ax,0xb800
mov es,ax
mov word es:[0],0x505
In real mode none of the following works: b800, b000, b8000, b0000
BTW: How do I insert a break point?
My OS: SOS (Simple Operating System).
I haven't read much of this post, but if you are using BOCHS then stick a 'hlt' where you want it to break and then check the debugging logs.
Website: https://joscor.com
Both code snippets you posted means the same thing--use the first method as it works in NASM.
/me thinks we need to see more code. More specifically your PMode and printing routine.
Are you using svdmeer's code?
Can you please rephrase this? I assume that it works with 0xb800, but then you say it doesn't... :/tadada wrote:the video ram is 0xb800 in real mode. Moving 0x5050 into the ram during real mode works (a black "P" on a purple background appears), but in pmode it doesn't.
/me thinks we need to see more code. More specifically your PMode and printing routine.
Are you using svdmeer's code?
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}