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 

Declaring DCB macros for Re-entrant program

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


Joined: 16 May 2005
Posts: 9
Topics: 2
Location: Somewhere on Earth.. :-)

PostPosted: Mon Oct 09, 2006 10:25 am    Post subject: Declaring DCB macros for Re-entrant program Reply with quote


Hi all,
What are the things need to be taken care while coding the DCB paramenters in reentrant program?? I hope we cannot declare the DCB macro in reentrant pgm that has AMODE of 31 & RMODE of ANY. I searched in the IBM manuals (DFSMS Using Datasets) but not able to understand clearly?? It will be great if any one can provide the sample code..

Note: I've started learning the assembler recently and i have created a re-entrant program that will do the multi-tasking with the help of ATTACH macro. Currently, i've allocated the SAVEAREA dynamically with the help of GETMAIN.

Please throw some light on this.... Laughing




Regards,
Guru

Every bit is sacred, Every bit is right.
If a bit is wasted, I can't sleep at night.
Every bit is gorgeous,Every bit is free.
Admire the shape it forges, In hex and BCD!
Back to top
View user's profile Send private message Yahoo Messenger
bablack
Beginner


Joined: 04 Dec 2002
Posts: 71
Topics: 0
Location: Little Falls, NJ

PostPosted: Mon Oct 16, 2006 1:10 pm    Post subject: Reply with quote

Two issues:

First, the DCB gets modified by OPEN and CLOSE so it can't be within a reentrant program.
Second, the DCB must be in 24-bit storage (below the line) so it can't be within a RMODE ANY program even if non-reentrant.

The solution to both is to GETMAIN an area with LOC=24 and move the DCB into the area. Then OPEN the copy of the DCB.
_________________
Bruce A. Black
Senior Software Developer
Innovation Data Processing
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mmprasadh
Beginner


Joined: 16 May 2005
Posts: 9
Topics: 2
Location: Somewhere on Earth.. :-)

PostPosted: Tue Oct 17, 2006 12:19 am    Post subject: Reply with quote

Hi bruce,
Thanx for the reply.. Actually i googled and found an example of how to take care about the DCB while coding the reentrant program. Below is the pgm for the same. Actually this is the firt time am trying to write a reentrant program. So, don't know how to start. Now i am reading the 'ASM Auth., service guide' to continue to explore...
Code:

F2F2 CSECT
F2F2 AMODE 31
F2F2 RMODE ANY
STM 14,12,12(13)
LR 12,15
USING F2F2,12
* get save area and add to chain
GETMAIN R,LV=72,LOC=(31)
ST 13,4(1)
LR 13,1
* get storage below the line and copy DCBs, etc.
GETMAIN R,LV=SIZE_T,LOC=(24)
LR 11,1
USING WORKAREA,11
MVC IN(SIZE_INDCB),INDCB
MVC OUT(SIZE_OUTDCB),OUTDCB
MVC OPENWK(SIZE_OPN),OPENS
MVC CLOSWK(SIZE_CLO),CLOSES
* get storage for records
GETMAIN R,LV=100,LOC=(31)
LR 3,1
* OPEN; note MF parameter
OPEN (IN,,OUT,(OUTPUT)),MF=(E,OPENWK)
* main logic
LOOP DS 0H
GET IN,(3)
PUT OUT,(3)
B LOOP
DONE DS 0H
CLOSE (IN,,OUT),MF=(E,CLOSEWK)
LR 1,3
FREEMAIN R,LV=100,A=(1)
LR 1,11
FREEMAIN R,LV=SIZE_T,A=(1)
LR 1,13
L 13,4(1)
FREEMAIN R,LV=72,A=(1)
LM 14,12,12(13)
SR 15,15
BR 14
* work areas and control blocks
INDCB DCB DDNAME=INDD,DSORG=PS,MACRF=GM, X
DCBE=IN_DCBE
SIZE_INDCB EQU *-INDCB
OUTDCB DCB DDNAME=OUTDCB,DSORG=PS,MACRF=PM, X
LRECL=100,RECFM=FB,DCBE=OUT_DCBE
SIZE_OUTDCB EQU *-OUTDCB
OPENS OPEN (,,),MF=L
SIZE_OPN EQU *-OPENS
CLOSES CLOSE (,,),MF=L
SIZE_CLO EQU *-CLOSES
SIZE_TOT EQU *-INDCB
IN_DCBE DCBE RMODE31=BUFF,EODAD=DONE
OUT_DCBE DCBE RMODE31=BUFF
WORKAREA DSECT
IN DS XL(SIZE_INDCB)
OUT DS XL(SIZE_OUTCDB)
OPENWK DS XL(SIZE_OPN)
CLOSWK DS XL(SIZE_CLO)
F2F2 CSECT
END F2F2

Regards,
Guru

Every bit is sacred, Every bit is right.
If a bit is wasted, I can't sleep at night.
Every bit is gorgeous,Every bit is free.
Admire the shape it forges, In hex and BCD!
Back to top
View user's profile Send private message Yahoo Messenger
bablack
Beginner


Joined: 04 Dec 2002
Posts: 71
Topics: 0
Location: Little Falls, NJ

PostPosted: Tue Oct 17, 2006 8:59 am    Post subject: Reply with quote

The key to a reentrant program is that you don't store into the program, meaning that all variable storage has to be GETMAINed. Typically you will use a DSECT to map that storage area.

Warning, many IBM macros will generate a calling sequence with an inline parameter area and store into it. You need to use the MF=L form to generate a parameter area in your workarea, and the MF=(E,parm) form to use it reentrantly.

The RENT option of the assembler will warn you about any reentrant violations.
_________________
Bruce A. Black
Senior Software Developer
Innovation Data Processing
Back to top
View user's profile Send private message Send e-mail Visit poster's website
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