Text Output Problems

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
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Text Output Problems

Post by pcmattman »

I have some really weird issues in my kernel!

I'm currently attempting to run an ELF program, which calls my OS' syscall to print some text. The routine through which this is done is simple:

shell.asm

Code: Select all

mov eax,1
mov esi,Welcome
int 0x80

...

Welcome db "Welcome to Mattise (from the Shell)!",13,10,0
This works properly, and I can see the text printed. There's just one thing: the first character of the line does not print. If I add a space before it, the string prints properly. You can see this weird problem at this location

Thanks in advance!

Edit: Actually, it's a problem with my kprintf() function... any ideas?
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Well does the kprintf work just fine from within the kernel. (Had to ask) Also the code for the call to kprintf would be nice to see. You might want to use bochs to see if the pointers are pointing to the same location in memory or if someone they point to a location 1 byte apart. (Maybe the interrupt handler accidentally adds 1 to the argument).
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

The pointers are correct, it works in my kernel, the code is in do_print.cc in my CVS repository.
User avatar
XCHG
Member
Member
Posts: 416
Joined: Sat Nov 25, 2006 3:55 am
Location: Wisconsin
Contact:

Post by XCHG »

I don't think your printing function works with your kernel accurately either. I downloaded your OS' image file and run it in VirtualPC. After logging in with root, I typed HELP and then LP. See what happened:

All the first characters of the lines printed in the red oval's area are not printed. I am guessing you are not handing newlines correctly or maybe you are printing those characters with a black foreground color.
Attachments
Error.PNG
Error.PNG (8.36 KiB) Viewed 977 times
On the field with sword and shield amidst the din of dying of men's wails. War is waged and the battle will rage until only the righteous prevails.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

XCHG wrote:I don't think your printing function works with your kernel accurately either. I downloaded your OS' image file and run it in VirtualPC. After logging in with root, I typed HELP and then LP. See what happened:

All the first characters of the lines printed in the red oval's area are not printed. I am guessing you are not handing newlines correctly or maybe you are printing those characters with a black foreground color.
Actually that's a really old build, but the same printf function... I hadn't seen that for a while :D

I doubt it's handling newlines, because everywhere else they work. It's just in the context of a kprintf( "%s", str ); that they don't work...

I have since fixed the problem by using the same function the kprintf helper function calls (cons.Output( str )) and it works properly so far. I would still like to fix the problem, though.

I think that it may be an issue in the code with having a string first up and not reading the first character properly. I really have no idea though :D
frank
Member
Member
Posts: 729
Joined: Sat Dec 30, 2006 2:31 pm
Location: East Coast, USA

Post by frank »

Syscall 1 doesn't appear to call kprintf.

Code: Select all

case SYSCALL_PRINTSTR:
   52 
   53 			// print the string in ESI
   54 			{
   55 				char* esi = (char*) r->esi;
   56 				cons.Output( esi );
   57 			}
   58 			break;
and I didn't see anything wrong with cons.Output( ). I am all out of ideas. The only thing I can think of is to painfully step through your kernel in bochs and look for where the pointer gets screwed up or it forgets to print the first character.
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

pcmattman wrote:I have since fixed the problem by using the same function the kprintf helper function calls (cons.Output( str )) and it works properly so far. I would still like to fix the problem, though.
It did call kprintf... I'll have to step through the code slowly and painfully... Thanks for your help though!
Post Reply