On 8/12/2011 12:11 PM, McKown, John wrote:
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
Almost certainly 144 bytes
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.
We cover that in our course "Developing Applications for z/OS UNIX",
which demonstrates working under the shell in Assembler, COBOL, PL/I
and C.
The Assembler is generally LE-compliant, and a lot of the work in all
the languages is done by calling C functions directly from the various
languages. Details at:
http://www.trainersfriend.com/UNIX_and_Web_courses/u520descr.htm
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
--
Kind regards,
-Steve Comstock
The Trainer's Friend, Inc.
303-393-8716
http://www.trainersfriend.com
* Special promotion: 15% off on all DB2 training classes
scheduled by September 1, taught by year end 2011
* Check out our entire DB2 curriculum at:
http://www.trainersfriend.com/DB2_and_VSAM_courses/DB2curric.htm