I really had a difficult time figuring this out. Of course, it was because I 
was searching incorrectly. But for we who program in HLASM, I thought it might 
be useful to mention the "registers at entry" to a program invoked from an UNIX 
shell. Which is done with the UNIX exec() call, and really is mainly documented 
here:
http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/BPXZB190/2.30

R13 points to a save area. But I don't really know if it is 72 bytes in length 
(like an old style SaveArea) or larger
R15 contains the EPA
R14 is the return address
R1 points to a parameter list of exactly 7 fullwords. These are 31 bit 
addresses.
+0 is a pointer to the number of arguments to the program. It is always at 
least F'1'.
+4 is a pointer to a list of pointers to fullwords. The list is as many 
addresses as there are arguments and contain the length of the corresponding 
argument
+8 is a pointer to a list of pointers to null terminated strings. The list is 
as many pointers are there are arguments. There is always at least one 
argument, which is the name of the program entered on the shell command line.
+12 is a pointer to the number of environment variables existing at the time 
the program is run.
+16 is a pointer to a list of pointers to fullwords. The list is as many 
addresses as there are environment variables and contain the length of the 
corresponding environment variable entry.
+20 is a pointer to a list of pointers to null terminated strings. The list is 
as many pointers as there are environment variables.
+24 is a pointer to the list itself, that is it points back to the +0 area. I 
don't know why this is here.

To process the arguments, you'd use code similar to:


          lr   r2,r1 save parm register
          l    r3,24(,r2) do a sanity check
          la  r3,0(,r3)
          cr r2,r3
          jne invalid_parm_list
          l   r3,0(,r2) load pointer to arg count
          l   r3,0(,r3) load argument count
          lm r4,r5,4(,r2) pointers to length / value
arglist ds 0h
          call doparm,((4),(5)),vl
          la r4,4(,r4) point to address of next argument's length
          la r5,4(,r5) point to address of next argument
          bct r3,arglist
...
doparm ds 0h
           stm r0,r15,saveregs
           l     r4,0(,r4) get actual length of argument
           l     r5,0(,r5) get actual address of argument
* at this point, r4 contains the length of the argument, including trailing 
x'00'
* and r5 points to the first byte of the argument.
* insert more code here
            lm   r0,r15,saveregs
            br   r14 return to caller

Hopefully of some interest to those here. Much easier to write UNIX code in C.





John McKown
Systems Engineer IV
IT

Administrative Services Group

HealthMarkets(r)

9151 Boulevard 26 * N. Richland Hills * TX 76010
(817) 255-3225 phone *
[email protected] * www.HealthMarkets.com

Confidentiality Notice: This e-mail message may contain confidential or 
proprietary information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. 
HealthMarkets(r) is the brand name for products underwritten and issued by the 
insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance 
Company(r), Mid-West National Life Insurance Company of TennesseeSM and The 
MEGA Life and Health Insurance Company.SM

Reply via email to