I need to use the LINK macro to call a program with 3 parameters, and my code must support re-entrant, so I believe I must do the following 4 things:
1. Use the list form of LINK to define a "template" in the literals area;
2. Reserve a block of space in the work area of my module;
3. Copy the "template" to the reserved block;
4. Use the execute form of LINK;
The code snippet below is a simplified version of my module:
MVC WORK_PLIST,TEMP_PLIST
LINK EP=BPXWDYN, +
PARAM=(PARM1,PARM2,PARM3),VL=1, +
MF=(E,WORK_PLIST)
* ...literals begin here...
TEMP_PLIST DS 0H
LINK EP=BPXWDYN,SF=L
TEMP_PLISTL EQU *-TEMP_PLIST
* ...work area's definition begins here...
WORKAREA DSECT
WORK_PLIST DS CL(TEMP_PLISTL)
WORKAREA EQU *-WORKAREA
The code doesn't work. When I checked the listing, I noticed that the parameter list doesn't look right at all. The following is the listing:
2017 LINK EP=BPXWDYN, +
PARAM=(PARM1,PARM2,PARM3),VL=1, +
MF=(E,WORK_PLIST)
2023+ LA 1,WORK_PLIST LOAD PARAMETER REG 1 03-IHBINNRA
2024+ LA 14,PARM1 PICKUP PARAMETER 02-IHBOPLST
2025+ LA 15,PARM2 PICKUP PARAMETER 02-IHBOPLST
2026+ LA 0,PARM3 PICKUP PARAMETER 02-IHBOPLST
2027+ STM 14,0,0(1) STORE INTO PARAM. LIST 02-IHBOPLST
2030+ OI 8(1),X'80' SET LAST WORD BIT ON @G860P40 02-IHBOPLST
2033+ CNOP 0,4 02-IHBINNRB
2034+ BRAS 15,*+20 BRANCH AROUND CONSTANTS 02-IHBINNRB
2035+ DC A(*+8) ADDR. OF PARM. LIST 02-IHBINNRB
2036+ DC A(0) DCB ADDRESS PARAMETER 02-IHBINNRB
2037+ DC CL8'BPXWDYN' EP PARAMETER 02-IHBINNRB
2038+ SVC 6 ISSUE LINK SVC @G381P2A 01-LINK
...........
2100 TEMP_PLIST DS 0H
2101 LINK EP=BPXWDYN,SF=L
2105+ CNOP 0,4 02-IHBINNRB
2106+ DC A(*+8) ADDRESS OF EP PARAMETER 02-IHBINNRB
2107+ DC A(0) DCB ADDRESS PARAMETER 02-IHBINNRB
2108+ DC CL8'BPXWDYN' EP PARAMETER 02-IHBINNRB
2109 TEMP_PLISTL EQU *-TEMP_PLIST
As I understand the listing, it only generated one A field for the parameters in the "template", however, in the executable code, it used "STM" instruction to directly write the 12 bytes (R14/R15/R0) into the parameter list block, so the 12 bytes should be placed from the first "DC A(*+8)" until half of the "DC CL8'BPXWDYN'". It obviously scewed it up.
I think that is because I misused the list form of the LINK macro. However, I read tht document several times, didn't sort out how to tell the list form how many parameters I will use.
Could you please give me some hints, or some example code of using the LINK macro in re-entrant-able way?
Many thanks!!