The title of this topic is incorrect. Programs that use DCBs can be located above the line; the actual DCBs
be located below the line. Here is a complete copy program that is located above the line.
COPY31 CSECT
COPY31 AMODE 31
COPY31 RMODE ANY
USING *,12
USING WA,11
SAVE (14,12),,*
LR 12,15
LA 15,SAVEAREA
ST 15,8(,13)
ST 13,4(,15)
LR 13,15
LA 0,WASIZE
GETMAIN RU,LV=(0),LOC=(24,ANY)
LR 11,1
MVC OPARM,MASTOPEN
MVC INPUT,MASTIN
MVC OUTPUT,MASTOUT
LA 0,XLIST
STCM 0,B'0111',(DCBEXLST-IHADCB)+OUTPUT+1
LA 0,WAEXIT
ST 0,XLIST
MVI XLIST,X'80'+5
MVC WAEXIT,MASTEXIT
OPEN (INPUT,INPUT),MF=(E,OPARM)
OPEN (OUTPUT,OUTPUT),MF=(E,OPARM)
LA 0,EOFCODE
STCM 0,B'0111',(DCBEODAD-IHADCB)+INPUT+1
MVC EOFCODE,EOFBR
COPYLOOP GET INPUT
LR 2,1
PUT OUTPUT,(2)
B COPYLOOP
EOFBR B EOF
EOF MVC OPARM,MASTCLOS
CLOSE INPUT,MF=(E,OPARM)
CLOSE OUTPUT,MF=(E,OPARM)
LA 0,WASIZE
FREEMAIN RU,LV=(0),A=(11)
L 13,4(,13)
RETURN (14,12),T,RC=0
DC 0F'0'
MASTEXIT SAM31 ,
L 15,MASTADDR-MASTEXIT(,15)
BR 15
MASTADDR DC A(OPENEXIT)
SAVEAREA DS 18F'0'
MASTOPEN OPEN (*-*),MF=L
MASTCLOS CLOSE *-*,MF=L
MASTIN DCB DSORG=PS,MACRF=GL,DDNAME=INPUT,EODAD=*-*
MASTOUT DCB DSORG=PS,MACRF=PM,DDNAME=OUTPUT,EXLST=*-*
DC 0D'0'
LTORG ,
DROP ,
DC 0F'0'
USING *,15
I USING IHADCB,2
O USING IHADCB,3
OPENEXIT LHI 2,-(OUTPUT-INPUT)
AR 2,1
LR 3,1
MVC O.DCBRECFM,I.DCBRECFM
XC O.DCBBLKSI,O.DCBBLKSI
MVC O.DCBLRECL,I.DCBLRECL
BR 14
DROP ,
DC 0D'0'
WA DSECT
INPUTS DCB DSORG=PS,MACRF=GL,EODAD=*-*
INPUT EQU INPUTS,*-INPUTS
OUTPUTS DCB DSORG=PS,MACRF=PM,EXLST=*-*
OUTPUT EQU OUTPUTS,*-OUTPUTS
OPARMS OPEN (*-*),MF=L
OPARM EQU OPARMS,*-OPARMS
XLIST DS A
WAEXITS SAM31 ,
L 15,XADDR-WAEXITS(,15)
BR 15
XADDR DS A
WAEXIT EQU WAEXITS,*-WAEXITS
EOFCODE DS XL4
DS 0D
WASIZE EQU *-WA
DCBD DSORG=QS,DEVD=DA
END COPY31
topic.
There was a surprise found when developing the program. The DCB open exit for the OUTPUT DCB was entered with AMODE 24; I expected it to be entered AMODE 31, since the program is AMODE 31, so the entry stub in the below the line work area had to switch to AMODE 31 with the SAM31 (Set Addressing Mode 31) instruction before branching to the main exit code located above the line. The exit itself is a simplified version of the DCB setup proposed in the Sending Data, Fixing Problems topic since System Determined Blksize is a better solution.