Page 3 of 5

Re:My print string function

Posted: Wed Mar 24, 2004 11:47 am
by bubach
as i don?t have any replies yet i will just continue to talk to myself.. ;)
i tested to change the jb to ja instead and the 'call scroll_up' to 'call _scroll_up' but all i got is a (general protection?) fault..
This sucks!

/ Christoffer

Re:My print string function

Posted: Wed Mar 24, 2004 12:07 pm
by Candy
bubach wrote: as i don?t have any replies yet i will just continue to talk to myself.. ;)
i tested to change the jb to ja instead and the 'call scroll_up' to 'call _scroll_up' but all i got is a (general protection?) fault..
This sucks!

/ Christoffer
Could you mail/send me a copy of your disk image? I'd like to run it in a debugging-bochs.

Re:My print string function

Posted: Wed Mar 24, 2004 12:18 pm
by bubach
ok, but i compile it on a normal floppy.. ;)
here?s the source-zip..

[attachment deleted by admin]

Re:My print string function

Posted: Wed Mar 24, 2004 2:12 pm
by Candy
bubach wrote: as i don?t have any replies yet i will just continue to talk to myself.. ;)
i tested to change the jb to ja instead and the 'call scroll_up' to 'call _scroll_up' but all i got is a (general protection?) fault..
This sucks!
*kicks bubach* don't change without thinking!

Excerpt from your zip:

Code: Select all

                push    edi^M
                push    esi                ; may be a good idea with a unchanged esi^M
^M
                mov     edi,0b8000h^M
                mov     esi,0b8000h+160^M
                mov     ecx,(160*49)/4^M
                rep     movsd^M
^M
                pop     ds^M
So, you push edi, then esi, then pop that back into ds and expect it to work?

The memory contains :

Code: Select all

0x9ffc0 <bogus+0>:      0x23    0x4d    0x53    0xae    0x81    0x00    0x00    0x00
0x9ffc8 <bogus+8>:      0x05    0x00    0x00    0x10    0x00    0x00    0x00    0x35
and your stack pointer & gdt are:

Code: Select all

esp:0x9ffc3
gdtr:base=0x88e4, limit=0x17
so that is WAY over the limit. It ends up at a 81ae which is a LOT more than 0x17.
PS: your stack pointer is unaligned. Align it :).

You might want to pop that esi & edi back again.

Re:My print string function

Posted: Thu Mar 25, 2004 3:43 am
by bubach
opps..
i missed that pop ds... ;)
that dosn?t sound that good.. ****!
now i am absolutly sure that i know too little to be programming a OS. i think that i will lay this on ice, and learn asm programming better first..

but whats with those ^M?

/ Christoffer

Re:My print string function

Posted: Thu Mar 25, 2004 3:53 am
by Candy
bubach wrote: i missed that pop ds... ;)
that dosn?t sound that good.. ****!
now i am absolutly sure that i know too little to be programming a OS. i think that i will lay this on ice, and learn asm programming better first..
That's a common error. You'll learn either way.
but whats with those ^M?
That's because you use Windows which adds a 0xd 0xa at the end of each line. Linux only reads the 0xa so the 0xd is printed as the thirteenth control character. Control characters are printed as ^ with the character corresponding to them. 0xd thus is ^M.

Use linux line breaks or learn to look over it (like I have).

This also applies in the inverse direction, if you use Linux files in windows it will not recognise the enters and display a mess of code. Check out AtlantisOS source for examples.

PS: half-decent wineditors convert that themselves. Notepad does not.

Re:My print string function

Posted: Thu Mar 25, 2004 8:04 am
by bubach
Candy wrote: The memory contains :

Code: Select all

0x9ffc0 <bogus+0>:      0x23    0x4d    0x53    0xae    0x81    0x00    0x00    0x00
0x9ffc8 <bogus+8>:      0x05    0x00    0x00    0x10    0x00    0x00    0x00    0x35
and your stack pointer & gdt are:

Code: Select all

esp:0x9ffc3
gdtr:base=0x88e4, limit=0x17
so that is WAY over the limit. It ends up at a 81ae which is a LOT more than 0x17.
PS: your stack pointer is unaligned. Align it :).
it was the gdt and stack stuff i meant, i don?t understand as much of it that i think i should do to be able to program a OS.

but thanks for all your help!

/ Christoffer

Re:My print string function

Posted: Fri Mar 26, 2004 2:36 am
by bubach
I have found the biggest bug!
all those calculations with 49 that should have been 24 instead.... :-[
how could i be so stupid!
in the os i toke tho functions from he uses a 8x8 font witch make the screen have 80x50 chars instead of 80x25.

/ Christoffer

Re:My print string function

Posted: Fri Mar 26, 2004 2:37 am
by Candy
bubach wrote: I have found the biggest bug!
all those calculations with 49 that should have been 24 instead.... :-[
how could i be so stupid!
in the os i toke tho functions from he uses a 8x8 font witch make the screen have 80x50 chars instead of 80x25.
Thanks. I missed that too :)

Re:My print string function

Posted: Fri Mar 26, 2004 3:04 am
by bubach
the sad thing is that it is still not working.. :'(

Re:My print string function

Posted: Fri Mar 26, 2004 3:22 am
by Candy
bubach wrote: the sad thing is that it is still not working.. :'(
*goes on a quest to linux to fix your problem*

be back in a few hours :D

ps: use makefiles.

Re:My print string function

Posted: Fri Mar 26, 2004 6:35 am
by bubach
ok. i do use a .bat file that compiles and copies the os.

/ Christoffer

Re:My print string function

Posted: Fri Mar 26, 2004 6:38 am
by Candy
You seem to be having some trouble with the meaning of some functions and opcodes.

example:

Code: Select all

                mov     dl,al^M
                pop     ebx^M
                mov     dh,bl^M
^M
                popad^M
                ret^M
Ignore the ^M's. You place the output value in dx, then pop the old value back in it, and then return. That will never work.

You have a lot of redundant code (inccursor, deccursor and getcursor all manually access the display chip for reading, inccursor, deccursor and setcursor_real all manually access the display chip for writing) and you seem to have a bit of spaghetti in there (two entry points with one exit point is not really looking good)

Also, you seem to use both spaces and tabs to space your code, and are occasionally inconsequent with it. That doesn't look too nice but doesn't in itself break anything.

Also, in the print_char, you have one push ebx, and two pops into edx. That confuses anybody that reads over it.

print starts with a pusha and ends with a popad, which would crash the system if you ran it.
You don't set the copy direction in scroll_up which wrecks your display routine in continuity.

You fill up the nonprinted area with zeroes, while spaces would have been better. Not a bug this, but something that's not entirely clean.

You scroll up after every character, but do not increase the cursor?


You don't set the org for your kernel properly!

The call to your string printing function disassembles as:

Code: Select all

(0).[572064] [0x00100230] 0008:00100230 (unk. ctxt): mov ESI, 00000015         ; be15000000
(0).[572064] [0x00100235] 0008:00100235 (unk. ctxt): mov AL, 0e                ; b00e
(0).[572064] [0x00100237] 0008:00100237 (unk. ctxt): call 001000cd             ; e891feffff
Your string is at 0x00100005. You currently try to print the interrupt vector table.

Re:My print string function

Posted: Fri Mar 26, 2004 7:03 am
by bubach
Mmm.. Ok, i will be back.

Re:My print string function

Posted: Fri Mar 26, 2004 7:11 am
by Candy
The intermediate version I made it to, sorry bout that. Shouldn't have done that, but it might help you with the rest.

[attachment deleted by admin]