Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 2422
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: 7932
Location: Bellevue, IA

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: 7932
Location: Bellevue, IA

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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us