Hello,
I'm new in Assembler and trying to learn the first steps, so sorry for any bad coding conventions or practices...
I'm trying to code an assembler routine to just receive parameters from a PL1 program, write them to a file and return. Just to learn how to pass parameters.
The problem is that, on return to the PL1 program, when I try to PUT the parameters to sysprint I get a SC04. If, in the PL1 program, I remark the PUT statement after calling the assembler program everything runs ok with RC=0. But if I try to PUT to sysprint the parameters I get S0C4.
I tried also moving with MVC some values to the parameters in the ASM program and then PUT them to sysprint in the PL1 program, but I get S0C1. Again, if I remark the PUT then it ends ok.
Any help on what's wrong with my code or how to pass parameters between PL1 and ASM would be really appreciated. In fact I already checked other posts with examples of ASM programs called from COBOL or PL1, and I don't find any difference with my code.
Code:
* THIS SAMPLE PROGRAM WILL READ PARAMS FROM A PL1 CALLER PGM.
*
* PARAMETERS
* R08 BASED
PDSECT DSECT
PDDNAME DS CL8
POPERAT DS CL2
PRETCOD DS H
PRETMSG DS CL80
*
* START OF PROGRAM
TEST5 CSECT
LR 12,15 LOAD BASE ADDR OF MODULE
USING TEST5,12 SET BASE REGISTER
SAVE (14,12) SAVE CALLER REGISTERS
ST 13,BUFFSAVE+4 KEEP CALLER SAVE AREA
L 8,0(,1) GET PARAM ADDRESS
ST 8,BUFFR08 KEEP PARAM ADDRESS
LA 13,BUFFSAVE SET OUR SAVE AREA ADDR
*
* OPEN SYSOUT DATASET TO PRINT TRACE MESSAGES
OPEN (OUTDCB,(OUTPUT)) OPEN OUTPUT FILE
*
* GET PARAMETERS AND PRINT THEM FOR TRACE
PARAMS USING PDSECT,8
L 8,BUFFR08 RESTORE REG08
MVC BUFFOUT(8),PARAMS.PDDNAME
MVC BUFFOUT+9(2),PARAMS.POPERAT
PUT OUTDCB,BUFFOUT
L 8,BUFFR08
*
* END PGM ROUTINE
R_ENDPGM EQU *
MVC BUFFOUT(80),=CL80'ENDPGM ROUTINE'
PUT OUTDCB,BUFFOUT
CLOSE (OUTDCB) CLOSE OUTPUT FILE
L 13,BUFFSAVE+4 RESTORE CALLER AREA REG
RETURN (14,12),RC=0 RESTORE AND RETURN
*
*
*
* STORAGE AREA AND FILE DECLARES
*
* DCB DECLARATIONS
OUTDCB DCB DSORG=PS,MACRF=(PM),RECFM=FB, X
BLKSIZE=0,DDNAME=SYSOUT,LRECL=80
*
* WORKING BUFFERS
BUFFSAVE DS 18F REGISTERS SAVE AREA
BUFFR08 DS F REGISTER 08 SAVE
BUFFOUT DC CL80' ' OUTPUT BUFFER
*
END
Code:
ASMTST5 : PROC OPTIONS (MAIN) REORDER;
/*******************************************************************/
/* */
/* PROGRAM : ASMTST5 */
/* */
/* FUNCTION : */
/* TEST ASM CALLS */
/*******************************************************************/
DCL ONCODE BUILTIN;
ON ERROR
BEGIN;
PUT SKIP LIST('ONCODE:' || ONCODE);
END;
Try with the below code for house keeping instead of the one you've used in assembler code.
Code:
*
* STANDARD ENTRY
*
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVEAREA+4
LA 13,SAVEAREA
*
* STANDARD EXIT
*
L 13,SAVEAREA+4
LM 14,12,12(13)
XR 15,15
BR 14
*