IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Calling a Subprogram


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 15, 2011 11:04 am
Reply with quote

I have written below mentioned test code for calling a subprogram.

Code:
L R15,=V(TESTPGM)                 
LA R1,ADDDATE                     
WTO 'SUBPROGRAM TESTPGM INVOKED'   
BALR R14,R15                       
WTO 'RETURNED FROM TESTPGM'       

ADDDATE  DC 0CL80     
OPERTN   DC CL3' '   
FILLER1  DC C' '     
ADD1     DC F'30'     
FILLER2  DC C' '     
ADD2     DC H'20'     
FILLER3  DC C' '     
RESULT   DC F'0'     
FILLER4  DC CL64' '   


I am getting SOC1 at the BALR instruction. The compilation of this program is successful . Please let me know anything else to be done while calling a subprogram. Thanks
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Jun 15, 2011 11:49 am
Reply with quote

You should never invoke other macros where you have done with your first WTO.

R1 is used by many macros and, in this case, WTO has used R1 and you have lost the addressability to the parameters to be passed to the called module.

Can you show the assembly listing? Is the PSW pointing at the BALR instruction?

Garry.
Back to top
View user's profile Send private message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 15, 2011 12:06 pm
Reply with quote

This is what I could find in Abend Dump,

Code:

* CALLING A SUBPROGRAM   
         L R15,=V(TESTPGM)
          LA R1,ADDDATE                 
          WTO 'SUBPROGRAM TESTPGM INVOKED
+         CNOP  0,4                     
+         BRAS  1,IHB0081A               
+         DC    AL2(30)                 
+         DC    B'0000000000000000'     
+         DC    C'SUBPROGRAM TESTPGM INVO
+                                       
+IHB0081A DS    0H                       
+         SVC   35                       
          BALR R14,R15                   
          WTO 'RETURNED FROM TESTPGM'   


Thanks a lot Gary. The prob is using the MACRO WTO before BALR instruction.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Jun 15, 2011 12:08 pm
Reply with quote

You're welcome - glad I could help.

It's GaRRy though, not GaRy....

Garry.
Back to top
View user's profile Send private message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 15, 2011 5:12 pm
Reply with quote

Hi Garry,

I am sorry ask this type questions. I tried to fidure out the reason but i couldn't find the issue.

Code:
* CALLING A SUBPROGRAM                       
         L R15,=V(TESTPGM)                   
         L R1,=A(OPERTN,ADD1,ADD2,RESULT)   
         BALR R14,R15               
         WTO 'RETURNED FROM TESTPGM'
BACK     RETURN (14,12),RC=0     
*                   
ADDFLD   DSECT       
OPERTNA  DC CL3' '   
FILLER1A DC C' '     
ADD1A    DC FL4'30' 
FILLER2A DC C' '     
ADD2A    DC HL2'20' 
FILLER3A DC C' '     
RESULTA  DC FL4'0'   
FILLER4A DC CL64' '


TESTPGM

Code:
         STM R14,R12,12(R13)   
         LA R14,SAVE18         
         ST R13,4(R0,R14)       
         ST R14,8(R0,R13)       
         LR R13,R14             
         LR R2,R1               
         WTO 'INSIDE TESTPGM'   
         L  R3,0(R0,R2)           
         MVC OPERTN,0(R3)         
         WTO 'AFTER MVC OPERTN'   
         L  R3,3(R0,R2)           
         MVC ADD1,0(R3)           
         WTO 'AFTER MVC ADD1'     

SAVE18   DS 18F
ADDDATE  DC 0CL80   
OPERTN   DC CL3' ' 
FILLER1  DC C' '   
ADD1     DC F'30'   
FILLER2  DC C' '   
ADD2     DC H'20'   
FILLER3  DC C' '   
RESULT   DC F'0'   
FILLER4  DC CL64' '


Job is abending with SOC4 after displaying the message 'INSIDE TESTPGM'.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Jun 15, 2011 5:33 pm
Reply with quote

Quote:
Job is abending with SOC4 after displaying the message 'INSIDE TESTPGM'.


At which instruction in which program is the PSW pointing when it gets S0C4? I see you don't show a RETURN from the called program? If this is missing the system will try to interpret the contents at SAVE18 as instructions....

Garry.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jun 15, 2011 5:34 pm
Reply with quote

Maybe I missed it, but I don't see CSECT addressability being established.

Also, I don't believe your PARMLIST for R1 is correct.

Instead -

Code:

         LA    R1,OPERTN             POINT TO 1ST-PARM
         ST    R1,PARMLIST           STORE IN PARMLIST
         LA    R1,ADD1                  POINT TO 2ND-PARM
         ST    R1,PARMLIST+4            STORE IN PARMLIST
         LA    R1,ADD2                  POINT TO 3RD-PARM
         ST    R1,PARMLIST+8         STORE IN PARMLIST
         LA    R1,RESULT                 POINT TO 4TH-PARM
         ST    R1,PARMLIST+12      STORE IN PARMLIST
         OI    PARMLIST+12,X'80'    INDICATE END-OF-PARMS
         LA    R1,PARMLIST            POINT TO PARMLIST
*
PARMLIST DS    XL16


Bill
Back to top
View user's profile Send private message
PeterHolland

Global Moderator


Joined: 27 Oct 2009
Posts: 2481
Location: Netherlands, Amstelveen

PostPosted: Wed Jun 15, 2011 5:38 pm
Reply with quote

Bill O'Boyle wrote:
Maybe I missed it, but I don't see CSECT addressability being established.

Bill


This TS is notorious for only supllying snippets of code.
Back to top
View user's profile Send private message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 15, 2011 5:40 pm
Reply with quote

I could see this message in JESMSGLG

TESTPGM ABENDED S0C4 AT 34+ DC C"OPEN OUTPUT FILE SUCCESS"

Job is abdending in called program.

I have established the addressability useing CSECT and also i have below to return back to calling program.
Code:

LM R14,R12,12(R13)   
BR R14               
Back to top
View user's profile Send private message
vinayknj

New User


Joined: 26 May 2008
Posts: 50
Location: Bangalore

PostPosted: Wed Jun 15, 2011 5:41 pm
Reply with quote

I could see this message in JESMSGLG

TESTPGM ABENDED S0C4 AT 34+ DC C"OPEN OUTPUT FILE SUCCESS"
But i haven't coded the line which is displayed above.

Job is abdending in called program.

I have established the addressability useing CSECT and also i have below to return back to calling program.
Code:

LM R14,R12,12(R13)   
BR R14               
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Jun 15, 2011 5:59 pm
Reply with quote

Bill,

The instruction
Code:
    L R1=A(P1,P2,P3,P4)
will genarate code whereby the ADCON addresses a group of addresses.

vinayknj

You may have established addressability but we can't see that 'cos you are only giving snippets of code. If you give the entire program(s) we can help more easily.

Your return from called program is suspect as you haven't first set R13 back to the caller's savearea. You are returning god-alone-knows-what from the called program's SAVEAREA instead of returning the values in the calling program's savearea. For this reason, you have unpredictable contents in R14 and then you try to RETURN there.

Garry.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Wed Jun 15, 2011 6:47 pm
Reply with quote

Garry,

In all my years, I have never done it this way.

But, the last address doesn't indicate end-of-parms (high-order bit is on).

I like rudimentary approaches, it keeps my sanity.... icon_wink.gif

Thanks,

Bill
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1193
Location: Dublin, Ireland

PostPosted: Wed Jun 15, 2011 7:50 pm
Reply with quote

Bill,

I noticed that it doesn't set the end-of-parms bit and I most certainly don't do it that way myself - I just threw in a quick Assembly to see whether it assembles OK or not.

Can't speak to my own sanity....

Garry.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Jun 16, 2011 6:16 am
Reply with quote

Unless you're specifically using the contents of R0 as an INDEX register, remove R0 and substitute it with a comma, because you really don't know what the value in R0 could be, unless of course, you're sure it's F'0'. The Assembler will recognize this comma as the omission of an INDEX register in the LOAD/STORE and other instructions -

Code:

         ST    R13,4(,R14)       
         ST    R14,8(,R13)         
         L     R3,0(,R2)   
         L     R3,3(,R2)       

Bill
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Thu Jun 16, 2011 6:43 am
Reply with quote

A correction. Use of R0 as an INDEX register informs the Assembler you've omitted this register. I've been using commas for years so the R0 thingy never dawned on me, unless I was using a non-R0 INDEX register.

I stand corrected.... icon_redface.gif

Bill
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jun 16, 2011 7:57 am
Reply with quote

Hello,

If you want to actually get your code working you need to post more complete/useful info from now on. Do not pick and choose what you think someone here could use.

For starters, post the complete code from beginning to end and the informational messages printed before and after this:
"TESTPGM ABENDED S0C4 AT 34+ DC C"OPEN OUTPUT FILE SUCCESS"

It i quite possible that your system has a diagnostic or abend module like ABEND-AID that is trying to help you isolate the problem.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Calling an Open C library function in... CICS 1
No new posts How to go into a subprogram in IBM De... IBM Tools 5
No new posts calling a JCl inside a JCL JCL & VSAM 3
Search our Forums:

Back to Top