Mail Archives: djgpp/1995/09/28/11:08:40
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 -