Joined: 26 Apr 2022 Posts: 9 Location: United States
I have been taking an online Assembler course. I have an excellent instructor who has been dealing with a catastrophic health issue and has limited availability. All failure to comprehend are mine, not his.
have reviewed an older thread on this. I understand that R1 will hold the parameter and that the first two bytes hold the length of the parameter.
I am encountering two problems. It's possible that both are more of an output and formatting issue. The first certainly is.
I am using R10 to hold the address of the parm and R9 for the length of the parm.
You may notice a commented out "DS X'0000'" used to force a S0C1 abend so that I can display registers in the dump. I've used that, and R9 holds a '3' and R10 holds what I believe to be an address. So that's commented out here. I get a clean (RC=0, anyway) run.
I have an output file (FILEOUT) into which I want to write the length of the parameter and then the parameter value. The output isn't viewable. If in SDSF I do SET HEX ON then I see the length as 3C which is what I'd expect but I don't get a printable '3'. For debugging, I have a couple of PUTs that aren't meant to be in the final result.
And I don't see anything but garbage in the rest of the output record. In my first run I am passing JCL PARM='THE' so the length is 3. I want to see a the word 'THE' and otherwise blanks to the right of the 'E'.
Code:
PRINT ON,NODATA,NOGEN
* ------------------------------------------------------------------*
* *
APGM5 CSECT , COMMA REQUIRED IF COMMENT ON THIS STMT
SAVE (14,12) SAVE CALLER'S REGS
BASR R12,0 ESTABLISH
USING *,R12
* LA R11,2048
* LA R11,2048(R12,R11)
* ------------------------------------------------------------------*
* SAVE CALLER REGISTERS *
LA R2,SAVEAREA POINT TO MY LOWER-LEVEL SA
ST R2,8(,R13) FORWARD-CHAIN MINE FROM CALLER'S
ST R13,SAVEAREA+4 BACK-CHAIN CALLER'S FROM MINE
LR R13,R2 SET 13 FOR MY SUBROUTINE CALLS
* ------------------------------------------------------------------*
* *
* PROGRAM LOGIC *
* THE CONTENTS OF THE PARM PASSED VIA JCL ARE PLACED IN R1. *
* THE FIRST 2 BYTES (HALF-WORD) PROVIDE THE PARM LENGTH. *
* LOAD R1 INTO R10 SAVE IT SO IT ISN'T OVERLAID. *
* REG10 IS USED TO STORE THE ENTIRE PARM PASSED FROM JCL. *
* REG9 IS USED TO STORE THE LENGTH OF THE PARM. *
. . . . . . . . . . . . . . . . . . . . . . .
* ------------------------------------------------------------------*
* *
* GET STARTED *
STRTUP EQU *
*
L R10,0(R1) LOAD R10 WITH THE FULL PARM
* DO SO BEFORE OPEN AS OPEN WIPES R1
SR R9,R9 ZERO R9
LH R9,0(,R10) LOAD R9 WITH THE LENGTH OF THE PARM
LA R10,2(,R10) LOAD ADDRESS OF PARM'S FIRST BYTE
* DS X'0000' FORCE ABEND
OPEN (FILEOUT,(OUTPUT))
*
* VERIFY A PARM IS PASSED
LTR R9,R9
BZ NOPARM IF LENGTH IS 0 THEN BR TO NOPARM
* -----------------------------------------------------------*
MVC OUTREC,=CL133' ' MOVE SPACES TO OUTPUT RECORD
CVD R9,PARMLEN CONVERT PARM LENGTH TO PACKED DEC
PUT FILEOUT,PARMLEN
ZAP UNPKLEN,PARMLEN UNPACK PARM LENGTH
PUT FILEOUT,UNPKLEN
MVC LENPARM,EDLEN
ED LENPARM,UNPKLEN
MVC PARMOUT,R10 MOVE R10
PUT FILEOUT,OUTREC
B WRAPUP
* -----------------------------------------------------------*
NOPARM EQU *
MVC OUTREC,=CL133' ' MOVE SPACES TO OUTPUT RECORD
MVC PARMFLD,=CL100'NO PARAMETER SUPPLIED'
PUT FILEOUT,OUTREC
Code:
* -----------------------------------------------------------*
WRAPUP EQU *
L R13,SAVEAREA+4 POINT TO CALLER'S SAVE AREA
RETURN (14,12),RC=0 RESTORE CALLER'S REGS & RETURN
SAVEAREA DC 18F'0' AREA FOR MY CALLEE TO SAVE & RESTORE MY REGS
* ------------------------------------------------------------------*
* DATA AREAS *
*
DS F
PARMLEN DS D
UNPKLEN DS PL5
PARMFLD DS CL100
*
* ------------------------------------------------------------------*
* DEFINE EDITWORD
* 1 2 3 4 5 6
EDLEN DC X'402020202021' 3 DIGITS, NO DEC
*
* ------------------------------------------------------------------*
FILEOUT DCB DSORG=PS, X
MACRF=(PM), X
DEVD=DA, X
DDNAME=FILEOUT, X
RECFM=FB, X
LRECL=133
*
OUTREC DS 0CL133
DC CL5' '
LENPARM DS ZL6
DC CL5' '
PARMOUT DS CL100
DC CL17' '
********************** WRAP IT UP *********************************
LTORG
YREGS
END
//L.SYSLMOD DD DSN=KC03I71.ASM.LOAD,DISP=SHR
//L.SYSLIB DD DSN=KC03I71.ASM.LOAD,DISP=SHR
//L.SYSIN DD *
NAME JCLCONC1(R)
/*
Your problem is with handling of binary-to-zoned decimals.
This works..
Program call:
//GO EXEC PGM=TESTPGM,PARM='Kilroy was here'
Code:
l r10,0(r1)
- - - - - - - - - - - - - - - - - - - 4 Line(s) not
lh r9,0(r10) get length
cvd r9,dw length as packed decimal
mvc prtr(7),=c'length='
unpk prtr+7(4),dw unpack to zoned decimal
oi prtr+7+4-1,x'f0' make last digit readable
mvc prtr+12(5),=c'text='
bctr r9,0 machine length for execute
j *+10 jump to execute
mvc prtr+17(*-*),2(r10) model for copy text
ex r9,*-6 copy text
- - - - - - - - - - - - - - - - - - 13 Line(s) not
prtr dc cl140' '
dw ds d
Output:
length=0015 text=Kilroy was here
The length in this case is 15, so the CVD will store x'000000000000015C' in the dw field.
The UNPK will store x'F0F0F1C5', note the sign nibble in the last byte, which is why you need the OI instrunction to make it readable.
And no need to clear the register before a LH, the LH will do that anyway.