MVS: GETMAIN / FREEMAIN 
Author Message
 MVS: GETMAIN / FREEMAIN

How would one do a 'GETMAIN' and 'FREEMAIN' from a MVS batch program.
All the references I see do a 'EXEC CICS'. Code samples appreciated.

~shine

Sent via Deja.com http://www.*-*-*.com/
Before you buy.



Mon, 07 Oct 2002 03:00:00 GMT  
 MVS: GETMAIN / FREEMAIN
You can do this via an assembler program - I like the STORAGE macro,
which allows you to OBTAIN and RELEASE memory.  It also allows you to
specify above / below the line storage, and boundary alignments.

***********************************************************************
* OBTAIN STORAGE FOR THE REQUESTED LENGTH:                            *
***********************************************************************
OBTSTG   MVC   FULLWORD,PARMSLEN       LOAD LENGTH TO FULLWORD
         L     R6,FULLWORD             LOAD REQUESTED STORAGE LENGTH
         MVC   PARMADDR,=F'0'          INIT PARM ADDRESS
         STORAGE OBTAIN,LENGTH=(R6),ADDR=STGADDR,COND=YES,             X
               LOC=BELOW,BNDRY=DBLWD
         LTR   R15,R15                 GOOD STORAGE OBTAIN?
         BZ    OBTGOOD                 YES - BRANCH AROUND ERR PROCESS

and to release storage:

***********************************************************************
* RELEASE STORAGE STARTING AT THE GIVEN ADDRESS FOR REQUESTED LENGTH: *
***********************************************************************
RELSTG   MVC   STGADDR,PARMADDR        LOAD REQUESTED STORAGE ADDRESS
         MVC   FULLWORD,PARMSLEN       LOAD LENGTH TO FULLWORD
         L     R6,FULLWORD             LOAD REQUESTED STORAGE LENGTH
         STORAGE RELEASE,LENGTH=(R6),ADDR=STGADDR,COND=YES
         LTR   R15,R15                 GOOD STORAGE RELEASE?
         BZ    RELGOOD                 YES - BRANCH AROUND ERR PROCESS

Todd Lucas


Quote:
> How would one do a 'GETMAIN' and 'FREEMAIN' from a MVS batch program.
> All the references I see do a 'EXEC CICS'. Code samples appreciated.

> ~shine

> Sent via Deja.com http://www.deja.com/
> Before you buy.



Mon, 07 Oct 2002 03:00:00 GMT  
 MVS: GETMAIN / FREEMAIN

Quote:

> How would one do a 'GETMAIN' and 'FREEMAIN' from a MVS batch program.
> All the references I see do a 'EXEC CICS'. Code samples appreciated.

> ~shine

> Sent via Deja.com http://www.deja.com/
> Before you buy.

        YREGS                           MVS REGISTER-MACRO
        STM     R14,R1,REGSAVE          SAVE R14 THRU R1
        L       R0,=A(L'STGAREA)        LOAD STORAGE LENGTH
        GETMAIN RU,LV=(0),LOC=ANY       GET STORAGE, ANY LOCATION
        LR      R9,R1                   STORAGE ADDRESSABILITY
        USING   STGDSECT,R9             INFORM ASSEMBLER
        ST      R9,R9SAVE               SAVE STORAGE ADDRESS
        LR      R0,R9                   LOAD 'RECVING' ADDRESS
        L       R1,=A(L'STGAREA)        LOAD 'RECVING' LENGTH
        SR      R14,R14                 LOAD 'SENDING' ADDRESS
        LA      R15,X'40'               LOAD 'SENDING' LENGTH
        SLL     R15,24                  SHIFT TO HIGH-ORDER
        MVCL    R0,R14                  INITIALIZE STORAGE TO SPACES
        LM      R14,R1,REGSAVE          RESTORE R14 THRU R1
        XC      REGSAVE(72),REGSAVE     CLEAR REGISTER SAVEAREA
********
******** SOME PROCESSING IS DONE HERE
********
        STM     R0,R1,REGSAVE           SAVE R0 AND R1
        L       R0,=A(L'STGAREA)        LOAD STORAGE LENGTH
        L       R1,R9SAVE               LOAD STORAGE ADDRESS
        FREEMAIN RU,LV=(0),A=(1)        FREE THE STORAGE
        LM      R0,R1,REGSAVE           RESTORE R0 AND R1
        XC      REGSAVE(72),REGSAVE     CLEAR REGISTER SAVEAREA
        SR      R9,R9                   CLEAR FORMER DSECT BASE

REGSAVE DS      18F
R9SAVE  DS      F
STGDSECT DSECT
STGAREA DS      CL32768

HTH....

WOB

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 08 Oct 2002 03:00:00 GMT  
 MVS: GETMAIN / FREEMAIN


Quote:


> > How would one do a 'GETMAIN' and 'FREEMAIN' from a MVS batch
program.
> > All the references I see do a 'EXEC CICS'. Code samples appreciated.

> > ~shine

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

>         YREGS                           MVS REGISTER-MACRO
>         STM        R14,R1,REGSAVE          SAVE R14 THRU R1
>         L  R0,=A(L'STGAREA)        LOAD STORAGE LENGTH
>         GETMAIN RU,LV=(0),LOC=ANY  GET STORAGE, ANY LOCATION
>         LR R9,R1                   STORAGE ADDRESSABILITY
>         USING      STGDSECT,R9             INFORM ASSEMBLER
>         ST      R9,R9SAVE          SAVE STORAGE ADDRESS
>         LR      R0,R9                      LOAD 'RECVING' ADDRESS
>         L       R1,=A(L'STGAREA)   LOAD 'RECVING' LENGTH
>         SR      R14,R14                    LOAD 'SENDING' ADDRESS
>         LA      R15,X'40'               LOAD 'SENDING' LENGTH
>         SLL     R15,24                  SHIFT TO HIGH-ORDER
>         MVCL    R0,R14                     INITIALIZE STORAGE TO
SPACES
>         LM      R14,R1,REGSAVE             RESTORE R14 THRU R1
>         XC      REGSAVE(72),REGSAVE        CLEAR REGISTER SAVEAREA
> ********
> ******** SOME PROCESSING IS DONE HERE
> ********
>         STM        R0,R1,REGSAVE           SAVE R0 AND R1
>         L  R0,=A(L'STGAREA)        LOAD STORAGE LENGTH
>         L  R1,R9SAVE               LOAD STORAGE ADDRESS
>         FREEMAIN RU,LV=(0),A=(1)   FREE THE STORAGE
>         LM R0,R1,REGSAVE           RESTORE R0 AND R1
>         XC REGSAVE(72),REGSAVE     CLEAR REGISTER SAVEAREA
>         SR R9,R9                   CLEAR FORMER DSECT BASE

> REGSAVE    DS      18F
> R9SAVE  DS      F
> STGDSECT DSECT
> STGAREA    DS      CL32768

> HTH....

> WOB

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Tue, 08 Oct 2002 03:00:00 GMT  
 MVS: GETMAIN / FREEMAIN
I really appreciate your response but I was thinking something more in
the line of: call 'GETMAIN' using this that the-other. Is this possible?
Could I assemble your code into a subroutine that I could call? I'll
have to admit that this is a little out of my usual relm, I just an
inquisitive COBOL coolie sweating down in the data paddies.

Thanks

~shine



Quote:


> > How would one do a 'GETMAIN' and 'FREEMAIN' from a MVS batch
program.
> > All the references I see do a 'EXEC CICS'. Code samples appreciated.

> > ~shine

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

>         YREGS                           MVS REGISTER-MACRO
>         STM        R14,R1,REGSAVE          SAVE R14 THRU R1
>         L  R0,=A(L'STGAREA)        LOAD STORAGE LENGTH
>         GETMAIN RU,LV=(0),LOC=ANY  GET STORAGE, ANY LOCATION
>         LR R9,R1                   STORAGE ADDRESSABILITY
>         USING      STGDSECT,R9             INFORM ASSEMBLER
>         ST      R9,R9SAVE          SAVE STORAGE ADDRESS
>         LR      R0,R9                      LOAD 'RECVING' ADDRESS
>         L       R1,=A(L'STGAREA)   LOAD 'RECVING' LENGTH
>         SR      R14,R14                    LOAD 'SENDING' ADDRESS
>         LA      R15,X'40'               LOAD 'SENDING' LENGTH
>         SLL     R15,24                  SHIFT TO HIGH-ORDER
>         MVCL    R0,R14                     INITIALIZE STORAGE TO
SPACES
>         LM      R14,R1,REGSAVE             RESTORE R14 THRU R1
>         XC      REGSAVE(72),REGSAVE        CLEAR REGISTER SAVEAREA
> ********
> ******** SOME PROCESSING IS DONE HERE
> ********
>         STM        R0,R1,REGSAVE           SAVE R0 AND R1
>         L  R0,=A(L'STGAREA)        LOAD STORAGE LENGTH
>         L  R1,R9SAVE               LOAD STORAGE ADDRESS
>         FREEMAIN RU,LV=(0),A=(1)   FREE THE STORAGE
>         LM R0,R1,REGSAVE           RESTORE R0 AND R1
>         XC REGSAVE(72),REGSAVE     CLEAR REGISTER SAVEAREA
>         SR R9,R9                   CLEAR FORMER DSECT BASE

> REGSAVE    DS      18F
> R9SAVE  DS      F
> STGDSECT DSECT
> STGAREA    DS      CL32768

> HTH....

> WOB

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Sent via Deja.com http://www.deja.com/
Before you buy.


Tue, 08 Oct 2002 03:00:00 GMT  
 MVS: GETMAIN / FREEMAIN

Quote:

> I really appreciate your response but I was thinking something more in
> the line of: call 'GETMAIN' using this that the-other. Is this
possible?
> Could I assemble your code into a subroutine that I could call? I'll
> have to admit that this is a little out of my usual relm, I just an
> inquisitive COBOL coolie sweating down in the data paddies.

> Thanks

> ~shine

Two things:

01) There is a slight Boo-Boo in my FREEMAIN MACRO coding. Instead of
loading R1 with the R9SAVE fullword, just code A=R9SAVE (no parenthesis
around R9SAVE as it is NOT a register). If you use R1 in my example,
you'll get a S0C4, because the MACRO expansion clears R1 BEFORE issuing
the SVC 120. This is what happens when you go by your memory (what's
that ?) :-)

02) Are you running "LE" (Language Environment)? If so, check out the
Callable Service Routine "CEEGTST" (Get Heap Storage). Refer to Book
Manager at:

http://www.s390.ibm.com/bookmgr-cgi/bookmgr.cmd/library, Book CEEA3020
(SC28-1940-08)

========================================================================

If you just need storage for a STEP, an implicit FREEMAIN is done when
you're STEP completes. It would be mucho overhead to CALL the sub-
program numerous times to Get/Free Storage. I would imagine, you'd call
the sub-program once, get the storage address and return it to your
COBOL program ? Unless I don't understand, COBOL2 (or greater) Working-
Storage should be able to handle large chunks of data, unless this
request has some unique requirements. I trust you're NOT using this
storage for CICS ?

Rather than clutter up C.L.C. with ASSEMBLER stuff, E-Mail me off-line,
explaining exactly what you want to do with this storage. I'll try to
give you an answer sometime next week after Easter.

Regards,

WOB,
Atlanta

Sent via Deja.com http://www.deja.com/
Before you buy.



Tue, 08 Oct 2002 03:00:00 GMT  
 MVS: GETMAIN / FREEMAIN


Quote:
> You can do this via an assembler program - I like the STORAGE macro,
> which allows you to OBTAIN and RELEASE memory.  It also allows you to
> specify above / below the line storage, and boundary alignments.

***********************************************************************
Quote:
> * OBTAIN STORAGE FOR THE REQUESTED LENGTH:
*

***********************************************************************
Quote:
> OBTSTG   MVC   FULLWORD,PARMSLEN       LOAD LENGTH TO FULLWORD
>          L     R6,FULLWORD             LOAD REQUESTED STORAGE LENGTH
>          MVC   PARMADDR,=F'0'          INIT PARM ADDRESS
>          STORAGE OBTAIN,LENGTH=

(R6),ADDR=STGADDR,COND=YES,             X
Quote:
>                LOC=BELOW,BNDRY=DBLWD
>          LTR   R15,R15                 GOOD STORAGE OBTAIN?
>          BZ    OBTGOOD                 YES - BRANCH AROUND ERR PROCESS

> and to release storage:

***********************************************************************
Quote:
> * RELEASE STORAGE STARTING AT THE GIVEN ADDRESS FOR REQUESTED LENGTH:
*

***********************************************************************

Quote:
> RELSTG   MVC   STGADDR,PARMADDR        LOAD REQUESTED STORAGE ADDRESS
>          MVC   FULLWORD,PARMSLEN       LOAD LENGTH TO FULLWORD
>          L     R6,FULLWORD             LOAD REQUESTED STORAGE LENGTH
>          STORAGE RELEASE,LENGTH=(R6),ADDR=STGADDR,COND=YES
>          LTR   R15,R15                 GOOD STORAGE RELEASE?
>          BZ    RELGOOD                 YES - BRANCH AROUND ERR PROCESS

> Todd Lucas



> > How would one do a 'GETMAIN' and 'FREEMAIN' from a MVS batch
program.
> > All the references I see do a 'EXEC CICS'. Code samples appreciated.

> > ~shine

> > Sent via Deja.com http://www.deja.com/
> > Before you buy.

The February 2000 edition of Enterprise System Journal had an article
about Language Environment. The article contained information, and code
examples, about getting and freeing storage in a COBOL program.

www.esj.com/fullarticle.asp?ID=3140051654PM

Sent via Deja.com http://www.deja.com/
Before you buy.



Wed, 09 Oct 2002 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. GETMAIN/FREEMAIN routines in MVS Cobol/370

2. DROP does FREEMAIN in TSO/REXX

3. GETMAIN

4. Getmain Help

5. GETMAIN

6. GETMAIN

7. GETMAIN ACROSS LINKAGE IN COBOL

8. GETMAIN limitations in COBOL??

9. Trace Cobol/MVS (LE/MVS) dynamic CALL

10. (MVS) Writing a REXX function in MVS C

11. MVS and MVS JCL Users Group/Info Sources

12. US - FL - S.E. ****MVS/CICS PROGRAMMERS (UNIX,MVS/TSO,ISPF,COBOL)****CONTRACT

 

 
Powered by phpBB® Forum Software