Executable format output

Started by
3 comments, last by Khaos 22 years, 5 months ago
Greetings. I am at a stage of my custom BASIC compiler creation, where I want to move from generating (NASM compatible) assembly code, to generating a pure binary executable format. I am going to be shooting for this to be compiled into a .COM file. I really only have one basic question. How could I get my compiler to generate the code, put it into a file in the correct format, and be able to select and run the file like any other .COM file? I might keep my compiler as is, generating assembly code, and then make my own linker like program to turn that into a .COM file, or I might change my compiler to simply output my executable file. So how can I do this? What is the file format for a .COM file, and how can I create this file? Any ideas, links, etc. is appreciated. Thanks guys! ===== Khaos =====
Advertisement
Ok, I have a (sorta) related (and totally irrelevant) question:
What exactly is the difference between a COM executable and an EXE one? I remember something about COM ones having a size limit, but that''s all I can recall from the MS-DOS days.
.COM is a nice, simple file format. Get the specs here. What you''ll want to do is essentially translate your assembly language to the corresponding opcodes, and write them to a file with the correct .COM header information. If you are looking for inspiration, I would suggest that you check out NASM, which is open source, and can output flat binary (e.g. .COM) files.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
True *.com files are limited to 64 kb - the *.com files that ship with non-DOS based windows aren''t true com files but are either NE or LE format files - leftovers from the early days of NT. A 32 bit windows executable format is PE - "portable executable" - portable in that it will run on different versions of windows - not portable in that it won''t run on *nix or mac. Bear in mind that *.com files are obsolete - but if you are looking to get your feet wet building a ''compiler'' I suppose there''s no harm there, eh? For format info check out wotsits.com - and maybe programmersheaven.com too. For info on PE files - start at google - search on Pietrek. Also check out Elicz''s site - don''t expect much source in basic - mostly asm and C or C++. Best of luck.
That''s a great start. Thanks a lot guys.

=====
Khaos
=====

This topic is closed to new replies.

Advertisement