1

Several years ago I used to write x86 assembly programs for MS-DOS operating system; most of them still run unmodified in Windows CMD.EXE command processor. My question is about two specific points in these programs:

  • The program parameters are located at offset 81H in the Program Segment Prefix and have a maximum lenght of 127 characters.

  • The ERRORLEVEL value that the program return is loaded in AL register prior to the Terminate Program function (4CH) of the INT 21H, so it is limited to values in the range 0-255.

I realized that in Windows XP the commands executed in a DOS window can process parameters of up to 8 KB size and may return a 32-bits signed value as ERRORLEVEL. So my question is: Is there a SIMPLE way that an old-style MS-DOS assembly program may have access to 8KB parameters and return 32-bits ERRORLEVEL values?

Yes, I know that a Windows-compliant assembly program have access to these features, but I wonder if a program could do that in a very simple way...

Aacini
  • 65,180
  • 12
  • 72
  • 108
  • 3
    MS-DOS (and other DOS variants) were restricted to these limits because of the OS itself, not because of the code, IIRC. As such (and since they're still running under a DOS emulation rather than as true Windows command-line/console apps), these restrictions can't be removed without a rewrite to make them true Windows apps, AFAIK. – Ken White Apr 12 '12 at 01:10
  • @KenWhite: Thanks for your answer. Is this rewrite very extensive? If not, could you post the simplest possible example of such program or a link to such example? – Aacini Apr 12 '12 at 03:23
  • @Aacini here's an example of a windows masm32 hello world: http://stackoverflow.com/q/4568306/309483 – Janus Troelsen Jul 28 '12 at 23:06

1 Answers1

0

Your 16-bit programs are running on 32-bit Windows due to NTVDM. More and more machines are getting 64-bit OS'es by default, and 64-bit Windows doesn't even have the NTVDM, so it won't work anymore.

I advise you to port your programs to 32 or 64-bit Windows.

After porting, access to the command line is easy. WinMain and main both have the command line as an argument.

Janus Troelsen
  • 20,267
  • 14
  • 135
  • 196