Since few weeks, I have been studying Assembly Language Programming, today I installed all the necessary applications to compile an assembly program.
I install DOSBox 0.74, NASM (Assembler), and AFD (Debugger). I mount the drive and see my .asm files correctly. But when I execute the following command:
nasm firstprogram.asm -o firstprogram.com
it gives me the following error: This program cannot be run in dos mode
But when I compile the file through command prompt (cmd) it compiles corrrectly and then I have to go to DOSBox to run AFD and debug the .com file.
Any idea why am I getting this error on DOSBox?
If you're executing nasm
inside of DOSBox, then what happens is pretty straightforward...
If you see the details of the Portable Executable Format (a.k.a: the internal format of .exe
s, .dll
s, and .com
s (those last used to use the Common Object File Format)), you'll notice there's something called the MS-DOS stub header. It's purpose is to display the message "This program cannot be run in DOS mode" on 16-bit real mode operating systems, such as MS-DOS, as to inform the user that the program is not compatible with the oldish system.
This means that you're running a Windows nasm
on a MS-DOS (virtual) platform. Try using the DOS binaries instead and you should be fine.
You downloaded the version that runs in Windows. When you open a directory of a specific version, there are subdirectories for various OS.
For example, here: https://www.nasm.us/pub/nasm/releasebuilds/2.12/
If you download the one from /dos folder you will be able to run it in DOSBox, however if you download the one in /win32 folder, you will only be able to run it from Windows.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With