I am trying to understand calling a subprogram from a main program using assembler. However I am getting an error when Link-editing. I am trying to simulate a calculator using the program.
My main program is as below.
MAINPGM CSECT
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVE+4
LA 13,SAVE
STARTC L 15,=V(SUBPGM) LOAD SUB PROGRAM
ST 0,SUBADDR SAVE ADDESS OF SUBPGM IN REG 0
LA 1,PARMLIST POINT REG 1 TO PARMLIST
BALR 14,15 CALL SUBPGM
LTR 15,15 CHECK RETURN CODE IN REG 15
BZ EXIT
EXIT L 13,SAVE+4
LM 14,12,12(13)
XR 15,15
BR 14
* OTHER DECLARATIONS
SAVE DC 18F'0'
NUM1 DC PL6'150'
NUM2 DC PL3'200'
WCFUNC DC CL1'+'
* DECLARATIONS TO CALL SUBPROGRAM
SUBADDR DC F'0' SUBPROGRAM ADDRESS
* SET UP LINKAGE AREA
PARMLIST DS 0F
DC A(WCFUNC)
DC A(NUM1)
DC A(NUM2)
END
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVE+4
LA 13,SAVE
STARTC L 15,=V(SUBPGM) LOAD SUB PROGRAM
ST 0,SUBADDR SAVE ADDESS OF SUBPGM IN REG 0
LA 1,PARMLIST POINT REG 1 TO PARMLIST
BALR 14,15 CALL SUBPGM
LTR 15,15 CHECK RETURN CODE IN REG 15
BZ EXIT
EXIT L 13,SAVE+4
LM 14,12,12(13)
XR 15,15
BR 14
* OTHER DECLARATIONS
SAVE DC 18F'0'
NUM1 DC PL6'150'
NUM2 DC PL3'200'
WCFUNC DC CL1'+'
* DECLARATIONS TO CALL SUBPROGRAM
SUBADDR DC F'0' SUBPROGRAM ADDRESS
* SET UP LINKAGE AREA
PARMLIST DS 0F
DC A(WCFUNC)
DC A(NUM1)
DC A(NUM2)
END
My subprogram is as below.
SUBPGM CSECT
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVE+4
LA 13,SAVE
USING LNU1SECT,3
USING LNU2SECT,4
USING LFUNSECT,5
WTO 'S1'
INITIAL DS 0H
WTO 'S2'
LM 3,5,0(1)
MAINLINE DS 0H
WTO 'S3'
BAL 14,PROCRTN
PROCRTN DS 0H
CLI LFUNCT,F1
BE MULT
CLI LFUNCT,F2
BE ADD
CLI LFUNCT,F3
BE SUB
CLI LFUNCT,F4
BE DIV
B BADOP
MULT MP LNUM1,LNUM2
B GOODOP
ADD AP LNUM1,LNUM2
B GOODOP
SUB SP LNUM1,LNUM2
B GOODOP
DIV DP LNUM1,LNUM2
B GOODOP
GOODOP LA 15,GOODRET
B FINAL
BADOP LA 15,BADRET
FINAL EQU *
L 13,SAVE+4
LM 14,12,12(13)
LA 15,0
BR 14
* EQUATES
F1 EQU C'*'
F2 EQU C'+'
F3 EQU C'-'
F4 EQU C'/'
GOODRET EQU 0
BADRET EQU 4
* WORKAREA
SAVE DC 18F'0'
RES DC PL3'0'
* DSECTS
LNU1SECT DSECT
LNUM1 DS PL6
ENU1SECT EQU (*-LNU1SECT)
*
LNU2SECT DSECT
LNUM2 DS PL3
ENU2SECT EQU (*-LNU2SECT)
*
LFUNSECT DSECT
LFUNCT DS CL1
EFUNSECT EQU (*-LFUNSECT)
END
STM 14,12,12(13)
BALR 12,0
USING *,12
ST 13,SAVE+4
LA 13,SAVE
USING LNU1SECT,3
USING LNU2SECT,4
USING LFUNSECT,5
WTO 'S1'
INITIAL DS 0H
WTO 'S2'
LM 3,5,0(1)
MAINLINE DS 0H
WTO 'S3'
BAL 14,PROCRTN
PROCRTN DS 0H
CLI LFUNCT,F1
BE MULT
CLI LFUNCT,F2
BE ADD
CLI LFUNCT,F3
BE SUB
CLI LFUNCT,F4
BE DIV
B BADOP
MULT MP LNUM1,LNUM2
B GOODOP
ADD AP LNUM1,LNUM2
B GOODOP
SUB SP LNUM1,LNUM2
B GOODOP
DIV DP LNUM1,LNUM2
B GOODOP
GOODOP LA 15,GOODRET
B FINAL
BADOP LA 15,BADRET
FINAL EQU *
L 13,SAVE+4
LM 14,12,12(13)
LA 15,0
BR 14
* EQUATES
F1 EQU C'*'
F2 EQU C'+'
F3 EQU C'-'
F4 EQU C'/'
GOODRET EQU 0
BADRET EQU 4
* WORKAREA
SAVE DC 18F'0'
RES DC PL3'0'
* DSECTS
LNU1SECT DSECT
LNUM1 DS PL6
ENU1SECT EQU (*-LNU1SECT)
*
LNU2SECT DSECT
LNUM2 DS PL3
ENU2SECT EQU (*-LNU2SECT)
*
LFUNSECT DSECT
LFUNCT DS CL1
EFUNSECT EQU (*-LFUNSECT)
END
My subprogram has assembled well and the load is also present in the load library.
However when assembling main program I am getting the error shown below.
IEW2745S D80F ABEND 913-38 OCCURRED WHILE PROCESSING PARTITIONED DATA SET WITH PROCESSING PARTITIONED DATA SET WITH DDNAME SYSLIB.
IEW2453E 920D UNABLE TO PROCESS LIBRARY SYSLIB DURING AUTOCALL PROCESSING.
IEW2456E 9207 SYMBOL SUBPGM UNRESOLVED. MEMBER COULD NOT BE INCLUDED FROM THE DESIGNATED CALL LIBRARY.
IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION MAINPGM.
IEW2638S 5384 AN EXECUTABLE VERSION OF MODULE *NULL* EXISTS AND CANNOT BE REPLACED BY THE NON-EXECUTABLE MODULE JUST
CREATED.
IEW2453E 920D UNABLE TO PROCESS LIBRARY SYSLIB DURING AUTOCALL PROCESSING.
IEW2456E 9207 SYMBOL SUBPGM UNRESOLVED. MEMBER COULD NOT BE INCLUDED FROM THE DESIGNATED CALL LIBRARY.
IEW2650I 5102 MODULE ENTRY NOT PROVIDED. ENTRY DEFAULTS TO SECTION MAINPGM.
IEW2638S 5384 AN EXECUTABLE VERSION OF MODULE *NULL* EXISTS AND CANNOT BE REPLACED BY THE NON-EXECUTABLE MODULE JUST
CREATED.
Could you please help me out here in understanding if the problem is with the main program or the sub program ?
Thanks in advance.