Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

assembly

nasm

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?

like image 549
Hassan Yousuf Avatar asked Oct 31 '22 18:10

Hassan Yousuf


2 Answers

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 .exes, .dlls, and .coms (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.

like image 93
3442 Avatar answered Nov 08 '22 11:11

3442


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.

like image 45
Vladivarius Avatar answered Nov 08 '22 11:11

Vladivarius