Please help me to build an exe or com file under linux
Posted: Thu Mar 03, 2011 7:10 am
How to build an com or exe file ( bootloader will read it ) using nasm under linux ( ubuntu ) ?
Thanks
Thanks
The Place to Start for Operating System Developers
http://f.osdev.org/
Code: Select all
valid output formats for -f are (`*' denotes default):
* bin flat-form binary files (e.g. DOS .COM, .SYS)
ith Intel hex
srec Motorola S-records
aout Linux a.out object files
aoutb NetBSD/FreeBSD a.out object files
coff COFF (i386) object files (e.g. DJGPP for DOS)
elf32 ELF32 (i386) object files (e.g. Linux)
elf ELF (short name for ELF32)
elf64 ELF64 (x86_64) object files (e.g. Linux)
as86 Linux as86 (bin86 version 0.3) object files
obj MS-DOS 16-bit/32-bit OMF object files
win32 Microsoft Win32 (i386) object files
win64 Microsoft Win64 (x86-64) object files
rdf Relocatable Dynamic Object File Format v2.0
ieee IEEE-695 (LADsoft variant) object file format
macho32 NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (i386) object files
macho MACHO (short name for MACHO32)
macho64 NeXTstep/OpenStep/Rhapsody/Darwin/MacOS X (x86_64) object files
dbg Trace of all info passed to output stage
Hmm... Looks 'Broken'. This will generate default executable file for the OS (aout under Linux and exe under Windows). In any case, COM file cannot be forced as output by simply adding the '.com' extension.stranger wrote:nasm source_file -o file.com since bin is default output format.
Do you mean you get a 'COM' file under NASM as a default output format?stranger wrote:All I can say is that on gentoo NASM version 2.08.02 behaves as I described.
@sidenote, please note "(`*' denotes default):" and " * bin flat-form binary files (e.g. DOS .COM, .SYS)" lines
The default for NASM is (usually) to generate a flat binary (and it assumes 16-bit instructions). A DOS 'COM' file is nothing more than a flat binary, with 16-bit (real mode) instructions. The only thing you need to do is slap "org 0x0100" at the start of your source file.Chandra wrote:Do you mean you get a 'COM' file under NASM as a default output format?stranger wrote:All I can say is that on gentoo NASM version 2.08.02 behaves as I described.
@sidenote, please note "(`*' denotes default):" and " * bin flat-form binary files (e.g. DOS .COM, .SYS)" lines
Infact you're right. But again, COM files come with limitations. There are some hard facts that separates COM files from 'flat binary' files. COM files are meant to be run under 'Real Mode' and are always executed at a fixed location. Moreover, they are extremely limited in size, more specifically less than 64kb. This is not always the case with 'flat binary' files.Brendan wrote:Hi,
The default for NASM is (usually) to generate a flat binary (and it assumes 16-bit instructions). A DOS 'COM' file is nothing more than a flat binary, with 16-bit (real mode) instructions. The only thing you need to do is slap "org 0x0100" at the start of your source file.Chandra wrote:Do you mean you get a 'COM' file under NASM as a default output format?stranger wrote:All I can say is that on gentoo NASM version 2.08.02 behaves as I described.
@sidenote, please note "(`*' denotes default):" and " * bin flat-form binary files (e.g. DOS .COM, .SYS)" lines
Cheers,
Brendan
Of course, but the fact that OP asked specific question (NASM under Ubuntu), is IMHO good justification for assumption that he was interested in specific answer, not general rules for writing com files.Chandra wrote: The main point here, is that there's more to do with the code itself rather than the switch .