MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Assembler Dynamic Call .. Same copy of storage area

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
k_sharma
Beginner


Joined: 14 Aug 2003
Posts: 10
Topics: 3
Location: Dallas, US

PostPosted: Tue Jan 04, 2005 5:41 pm    Post subject: Assembler Dynamic Call .. Same copy of storage area Reply with quote

Hi
When we call any program dynamically from Assembler program through LINK or LOAD+CALL, it always use the refreshed copy of called module. So if we have set some switched in called program, they all will be refreshed.

Does somebody knows how we can use the same copy of called module by calling that module dynamically from Assembler.

Thanks
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12372
Topics: 75
Location: San Jose

PostPosted: Tue Jan 04, 2005 6:11 pm    Post subject: Reply with quote

K_sharma,

If you do a LOAD/LINK, the module will remain in storage after the program terminates.

Check this link for a detailed explanation of Load/Link macros

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2A630/CCONTENTS?DT=20020625111237


Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Wed Jan 05, 2005 12:08 pm    Post subject: Reply with quote

In order to use the same copy of a module via LINK the module in storage must be considered to be a usable copy. The only way that I know of to do this is to link the subroutine with the REUS attribute.

If you want to use the LOAD macro, you can save the address of the LOAD(ed) routine, and then instead of using LINK always issue a CALL using that address. LOAD puts the entry point address in Register zero. So after you do your LOAD you would do a ST R0,MYSUB and then in order to access this routine you'd do a L R15,MYSUB followed by a CALL (15),..........

Quote:
If you do a LOAD/LINK, the module will remain in storage after the program terminates.


This statement is unclear to me. But what I think it means is that when the called routine is completed and returns control to the caller, that it remains in storage. This is true, and if you continue to issue LOADs and LINKs, you may end up with hundreds or thousands of copies of this program in storage. Eventually you'll run out of memory and get a S80A or some such abend.

So......... I think you should use one of the two methods illustrated above in order to use the same copy every time. Smile

Hope this helps
DTF
________
justin bieber fans


Last edited by dtf on Tue Feb 01, 2011 1:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
k_sharma
Beginner


Joined: 14 Aug 2003
Posts: 10
Topics: 3
Location: Dallas, US

PostPosted: Wed Jan 05, 2005 1:31 pm    Post subject: Reply with quote

Hi
Actually I made the second program as REUS only. But everytime, I am getting the fresh code of second program. I just tried to make 2 small program to check this fundamental out. See my 2 programs. PROG1 is assembler whereas PROG2 is cobol. I have set one counter in PROG2 to check whether its same copy is being used or different.


PROG1 CSECT
REGS
LINKREG EQU R14
BASEREG EQU R11
STM R14,R12,12(R13)
LR BASEREG,R15
USING PROG1,BASEREG
ST R13,SAVEREG+4
LR R2,R13
LA R13,SAVEREG
ST R13,8(R2)
LOAD EP=PROG2
ST R0,PROG2ADR
LA R3,10
LOOP DS 0H
L R15,PROG2ADR
BALR R14,R15
BCT R3,LOOP
L R13,SAVEREG+4
LM R14,R12,12(R13)
XR R15,R15
BR LINKREG
SAVEREG DS 18F
PROG2ADR DS F
END




IDENTIFICATION DIVISION.
PROGRAM-ID. PROG2.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WS-COUNTER PIC 99.
PROCEDURE DIVISION.
MAINLINE-ROUTINE.
ADD +1 TO WS-COUNTER.
DISPLAY 'CALL TO PROG2 MODULE ' WS-COUNTER.
GOBACK.


To my surprise, when I run this program, everytime I get the counter value as "01". It means it always use the fresh copy of PROG2

But If I write PROG1 in COBOL and call PROG2 as dynamic, it works good. means everytime it updates the counter.

As far as LINK concerns, it always take the fresh copy as I think it does LOAD internally everytime.


Thanks..
Back to top
View user's profile Send private message
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Thu Jan 06, 2005 1:32 pm    Post subject: Reply with quote

This is interesting. Here is a theory - - by having an assembler MAIN program, you have not established a cobol environment. As such, it maybe taking the COBOL atrtibute at compile time of RENT which could mean you aquire a new WORKING STORAGE for each execution, and could explain your result.

Try this: Write a COBOL program and name it PROG00. Have PROG00 call PROG01 (assembler), and see if you get the same result.

Let me know if this changes anything or not. I would also like to know if the called COBOL program has the RENT option set at compile. If the theory holds, I can tell you how to establish the COBOL environment for your Assembler mainline, and get past the problem. Smile

DTF
________
Premium V engine


Last edited by dtf on Tue Feb 01, 2011 1:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Fri Jan 07, 2005 12:45 pm    Post subject: Reply with quote

I played around with your sample program and was able to duplicate your problem. If you insert the following code in your assembler mainline, it should fix the problem. The first section of code should be at initialization and the second section of code should be before you terminate your program.

Code:

         LOAD  EP=IGZERRE             LE COBOL MODULE             
         ST    R0,@IGZERRE            SAVE EPA                     
         LA    R1,1                   INDICATE INITIALIZE         
         LR    R15,R0                 GO                           
         BASSM R14,R15                   INIT ENVIRONMENT         
         LTR   R15,R15                Q. INIT ACCOMPLISHED?       
         BNZ   ABENDIT                BIF NOT                     


Code:

         L     R15,@IGZERRE              COBOL ENVIRONMENT             
         LA    R1,2                      INDICATE TERMINATE           
         BASSM R14,R15                   GO DO IT                     
         DELETE EP=IGZERRE               REMOVE SERVICE ROUTINE       
         .
         .
 @IGZERRE DC    F'0'         
 ABENDIT  DS    0H                     
         ABEND 100,DUMP     

________
herbal store


Last edited by dtf on Tue Feb 01, 2011 1:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
dtf
Beginner


Joined: 10 Dec 2004
Posts: 110
Topics: 8
Location: Colorado USA

PostPosted: Tue Jan 11, 2005 11:07 am    Post subject: Reply with quote

K_sharma,

Curious if this solved your problem. Smile

DTF
________
silversurfer vaporizer


Last edited by dtf on Tue Feb 01, 2011 1:41 pm; edited 1 time in total
Back to top
View user's profile Send private message
k_sharma
Beginner


Joined: 14 Aug 2003
Posts: 10
Topics: 3
Location: Dallas, US

PostPosted: Tue Jan 11, 2005 5:52 pm    Post subject: Reply with quote

Hey dtf
Thanks. Even I tried something also. I tried out IBM utility ILBOSTP0. I think it has same functionality as IGZEERE. Just after calling this once, it working fine. This is amazing.

Thanks DTF very much.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group