View previous topic :: View next topic
|
Author |
Message |
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Is this CICS or Batch?
Bill |
|
Back to top |
|
|
satish.ms10
Active User
Joined: 10 Aug 2009 Posts: 184 Location: India
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|