Author Topic: Coding a command to run under DOS16, WIN32 and WIN64  (Read 11944 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.

Offline alCoPaUL

  • Jr. Member
  • *
  • Posts: 5
Re: Coding a command to run under DOS16, WIN32 and WIN64
« Reply #2 on: February 16, 2022, 12:13:05 AM »
NASM itself is available to run in DOS16, Win32 and Win64 environments separately.

and the Win64 version can assemble DOS16, Win32 and Win64 assembly language sources.

NASM is also available in all Linux distros (correct me if I'm wrong) and also used in MacOS (it's installed by default in the Old Snow Leopard version even).

But if you wish to write codes that run flawlessly on Microsoft OSes, the best thing to use is to use their Microsoft Incremental Linker on an appropriate architecture (Win32 is usually on x86 build tools and Win64 is on x64 build tools) just to be sure.

and with this approach, most of the time you have to install the Runtimes for the version of the Microsoft SDK that you used, if you wrote a code under a lower SDK compared to the SDK that is meant to be used in their latest OS (e.g. printf() from C Runtime).

And Windows 11 with the latest Visual Studio got some funky libraries (.lib files) that are still have to be documented programmatically in the assembly language mindset.

Google is still lacking if you search string "assembly language windows 11".
« Last Edit: February 16, 2022, 12:44:02 AM by alCoPaUL »

 

SMF spam blocked by CleanTalk