Re: How to create a standalone C program?




"dspfun" <dspfun@xxxxxxxxxxx> wrote in message news:1185908920.759023.148720@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
How do you create a standalone C program? With standalone C program I
mean it should run "freestanding" on a CPU without an OS or other
supporting software/libraries linked to the C program. After the bios/
setup has done its initializations and "stuff" I would like to be able
to continue execution with my own C program. The C program will be
really simple to start with, for example just write an integer value
to a memory address.

Don't include any libraries.
The snag is that you've then go no IO. You need to write to hardcoded memory address, possible in C, or generate interrupts, for which you need a spot of assembly.
Then somehow you've got to get a compiler that can be persuaded not to include normal start-up code before main(). This is probably possible with most comercial compilers, but it will need a certain amount of delving into unexplored depths of documentation to understand how to do it. On non-hosted implementations, which is effectively what you are using the PC as, normally entry is vai a special function called "boot" or similar.


.