Generating *.COM file

Started by los8005, July 03, 2013, 02:41:02 PM

Previous topic - Next topic

los8005

Hello! Is it possible to generate a Pelles C output file format *.com or other binary format without headers exe? I'm trying to compile a kernel mini os. Thanx.

Bitbeisser

Quote from: los8005 on July 03, 2013, 02:41:02 PM
Hello! Is it possible to generate a Pelles C output file format *.com or other binary format without headers exe? I'm trying to compile a kernel mini os. Thanx.
Pelle's C is a Windows based compiler for Windows based/targeted development, so the answer is no.

Ralf

frankie

#2
As Ralph said PellesC is a 32/64 bits compiler and cannot produce com files (that are 16bits executables).
But the 32/64PE format is basically an absolute executable prelinked at the specified base address (for win32 that address is 0x400000 by default). If you specify a different address using linker switch you will have an executable ready to run at the address you choosed displaced by the PE header size.
Of course you have to omit default libraries (see switches od compiler and linker) and define your entry point (linker switch).
In this case you need a simple binary code (that can be produced in assembler than compiled binary format using NASM or YASM) that at boot switch to 32 bits and jump to code entry read from code start in the PE header, or, if your entry point is the very first linked code, simply jump to base_address+PE_header_size (if your source have many modules it is not guaranteed that the very first linked code is that you intended to be).
I used this method to produce a simple OS sample (http://forum.pellesc.de/index.php?topic=443.0).
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

los8005