Hassan Yousuf
Hassan Yousuf

Reputation: 731

DOSBox - This program cannot be run in dos mode (Assembly)

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?

Upvotes: 5

Views: 36812

Answers (3)

3442
3442

Reputation: 8576

You're receiving this error message because you're attempting to run the Windows version of the nasm binary on a virtual MS-DOS platform. This isn't supported. Instead, you should download and use the MS-DOS nasm binary.

Explanation: When you see the details of the Portable Executable Format (the internal format of .exe, .dll, and some .com files), you'll come across the MS-DOS stub header. This header's primary function is to display the message "This program cannot be run in DOS mode" when executed on 16-bit real mode operating systems like MS-DOS. This message serves as a warning to the user that the program they're trying to run is incompatible with their current system.

Upvotes: 10

Vladivarius
Vladivarius

Reputation: 518

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.

Upvotes: 1

Nikolay
Nikolay

Reputation: 1

Probably you are doing so called console application. It runs on console, but requires Windows 95 or never under the hood, mainly for fat32 support.

Upvotes: -7

Related Questions