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

Query on House keeping routine


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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: 2481
Location: Netherlands, Amstelveen

PostPosted: Thu May 20, 2010 4:26 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 20, 2010 4:37 pm
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
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
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu May 20, 2010 8:18 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top