Author Topic: Coding a command to run under DOS16, WIN32 and WIN64  (Read 8437 times)

Offline rreynolds

  • Jr. Member
  • *
  • Posts: 2
Coding a command to run under DOS16, WIN32 and WIN64
« on: April 26, 2021, 07:09:41 PM »
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.

Roops

Offline vitsoft

  • Jr. Member
  • *
  • Posts: 13
  • Country: cz
    • About me
Re: Coding a command to run under DOS16, WIN32 and WIN64
« Reply #1 on: May 02, 2021, 02:06:34 PM »
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 https://euroassembler.eu/prowin32/locktest.htm.