NO

Author Topic: Generating *.COM file  (Read 2675 times)

los8005

  • Guest
Generating *.COM file
« 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.

Offline Bitbeisser

  • Global Moderator
  • Member
  • *****
  • Posts: 772
Re: Generating *.COM file
« Reply #1 on: July 03, 2013, 10:51:03 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

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2099
Re: Generating *.COM file
« Reply #2 on: July 03, 2013, 11:49:38 PM »
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).
« Last Edit: July 04, 2013, 12:02:10 AM by frankie »
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

los8005

  • Guest
Re: Generating *.COM file
« Reply #3 on: July 04, 2013, 07:51:50 AM »
Thanks for all replies.