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.
For some reason, any time I code a "print text to screen function", it can only produce single 'S's. I am using DJGPP and its all in C. Also, I'm using Bochs to run it. The problem code:
Just a shot in the dark, but is your read-only data section properly linked? I don't know the specifics because I use MSVC, but failing to link the .rodata segment (I think...) is often the cause of strange string printing bugs.
Search the forum, this type of thing seems to happen often.
Nothing looks wrong from a quick glance at the code, although I would recommend using a global variable or something to store the X and Y position rather than using seven port I/O instructions per character. This could get slow. But slowness is secondary: getting it working is the top priority.
You probably have a linker issue. Check that you indeed link the .rodata section as your program does need it.
The code itself is perfectly fine - it runs in my os without problems:
Booting from Floppy...
MOS V1.3.0 bootloader executing
Loading MOS86..............................
MEM A20 GDT TXT Welcome to Sharp!
Mike: its 7 I/Os a string, not each character
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Can you post the linker script you used to compile it? Because I tried some examples with the rodata section in it, and it still compiled the same way....
I just can't get it to work. It's as if my computer is against me. I've tried close to 100 different linker scripts and none of them will work with me...
If anyone else has a good suggestion, speak up.
Edit: I ran was looking at a dump of the code, and both of my strings are there. I don't know if this means that the linker is not the problem, but maybe its something to consider.
OK, but stick with .rodata* as .rdata* is definitely wrong. (Just in case that was also a problem.)
Also, change "int Offset" to "unsigned int Offset". What is the type of In? If it returns a char, change it to return an unsigned char.
(A char might be signed. If the call to In() returns some character >= 128, it'll be negative as a signed char, so when the compiler casts the char into an int (to store it in Offset), it'll stick 1s at the beginning instead of 0s, which will make everything go wrong.)
EDIT: I didn't notice your edit. I suppose the linker script is OK then.
If you upload your kernel binary and maybe the .o file containing Write (you'll need to zip them, apparently), I can look at them and see if anything looks strange...