Please help me to build an exe or com file under linux
Please help me to build an exe or com file under linux
How to build an com or exe file ( bootloader will read it ) using nasm under linux ( ubuntu ) ?
Thanks
Thanks
Re: Please help me to build an exe or com file under linux
[stupid post deleted.]
Last edited by Solar on Thu Mar 03, 2011 8:59 am, edited 1 time in total.
Every good solution is obvious once you've found it.
Re: Please help me to build an exe or com file under linux
nasm source_file -o file.com since bin is default output format.
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
Re: Please help me to build an exe or com file under linux
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.
[Side note: bin is not the default output format. Use -f bin to output flat binary]
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Please help me to build an exe or com file under linux
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
@sidenote, please note "(`*' denotes default):" and " * bin flat-form binary files (e.g. DOS .COM, .SYS)" lines
Re: Please help me to build an exe or com file under linux
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
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Please help me to build an exe or com file under linux
Hi,
Cheers,
Brendan
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
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
-
- Member
- Posts: 255
- Joined: Tue Jun 15, 2010 9:27 am
- Location: Flyover State, United States
- Contact:
Re: Please help me to build an exe or com file under linux
And if you want to make a PE file, just compile a binutils that can take win32 or coff object files and output PE files. Then use nasm -f win32 file.asm and link the generated object file.
Re: Please help me to build an exe or com file under linux
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
Hence, a simple assumption of OP's environment cannot be made because he is bound to be under such limitations if he wants to target a COM file.
The main point here, is that there's more to do with the code itself rather than the switch .
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Re: Please help me to build an exe or com file under linux
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 .