NASM Forum > Other Discussion

Coding a command to run under DOS16, WIN32 and WIN64


I'm sure I knew this once. I tried, but I don't even know what terms to search for. Can anyone point me in the right direction, please?

I want the same command name (a small compiler/interpreter assembled with NASM) to be available under Win64, WIN32, and DOS. I though I could use a .COM and a .EXE, but I checked my Win64 installation and it uses PATHEXT=.COM;.EXE;.PY;.CMD; etc. It starts (and fails) the .COM first.

Can anyone think of a way to have the same command file be able to start, which runs the correct version?
Or do I need 3 different versions such as myprog16,myprog32 and myprog64?

Many thanks in advance for clues.


You need only two different version of your program. One 16bit for DOS compiled to myprog16.exe, and one 32bit for Windows myprog.exe. When linking the Windows version, instruct the linker to use myprog16.exe as a stub file, instead of usual built-in stub which only says This program cannot be run in DOS mode.

Your program will work in DOS, Windows32 and Windows64 under the unified name myprog.exe.
As an example of such dual program see


[0] Message Index

Go to full version