Page 1 of 1

addressability of a program

PostPosted: Tue Jan 29, 2008 8:21 am
by rahul2380
Hi, could anyone let know, how is the addressability of a called program set when we make a call for it. What all instructions are involved and how is the data of the calling program saved in savearea. Thanx

Re: addressability of a program

PostPosted: Wed Jan 30, 2008 3:10 am
by dick scherrer
Hello Rahul and welcome to the forums,

how is the addressability of a called program set when we make a call for it
When you call a sub-program, the addressability is done the same as when the main program is invoked by the operating system. This is usually known as the "standard linkage convention".

how is the data of the calling program saved in savearea
The caller's data is not saved in the savearea. The save area stores register content.

Re: addressability of a program

PostPosted: Thu Feb 21, 2008 9:46 pm
by tsjurseth
Since no one have helped you I will give this information.

The POPs manual is the king of manuals when dealing with assembler.
POP is the Principle of Operations.

The actual instructions are as follows and should be built into a startup macro.
This the from my days in the 370 market place.

an online version can be found here. http://publibz.boulder.ibm.com/cgi-bin/ ... 0504121320


Assembler codeing can begin in any collum other then 1. if its in col. 1 then its a label.

The called pgm must have the follwing instructions to follow the rules.
  stm  r14,r12,12(r13)        save the callers registers into the new pgms save area.  ( of couse this is non-reentrant)
  balr r12,0                        set addresserrablilty with r12 for use as base reg
  using *,r12                      give address ability to the next 4096 bytes with addressability
  st   r13,savearea+4         save the old savearea 4 into the new save area
  la   r13,savearea             load r13 with new savearea address
  st   r13,savearea+8         save new savearea address

your special code

to return to caller
 l    r13,4(r13)                restore the callers save area
 lm   r14,r12,12(r13)      restore the original registers from who called you
 br   r14                         return to caller
savearea 0d                   allign on double word boundary. 
 ds   18f   



Have at it. Any questions. TKS

Re: addressability of a program

PostPosted: Thu Feb 21, 2008 10:01 pm
by CICS Guy
tsjurseth wrote: stm r14,r12,12(r13) save the callers registers into the new pgms save area. ( of couse this is non-reentrant)
IIRC, r13 is pointing to a save area in the calling program, isn't it?
balr r12,0 set addresserrablilty with r12 for use as base reg
using *,r12 give address ability to the next 4096 bytes with addressability
Why use another register, isn't r15 already pointing to the entyry point?

Re: addressability of a program

PostPosted: Wed Mar 05, 2008 9:02 pm
by dickvb
tsjurseth wrote: stm r14,r12,12(r13) save the callers registers into the new pgms save area. ( of couse this is non-reentrant)

IIRC, r13 is pointing to a save area in the calling program, isn't it?


In the calling program or provided by the calling program, yes.
(It could well be "provided by" the calling program and be entirely re-entrant..)

balr r12,0 set addresserrablilty with r12 for use as base reg
using *,r12 give address ability to the next 4096 bytes with addressability


Why use another register, isn't r15 already pointing to the entyry point?


Yes, but if your module is going to do anything non-trivial, such as use any system or
I/O macros, R15 is going to get modified. Much safer, and more standard-observant,
to provide your own base register.

Re: addressability of a program

PostPosted: Wed Mar 05, 2008 10:05 pm
by CICS Guy
dickvb wrote:In the calling program or provided by the calling program, yes.
'Standard linkage'......
Yes, but if your module is going to do anything non-trivial, such as use any system or
I/O macros, R15 is going to get modified. Much safer, and more standard-observant,
to provide your own base register.
Correct, but I'd assumed the programmer would know that....grin.....