I'm looking for some help with properly compiling a C program for my Assembly-based OS.
Here is some background info:
My OS is written in 64-bit x86 assembly.
The C program also needs to be 64-bit.
Currently I am not interested in any library calls (like stdio, stlib, etc).
I can compile the program in Linux using GCC (Using Arch Linux in 64-bit mode).
I have had some success with this using the following:
Code: Select all
int main()
{
return 0x12345678;
}
Code: Select all
gcc -c testc1.c
ld -r -Tdata 0x100 -e _start -s -o testc1.out testc1.o
objcopy -O binary -j .text testc1.out testc1.bin
The real issue is trying to get a C program to be able to write to the screen:
Code: Select all
int main(void)
{
char *str = "Hello, world", *ch;
unsigned short *vidmem = (unsigned short*) 0xb8000;
unsigned i;
for (ch = str, i = 0; *ch; ch++, i++)
vidmem[i] = (unsigned char) *ch | 0x0700;
return 0x12345678;
}
Thanks,
-Ian