Page 2 of 4

Posted: Sun May 25, 2008 5:02 pm
by tadada
It still create this exception in Bochs:
00002589342e[CPU0 ] exception(): 3rd (13) exception with no resolution, shutdown status is 00h, resetting

Posted: Sun May 25, 2008 5:23 pm
by svdmeer
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.

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

Posted: Sun May 25, 2008 5:30 pm
by tadada
other then the fact that it won't print to the screen the error has been fixed. Now it loads and doesn't create an error. It is sitting there happily saying nothing for I took out the loading msgs.

Thank you very much.

Posted: Sun May 25, 2008 5:45 pm
by svdmeer
Do you get something on screen if you replace "call Print" with "mov word [0xb8000],0x5050"?

Are you sure you are in textmode? If not try in your realmode part "MOV AX,3", "INT 10h".

Posted: Sun May 25, 2008 6:26 pm
by tadada
It prints "loading the kernel" in all its glory under realmode but It won't print anything under pmode.

Posted: Sun May 25, 2008 10:43 pm
by neon
tadada wrote:It prints "loading the kernel" in all its glory under realmode but It won't print anything under pmode.
Please answer svdmeer's question, and do not call your routine.

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.)

Posted: Mon May 26, 2008 4:27 am
by tadada
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.

Posted: Mon May 26, 2008 5:34 am
by thepowersgang
Maybe the error is in the GTD you posted, I counted only 2 dwords for the first entry (null entry) isn't there supposed to be 3?

Posted: Mon May 26, 2008 5:41 am
by tadada
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.

Posted: Mon May 26, 2008 7:15 am
by thepowersgang
My bad, i'm tired.

I read the dw as meaning DWord not Data: Word

try using the bochs debugger, add a breakpoint at the Pmode code start and use the step function ('s') to trace each instruction until you hit the error.

Posted: Mon May 26, 2008 8:21 am
by svdmeer
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?

Posted: Mon May 26, 2008 9:03 am
by neon
iirc, the text mode video segment can begin at either 0xb8000 or 0xb0000--Try both of them and see what happens.

Posted: Mon May 26, 2008 10:54 am
by tadada
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:

Code: Select all

mov ax,0xb800 
mov es,ax 
mov word [es:0],0x5050
with this code:

Code: Select all

mov ax,0xb800 
mov es,ax 
mov word es:[0],0x505
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?

Posted: Mon May 26, 2008 11:06 am
by 01000101
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.

Posted: Mon May 26, 2008 11:38 am
by neon
Both code snippets you posted means the same thing--use the first method as it works in NASM.
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.
Can you please rephrase this? I assume that it works with 0xb800, but then you say it doesn't... :/

/me thinks we need to see more code. More specifically your PMode and printing routine.

Are you using svdmeer's code?