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.
Hello, i am programming PM OS FortOS in C and ASM. I am creating function getline(); and it doesn't work fine. I don't know, if i have bad getch();, getline();, puts(unsigned char *text); or putch(unsigned char ch); function... Can you help me please?
Before one week, I was on to this (a keyboard driver). Well, it's not finished yet, but I can give you several tips:
1. It is not just about reading characters through ports. Do not think, that 0x30 would be character '0'. Do you know anything about scan codes? Your keyboard works with scan codes (the codes it sends to the port 0x60 are scan codes). You must write your own routine to translate these scan codes, to ASCII characters.
2. It is clear that the video memory (80x25 I'm talking about) takes two bytes for a character. The first byte is the ASCII code of the character and the next byte is the attribute (color of the character for example). You didn't post your putch procedure, so I'm not sure, whether you know about the attribute bytes.
I think, I have problems with Bochs. The biggest one: Bochs hates me!
From the list of most notorious errors in C code: - Not null terminating a string
yup, you forgot to add a '\0' to the end of the string before giving it to puts.
Regarding the rest: - char getline() {...}
getline should hand over a string. Not a character, no? - goto labb;
Yuck. goto's are evil. - One True Bracing Style
I think the people here can agree that NOT identing is potentially the worst bracing style. we have the
tag for that, not [quote]
[i]- linak[citac] = cteno; [/i]
You mind posting code in english? That would save us from having to reverse-engineer variable names.
"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 ]
no, even void getline(char * p)
otherwise you end up returning an array that goes out of scope the moment you return it (another common error).
"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 ]
Combuster wrote:no, even void getline(char * p)
otherwise you end up returning an array that goes out of scope the moment you return it (another common error).
Oh...I was thinking he was using malloc or something. Sorry...
Well first fix up your getLine to use a while loop (and break statments). Secondly, it look to me that your writting a stack pointer to the screen. What compiler are you using?
Microsoft: "let everyone run after us. We'll just INNOV~1"
I am using DJGPP - GCC compiler and NASM for compiling ASM parts.
To be more specific - you are using code from Bran's Kernel Development Tutorial.
linak[citac] = cteno;
Translation: Liner[Counter] = The readed;
Sorry guys as I can't help with this...
If your OS is in text mode for now (well I think it is ), you can try to find some disassembled BIOS on the net and copy the 16-bit code from there. It shouldn't do any serious problems as you aren't using BIOS interrupts, but the copied code.