Joined: 14 Aug 2003 Posts: 10 Topics: 3 Location: Dallas, US
Posted: Tue Jan 04, 2005 5:41 pm Post subject: Assembler Dynamic Call .. Same copy of storage area
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.
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
Posted: Wed Jan 05, 2005 12:08 pm Post subject:
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.
Joined: 14 Aug 2003 Posts: 10 Topics: 3 Location: Dallas, US
Posted: Wed Jan 05, 2005 1:31 pm Post subject:
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.
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
Posted: Thu Jan 06, 2005 1:32 pm Post subject:
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.
Joined: 10 Dec 2004 Posts: 110 Topics: 8 Location: Colorado USA
Posted: Fri Jan 07, 2005 12:45 pm Post subject:
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
Joined: 14 Aug 2003 Posts: 10 Topics: 3 Location: Dallas, US
Posted: Tue Jan 11, 2005 5:52 pm Post subject:
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.
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