DOSBox - This program cannot be run in dos mode (Assembly)
Solution 1
If you're executing nasm
inside of DOSBox, then what happens is pretty straightforward...
You've been lied by compatibility layers!
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.
Solution 2
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.
Related videos on Youtube
Hassan Yousuf
Updated on September 16, 2022Comments
-
Hassan Yousuf over 1 year
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?
-
3442 over 8 yearsBTW, what does this has to do with C++?
-