I am trying to work on an array program to understand the concepts of array processing in Assembler.
Given below is the array program to add the numbers in an array.
* ADD NUMBERS IN AN ARRAY
ADDARR CSECT
BALR 12,0
USING *,12
USING TNUMSECT,6
BAL 11,ADDRTN
WTO 'DISPLAY1'
OPEN (OUTDCB,(OUTPUT))
UNPK OUTNUM,TOT
OI OUTNUM+1,X'F0'
PUT OUTDCB,OUTAREA
WTO 'DISPLAY9'
CLOSE (OUTDCB)
B EXIT
ADDRTN ST 11,ADDSAVE
WTO 'DISPLAY2'
LA 6,TNUMTABL
LA 3,ENUM#ENT
MOREENT DS 0H
WTO 'DISPLAY3'
AP TOT,TNUMCODE
LA 6,ENUMLEN(,6)
BCT 3,MOREENT
ADDEXIT DS 0H
WTO 'DISPLAY4'
L 11,ADDSAVE
BR 11
EXIT L 13,SAVE+4
WTO 'DISPLAY10'
LM 14,12,12(13)
WTO 'DISPLAY11'
XR 15,15
WTO 'DISPLAY12'
BR 14
WTO 'DISPLAY13'
* DECLARATIONS
ADDSAVE DC F'0'
SAVE DS 18F
TOT DC PL2'0'
OUTDCB DCB DSORG=PS,MACRF=(PM),DDNAME=TESTOUT, X
RECFM=FB,LRECL=80,BLKSIZE=0
OUTAREA DS 0CL80
OUTNUM DS CL2
FILLER1 DS CL78' '
* TABLE DECLARATION
TNUMTABL DS 0H
DC PL2'15'
ENUMLEN EQU (*-TNUMTABL)
DC PL2'12'
DC PL2'09'
DC PL2'16'
DC PL2'05'
ENUMTLEN EQU (*-TNUMTABL)
ENUM#ENT EQU (ENUMTLEN/ENUMLEN)
* DSECT ENTRY FOR TABLE
TNUMSECT DSECT
TNUMENTY DS 0PL2
TNUMCODE DS PL2
ENUMENTY EQU (*-TNUMSECT)
END
ADDARR CSECT
BALR 12,0
USING *,12
USING TNUMSECT,6
BAL 11,ADDRTN
WTO 'DISPLAY1'
OPEN (OUTDCB,(OUTPUT))
UNPK OUTNUM,TOT
OI OUTNUM+1,X'F0'
PUT OUTDCB,OUTAREA
WTO 'DISPLAY9'
CLOSE (OUTDCB)
B EXIT
ADDRTN ST 11,ADDSAVE
WTO 'DISPLAY2'
LA 6,TNUMTABL
LA 3,ENUM#ENT
MOREENT DS 0H
WTO 'DISPLAY3'
AP TOT,TNUMCODE
LA 6,ENUMLEN(,6)
BCT 3,MOREENT
ADDEXIT DS 0H
WTO 'DISPLAY4'
L 11,ADDSAVE
BR 11
EXIT L 13,SAVE+4
WTO 'DISPLAY10'
LM 14,12,12(13)
WTO 'DISPLAY11'
XR 15,15
WTO 'DISPLAY12'
BR 14
WTO 'DISPLAY13'
* DECLARATIONS
ADDSAVE DC F'0'
SAVE DS 18F
TOT DC PL2'0'
OUTDCB DCB DSORG=PS,MACRF=(PM),DDNAME=TESTOUT, X
RECFM=FB,LRECL=80,BLKSIZE=0
OUTAREA DS 0CL80
OUTNUM DS CL2
FILLER1 DS CL78' '
* TABLE DECLARATION
TNUMTABL DS 0H
DC PL2'15'
ENUMLEN EQU (*-TNUMTABL)
DC PL2'12'
DC PL2'09'
DC PL2'16'
DC PL2'05'
ENUMTLEN EQU (*-TNUMTABL)
ENUM#ENT EQU (ENUMTLEN/ENUMLEN)
* DSECT ENTRY FOR TABLE
TNUMSECT DSECT
TNUMENTY DS 0PL2
TNUMCODE DS PL2
ENUMENTY EQU (*-TNUMSECT)
END
When I am running this program, I am able to see the result in the output file but the job abends with S0C1 abend.
Below is the output file.
****** ***************************** Top of Data ******************************
000001 57
****** **************************** Bottom of Data ****************************
000001 57
****** **************************** Bottom of Data ****************************
I am able to see the display till DISPLAY10 in spool but not able to see the displays later on which means there is a problem with the statement LM 14,12,12(13) .
Could you help me out in understanding if we need to add anything specific when working with arrays?
Thank you.