I have a print function in asm, saved inside string.asm
In the same file i have another print function called printh, used for printing hex codes by converting to ascii, and then calling the print function. My problem is, it never prints after the conversion. :/ and i know the print function works since i've been using it and im fairly sure my printh function works. Even if i just call print with some 'test' ascii stored in the data section it never works. Am i allowed to have two funcions inside 1 .asm file and have them call each other? Seems v.strange.
I did have another similar problem a few days back. My relocate code (once fixed, but now no longer used) ended up somehow jumping to 4kb mark and running bios code. The screen would blank and i would even get the curser grub leaves to go away but i have no problem with this anymore, as i said, the relocate was fixed, and now, isn't used anyway. But any ideas on the first prob?
Thanks.
Brill.
An interesting problem
RE:An interesting problem
Why don't you post the assembly source file with the two functions??
RE:An interesting problem
I won't post the source because it's a lot to put on 1 page, but i'll put it at some url and post that here later at home when i have the access to run ftp connections .
RE:An interesting problem
ok, i've uploaded the assembly files to some web space.
The url's are...
http://jobb-uk.hypermart.net/osdev/main.asm
http://jobb-uk.hypermart.net/osdev/start.asm
http://jobb-uk.hypermart.net/osdev/string.asm
string and main are the only 2 functions that need to be read to understand the concept of whats happening. I put start up because main is whats run after start and maybe the problem could be there.
The way it works is, start.asm sets up the basic system environment. This means, gdt, idt (handlers arn't programmed yet) and the meminit function which is incomplete, but that doesn't matter because nothing yet relies on the MM. After the env' is setup, start jumps to main so the os can start from scrath but expect the system to be stable enough to continue with what an os should do. main at the moment only has about 3/4 lines of code to setup a call on printh (my hex printing function) and then cli, hlt to stop.
When i call printh. It expects edx to contain the hex values in the 8 nibbles and ah to be the vga attribute byte. printh does some work on each nibble by turning it into ascii through addition. 0 in hex is 0000 binary, adding 48 denary to this will give 0 in ascii, and because ascii codes go up in 1's just like hex, we just add 48 to each hex NUMBER. The hex letters have to be added to 55 because they have a different denary offset from hex.
After the addition is made. I save the byte of ascii inside a byte data storage, load esi with that storage and call print, which, asuming print works the way i want it to, should print out the ascii character. But it doesn't print when called from printh but it does work when called from say main with some normal ascii text. Thoughts are that prinh doesn't work as intended but looking over the printh code, it seems logical to work correct. Unless someone can see any mistakes.
And another odd thing is, another function called version ends up getting run somehow even though i don't call it. That actually uses the normal ascii print to put some info on screen regarding the osname, version and my name.
Thanks to anyone in advance who may give help .
Brill.
The url's are...
http://jobb-uk.hypermart.net/osdev/main.asm
http://jobb-uk.hypermart.net/osdev/start.asm
http://jobb-uk.hypermart.net/osdev/string.asm
string and main are the only 2 functions that need to be read to understand the concept of whats happening. I put start up because main is whats run after start and maybe the problem could be there.
The way it works is, start.asm sets up the basic system environment. This means, gdt, idt (handlers arn't programmed yet) and the meminit function which is incomplete, but that doesn't matter because nothing yet relies on the MM. After the env' is setup, start jumps to main so the os can start from scrath but expect the system to be stable enough to continue with what an os should do. main at the moment only has about 3/4 lines of code to setup a call on printh (my hex printing function) and then cli, hlt to stop.
When i call printh. It expects edx to contain the hex values in the 8 nibbles and ah to be the vga attribute byte. printh does some work on each nibble by turning it into ascii through addition. 0 in hex is 0000 binary, adding 48 denary to this will give 0 in ascii, and because ascii codes go up in 1's just like hex, we just add 48 to each hex NUMBER. The hex letters have to be added to 55 because they have a different denary offset from hex.
After the addition is made. I save the byte of ascii inside a byte data storage, load esi with that storage and call print, which, asuming print works the way i want it to, should print out the ascii character. But it doesn't print when called from printh but it does work when called from say main with some normal ascii text. Thoughts are that prinh doesn't work as intended but looking over the printh code, it seems logical to work correct. Unless someone can see any mistakes.
And another odd thing is, another function called version ends up getting run somehow even though i don't call it. That actually uses the normal ascii print to put some info on screen regarding the osname, version and my name.
Thanks to anyone in advance who may give help .
Brill.
RE:An interesting problem
I forgot something. People may notice that i have a jmp short $ instruction in the middle of my printh function. I know about this, i put it there _AFTER_ the function wouldn't work. I was using it to test different areas of the function to see if i could find out what was going wrong.
RE:An interesting problem, partially fixed ;/
ok, the version program is never run, it happens that i assemble the version script right after the string script, and ldscript puts all .data sections together, thus you have version data straight after string data which is what's making it print. Meaning something is wrong inside my print function. I seem to be able to call print from one part of printh but not another though. ;/.
RE: problem fixed :D
heh, a typo and silly error code in a couple of functions made the whole thing go wrong. Fixed now though , thank you to anyone who would have helped .