Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Query on House keeping routine

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
yugendran

New User


Joined: 14 Dec 2007
Posts: 51
Location: indore

PostPosted: Thu May 20, 2010 4:11 pm    Post subject: Query on House keeping routine
Reply with quote

Hi Guys,

In house keeping,

Code:
STM   14,12,12(13)   Save GPRs @ entry
BALR   12,0      
USING    *,12         
ST   13,SAVE+4  Save GPR 13(Save area of OS) in 2nd full word
LA   13,SAVE      Passing save area address thru GPR 13 to SUB2
ST            13,SAVE+8   ( Is it required)             
Call to SUB
.
.
.
L   13,SAVE+4   Retrieve OS save area address
LM   14,12,12(13)   Restore GPRs 
BR   14      Return to OS
SAVE   DC   18F’0’

My Question:
1) ST 13,SAVE+8 ( Is it required)
Is it really required/optional, if optional what is the purpose of this and when will we use this?

2) Above code is main program, is it correct to say that we are saving GPRs @ entry into OS save area?

Pls correct me if i m wrong.

Thanks,
Yuge
Back to top
View user's profile Send private message

PeterHolland

Global Moderator


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

PostPosted: Thu May 20, 2010 4:26 pm    Post subject:
Reply with quote

LA 13,SAVE Passing save area address thru GPR 13 to SUB2
ST 13,SAVE+8 ( Is it required)

Yes, its required, so called/linked/system routines etc. programs can use that save area.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 20, 2010 4:37 pm    Post subject:
Reply with quote

While it is technically not a requirement to set up save area chaining with the code you question, it is a very good idea to do so. Why? Because some system routines assume proper save area chaining exists. If an abend occurs and the save area chain is not set up, a second abend occurs (and overlays the first) indicating a save area chain corruption. Then you cannot find out about the original abend problem because of the save area chain abend.
Back to top
View user's profile Send private message
Ronald Burr

Active User


Joined: 22 Oct 2009
Posts: 293
Location: U.S.A.

PostPosted: Thu May 20, 2010 5:47 pm    Post subject:
Reply with quote

Just an observation:

Your exit routine does an LM 14,12,12(13) to "restore GPRs". While there is nothing intrinsically wrong with that instruction, it will destroy ( restore the original contents of ) GPR 15, which is designed to contain the RETURN-CODE of the module. When R15 does NOT contain a value of ZERO upon exiting a module, depending on how the module was invoked, it may cause problems. If the module was CALLED by another module, the CALLING module may interpret a non-zero return code as meaning that the CALLED module detected an error; if invoked by the OS ( via JCL ) it may result in the setting of a high return code, or even an abend, for the step.

The exit routing I use most looks like this:
Code:
EXIT       L       R13,DSAVE+4           RESTORE CALLING REGS
           L       R14,12(R0,R13)
           L       R15,RETCOD            LOAD RETURN CODE
           LM      R0,R12,20(R13)
           BR      R14                   RETURN TO CALLING PROGRAM


where DSAVE is my program's save area and RETCOD is a fullword in which I set the programs return-code ( zero if all went well ).
Back to top
View user's profile Send private message
yugendran

New User


Joined: 14 Dec 2007
Posts: 51
Location: indore

PostPosted: Thu May 20, 2010 7:05 pm    Post subject:
Reply with quote

Good catch Ronald.. Thank you!!!
Back to top
View user's profile Send private message
yugendran

New User


Joined: 14 Dec 2007
Posts: 51
Location: indore

PostPosted: Thu May 20, 2010 7:24 pm    Post subject:
Reply with quote

Another Question:

HELLOTSO START 0
* PRINT NOGEN
BEGIN SAVE (14,12)
LR 12,15
USING TYPE,12
ST 13,SAVE+4 (It is saving the previous SA address in the current SA ie called program)
LA 11,SAVE
ST 11,8(13) (It is saving the current SA in the Prevoius SA ie calling program)
LR 13,11

I got this code in allinterview.com. As per this code, It is saving the current SA in the Prevoius SA ie calling program.

I am confused like SAVE+8 should contain the Next save area address or Current save area address?

Thanks
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

PostPosted: Thu May 20, 2010 8:18 pm    Post subject:
Reply with quote

Register 13 points to the save area of the calling program. SAVE is the save area for the called program. Storing register 13 in SAVE+4 establishes the backwards chain from the called program save area to the calling program save area. Storing the address of SAVE at the address pointed to by register 13 + 8 bytes establishes the forwards chain from the calling program save area to the called program save area. If your program calls another program, THAT program will store its save area address in SAVE+8 -- otherwise it will be not be initialized.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us