delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp-workers/1999/09/29/04:56:18

Date: Wed, 29 Sep 1999 10:29:51 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
X-Sender: eliz AT is
To: Laurynas Biveinis <lauras AT softhome DOT net>
cc: djgpp-workers AT delorie DOT com
Subject: Re: Help with arg passing
In-Reply-To: <37F0F288.25B90206@softhome.net>
Message-ID: <Pine.SUN.3.91.990929102924.11087N-100000@is>
MIME-Version: 1.0
Reply-To: djgpp-workers AT delorie DOT com
X-Mailing-List: djgpp-workers AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

On Tue, 28 Sep 1999, Laurynas Biveinis wrote:

> My questions are from direct_exec_tail() -

Here's my $0.02 worth of answers:

> 1) Is argv[0] passed together with other args ?

I'm not sure what argv[0] are you asking about: direct_exec_tail
doesn't have a variable by that name.  Below I'm assuming you were
asking about the `program' argument passed to direct_exec_tail.

What direct_exec_tail does is to put *both* the program name and the
rest of arguments into the transfer buffer.  However, they are passed
to DOS as separate strings, because function 4Bh needs the following
arguments:

  DS:DX -> program name
  ES:BX -> parameter block which includes:

	     - a pointer to the environment block
	     - a pointer to the command tail
	     - two pointers to the two standard FCBs

The "command tail" is the rest of the arguments beyond the program's
name, with a count of bytes prepended and the CR character appended.

The variables prog_la, parm_la, arg_la, fcb1_la, fcb2_la, and env_la
are linear addresses (inside the transfer buffer) where the above data
is copied.

> 2) Is argv[0] equal to exe's file name passed to DOS fn 0x4B?

No, direct_exec_tail generates the short 8+3 version of the file name
passed in `program', and passes that to DOS, because function 4Bh
requires an SFN.  Note the call to the function 7160h/CX=1 of Int 21h
near the beginning of direct_exec_tail.

> Where in the memory lives argv[0] and .exe name ?

Sorry, I don't understand this question.  The `program' argument
already has the .exe suffix attached to it when it is passed to
direct_exec_tail (assuming that we are going to execute a .exe
program; it might also be COMMAND.COM or some other extension).  This
is done by higher-level functions that search PATH and know about
executable suffixes.

> 3) If LFN is converted to SFN, which version (short or long) goes to argv[0]?

What is passed to DOS is the SFN, since 214B requires it.  What the
invoked program gets in its argv[0] (via !proxy), if it is a DJGPP
program, is the original LFN file name with its full path prepended.
A non-DJGPP program gets the SFN, since it has no other means of
getting at the command line except as passed by DOS.

- Raw text -


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