Help with calling subprogram



High Level Assembler(HLASM) for MVS & VM & VSE

Help with calling subprogram

Postby monica1 » Thu Feb 09, 2017 11:09 am

Hi,

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


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


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.                                                              



Could you please help me out here in understanding if the problem is with the main program or the sub program ?

Thanks in advance.
monica1
 
Posts: 7
Joined: Mon Jan 16, 2017 8:27 am
Has thanked: 0 time
Been thanked: 0 time

Re: Help with calling subprogram

Postby Aki88 » Thu Feb 09, 2017 11:47 am

Hello,

monica1 wrote:...
...
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.                                                              



Could you please help me out here in understanding if the problem is with the main program or the sub program ?...


I am not very hot on Assembler, but from the error message you've shown - S913-038, there appears to be an access related issue.
Basically you do not have access to the SYSLIB dataset you've passed in your JCL. Kindly contact the site-support to get the correct SYSLIB dataset or procure access to it.

For your reference:

913
Explanation: The error occurred during processing of an OPEN macro instruction. This system completion code is accompanied by message IEC150I. Refer to the explanation of message IEC150I for complete information about the task that was ended and for an explanation of the return code in register 15.
Application Programmer Response: Respond as indicated in message IEC150I.
System programmer response: If the error recurs and the program is not in error, look at the messages in the job log for more information. Search problem reporting data bases for a fix for the problem. If no fix exists, contact the IBM Support Center. Provide the JCL and the program listing for the job.
Source: DFSMSdfp

38
An OPEN was issued for a RACF-protected data set on a DASD volume or a RACF-protected tape volume to which the caller was not authorized.


Hope this helps.
Aki88
 
Posts: 381
Joined: Tue Jan 28, 2014 1:52 pm
Has thanked: 33 times
Been thanked: 36 times

Re: Help with calling subprogram

Postby steve-myers » Thu Feb 09, 2017 6:15 pm

  • As AKI88 noted, you must resolve the link edit problem.
  • IBM provides a macro library with hundreds of macros that automate some programming tasks. For example -

    CALL SUBPGM,MF=(E,PARMLIST)

    rather than -

    L     15,=V(SUBPGM)            LOAD SUB PROGRAM              
    LA    1,PARMLIST               POINT REG 1 TO PARMLIST        
    BALR  14,15                    CALL SUBPGM
  • ST    0,SUBADDR                SAVE ADDESS OF SUBPGM IN REG 0

    The comment and the code do not match. Fix it. By the way, it is ADDRESS, not ADDESS
I see nothing obviously wrong with the code, other than it is much too complicated for the task.
steve-myers
Global moderator
 
Posts: 2105
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 243 times


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post