Hi,
How can I create a flat binary file out of a single C source file, that can be loaded into a certain address and jumped to?
Lets say I have this in the c source file:
void k_main()
{
char *vid = ( char * ) 0xb8000;
int i = 0;
vid = 'A';
i++;
vid = 0x07;
while ( 1 )
{
}
}
I want this to be put into a flat binary file that can be loaded at an address and jumped to, it would then print the 'A' and then hang.
I have tried many tutorials on writing a simple c kernel, but I dont like them it should be much more simple, if gcc is so complex to use I will not use it.
Thanks.
Flat Binary with GCC
Re:Flat Binary with GCC
You are going to have to use a linker script to tell gcc how to link the file. read the docs that come with gcc, it has an example simple linker script that does what you are looking for
Re:Flat Binary with GCC
ld -Ttext 0x600 -oformat binary -o kmain.bin kmain.o
where 0x600 is the absolute address where this code is going to reside. This assumes the GDT gives the base address as 0x0 and that you switch to pmode before you jump there.
There are several complications in practice, but this should get you something working.
where 0x600 is the absolute address where this code is going to reside. This assumes the GDT gives the base address as 0x0 and that you switch to pmode before you jump there.
There are several complications in practice, but this should get you something working.
Re:Flat Binary with GCC
Look at my FritzOS web site...it has stuff that'll help you.
You need to look at the install.sh file for how to compile it.
You need to look at the install.sh file for how to compile it.