This has been annoying me for a while.
I have implemented syscalls and am now testing binary file loading and libraries to use syscalls and etc.
Now, my problem:
I have (for now) set syscall 1 to be a sys_print function (to write a character to the screen). I also have a basic library to call that syscall:
Code: Select all
int putch(char c)
{
asm("int $0x80"::"a"(1), "b"(c));
return 1;
}
I also have a program (init.c) which does run on my OS. Now, I have made it print 'Hello' on the screen with a bunch of putch() calls. My problem function is this:
Code: Select all
int puts(char str[256])
{
int i=0;
while(str[i] != '\0')
{
putch(str[i]);
i++;
}
return 1;
}
Here is the main() function:
Code: Select all
int main_init()
{
putch('H');putch('e');putch('l');putch('l');putch('o');putch('!');putch('\n');
puts("Hello, Testing. Hello World!");
}
It compiles with this:
Code: Select all
gcc -c -o init.o -nostdlib -nostdinc -I ../library/include -m32 init.c
ld -m elf_i386 --oformat binary -e main_init -o init -nostdlib init.o ../library/libc.o
-JL