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

Housekeeping activities in Assembler


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

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Wed May 12, 2010 8:13 pm
Reply with quote

Hi All,

Can anyone give some idea on Housekeeping activities in Assembler?

I means activities need to carried out in the beginning of the program and just before end of the program.

Kindly let me know why these activities need to carried out.

I would be very much thankful if you explain with some examples.

Thanks in advance.
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed May 12, 2010 8:22 pm
Reply with quote

no much philosophical difference between PL/1 and COBOL.
since your skills are COBOL (and PL/1), I imagine you can answer the question, yourself.
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: Wed May 12, 2010 8:27 pm
Reply with quote

Very similar to the COBOL prologue (assuming you've looked at the pseudo assembler generated by COBOL). Starting the program, you have to establish addressability for your program, set up save area linkage, and so forth. Ending the program, you have to restore registers, set the return code and any returned values before exiting.
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 May 12, 2010 8:39 pm
Reply with quote

Is this CICS or Batch?

Bill
Back to top
View user's profile Send private message
satish.ms10

Active User


Joined: 10 Aug 2009
Posts: 184
Location: India

PostPosted: Thu May 13, 2010 11:46 am
Reply with quote

Thank you all for your quick reply,

Hi Robert,

I have looked at pseudo assembler generated by COBOL/PL1 but I was not aware of Assembler so I couldn't understand what is happening there.

Now I have understand in the starting of a ASM program we need to
1. Establish addressability for the program
2. Set up save area linkage, and so forth.

And in ending the program,

1. Need to restore registers
2. Set the return code and any returned values

Could you please explain me above points by taking some sample code if available? then I will have some clear idea.

I am very sorry if I am troubling you with my questions.

Thanks in advance.
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 13, 2010 4:32 pm
Reply with quote

This is customized for some things I was doing, but start up code should look something like:
Code:
MF0119   CSECT
         REGEQU                       Use variables for registers for cross reference
         STM   R14,R12,12(R13)        Save registers in calling program save area
         LR    R12,R15                Save address of program
         USING MF0119,R12             Establish addressability
         LA    R15,SAVEAREA           Set up save area
         ST    R13,4(R15)             Forward save area chain
         ST    R15,8(R13)             Backwards save area chain
         LR    R13,R15                New save area
while the wrap up code can be something like
Code:
         L     R13,SAVEAREA+4     CALLING PROGRAM SAVE AREA
         XR    R15,R15            RETURN CODE ZERO
         RETURN (14,12),RC=(15)   MACRO TO RESTORE REGS, USING RC IN 15
Return is an IBM macro stored in SYS1.MACLIB typically.
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 13, 2010 4:53 pm
Reply with quote

see :

ibmmainframes.com/viewtopic.php?t=47046&highlight=initscc
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 May 13, 2010 5:54 pm
Reply with quote

For CICS/Assembler, the normal Prologue Code will perform most of your housekeeping as Robert has posted for Batch.

When returning to the Caller, set your R15 (this is a substitute for the RETURN Macro) and issue -

Code:

CICSPROG DFHEIENT CODEREG=R3,DATAREG=R13,EIBREG=R11
         XR    R15,R15             SET 'NORMAL' RETURN-CODE
CICSRETN EQU   *
         DFHEIRET RCREG=R15        RETURN TO CALLER
         END   

The DFHEIRET Macro will generate an internal FREEMAIN and free the previously acquired Dynamic-Stg (DFHEISTG) from the Prologue and return to the Caller, preserving R15, which can then be checked by the Caller. For COBOL Callers, R15 equates to the RETURN-CODE Special-Register.

For the most part, you can optionally substitute DFHEIRET for an EXEC CICS RETURN, but this should be confirmed.

Note: Be cautious with R12 because it contains the address of the Common Anchor Area (CAA) from the HLL Caller. I've gotten in the habit of using R3 instead and have left R12 "Off Limits".

Bill
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 Build dataset list with properties us... PL/I & Assembler 4
No new posts Finding Assembler programs PL/I & Assembler 5
No new posts How Can I Recall a Migrated Data Set ... PL/I & Assembler 3
No new posts step by step trace 4 ISPF dialog call... TSO/ISPF 17
No new posts Getting SOC4 while calling a Cobol DB... PL/I & Assembler 4
Search our Forums:

Back to Top