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.
frank
Post
by frank » Thu Aug 15, 2002 8:44 am
the basic functions work now (putc,gotoxy)
but printf does not work...
Code: Select all
printf("fffff"); <- that's how I call the printf function
Code: Select all
void printf(char * string)
{
unsigned short *vidmem = (short*) 0xb8000;
int i=0;
if (string[0]=='f'){
vidmem[i] = 0x1F66;
}
}
it does print an f without the if statement, but does not with it.
So the first character is not f....
where did those characters go?
crazybuddha
Post
by crazybuddha » Thu Aug 15, 2002 9:58 am
You are probably expecting that the string is passed on the stack. It isn't.
We need to know more about your linking to give a more complete answer.
frank
Post
by frank » Thu Aug 15, 2002 11:40 am
> You are probably expecting that the string is passed on the stack. It isn't.
I understand, so how is it passed?
This is the compile line:
Code: Select all
gcc -O4 -c kern.c
ld -o kern -Ttext 0x0 -e 0x0 kern.o
objcopy -R .note -R .comment -S -O binary kern kern.bin
(I jump to the main in the kernel using asm("jmp main"); on 0x0 of the kernel)
this is how I've set up the stack:
Code: Select all
mov ax,0x10
mov ss,ax
mov esp,0xFFFF
frank
Post
by frank » Fri Aug 16, 2002 9:48 am
Got it working now ;D
the Ttext was wrong, since i've loaded it into 0x1000 it can't be 0x0
Code: Select all
gcc -O4 -c kern.c
ld -o kern -Ttext 0x1000 -e 0x0 kern.o
objcopy -R .note -R .comment -S -O binary kern kern.bin