www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/09/28/11:08:40

Date: Thu, 28 Sep 1995 15:54:48 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: "A.Appleyard" <A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk>
Cc: DJGPP AT SUN DOT SOE DOT CLARKSON DOT EDU
Subject: Re: How to get command-line args?

On Tue, 26 Sep 1995, A.Appleyard wrote:

>   If I write a program QAZAQ.EXE or QAZAQ.COM in machine code (assembler), if
> I call it with arguments from the DOS prompt e.g. by typing
>       QAZAQ 123 \MYFILE.TXT "the cat caught the mouse" 1.65e-34
>   how can the program QAZAQ read these call arguments?

Call Interrupt 21h, function 51h or 62h (both do the same).  They'll 
return the PSP segment in BX register (the offset is always zero).  At 
offset 80h in that segment you'll find a single byte which gives you the 
length of the command-line tail (after the program name was stripped).  
Starting at offset 81h, you'll find N characters of the command-line 
tail, where N is given by the length byte.

You will have to parse the arguments yourself; in particular, quoted 
arguments aren't different from unquoted ones, and the command line ends 
with a CR.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019