. Advertisement .
..3..
. Advertisement .
..4..
I am tired of fixing the problem: this program cannot be run in dos mode in the assembly; even if I get the reference from another forum, it still returns an error:
This program cannot be run in dos mode
To identify the problem, I will show you the detail here:
nasm firstprogram.asm -o firstprogram.com
How do I do that? Could you support me in improving this problem?
The cause:
Compatibility layers have lied to you!
You will see something called the MS-DOS stub header if you look at the specific description of the Portable Executable Format (a.k.a. is the internal format of
.exe
s;.dll
s, and.com
s are used to utilize the Common Object File Format). Its goal is to show the notice “this program cannot be run in DOS mode” on 16-bit real mode operating systems like MS-DOS, informing the user that the program does not match with the old system.It indicates that you’re using an MS-DOS (virtual) platform to run a Windows nasm. Therefore, the error happens.
Solution:
To solve this error, you should use the DOS binaries.
The version you downloaded runs under Windows. You will find subdirectories that correspond to different OS when you open a directory for a particular version.
For example, here: https://www.nasm.us/pub/nasm/releasebuilds/2.12/
You can run the file in DOSBox if it is downloaded from the /dos directory. However, if it’s downloaded in the /win32 folder it will only work in Windows.