What follows is a complete program to read the first record of a disk dataset. It illustraes the use of the TTRN to MBBCCHHR converion routine as well as a correct channel program to locate and read a record from disk.
READR1 CSECT
PUSH PRINT
PRINT NOGEN
CVT DSECT=YES
DCBD DSORG=QS,DEVD=DA
POP PRINT
READR1 CSECT
USING *,12
SAVE (14,12),,'READ TRACK 0 RECORD 1 &SYSDATE &SYSTIME'
LR 12,15 COPY ENTRY POINT ADDRESS TO REG 12
LA 15,SAVEAREA LOAD ADDRESS OF THE NW SAVE AREA
ST 15,8(,13) ADD THE NEW SAVE AREA TO THE
ST 13,4(,15) SAVE AREA CHAIN
LR 13,15 ESTABLISH THE NEW SAVE AREA POINTER
OPEN (EXCPDCB,INPUT) OPEN THE DCB
L 0,=X'00000100' LOAD THE TTRN INTO REG 0
L 1,DCBDEBAD-IHADCB+EXCPDCB LOAD THE ADDRESS OF THE DEB
LA 2,IOBSEEK LOAD ADDRESS OF IOBSEEK
* THE TTRN TO MBBCCHHR CONVERSION ROUTINE DESTROYS REGISTER 9 THROUGH
* 13, SO WE SAVE REGISTERS 8 THROUGH 13 IN THE SAVE AREA, COPY REGISTER
* REGISTER 13 TO REGISTER 8 BEFORE WE CALL THE CONVERSION ROUTINE, AND
* RESTORE REGISTER 8 THROUGH 13 FR OM THE SAVE AREA AFTER THE
* CONVERSION ROUTINE RETURNS
STM 8,13,12(13) SAVE REGISTERS 8 THROUGH 13 IN X
THE SAVE AREA
LR 8,13 COPY THE SAVE AREA POINTER TO REG 8
L 15,CVTPTR LOAD ADDRESS OF THE CVT
L 15,CVTPCNVT-CVTMAP(,15) LOAD ADDRESS OF THE TTRN TO X
MBBCCHHR CONVSERION ROUTINE
BASR 14,15 CONVERT TTRN TO MBBCCHHR
LM 8,13,12(8) RESTORE REGISTERS 8 THROUGH 13
MVI EXCPECB,0 RESET THE ECB
EXCP IOB READ THE RECORD
WAIT 1,ECB=EXCPDCB WAIT FOR THE I/O TO COMPLETE
CLOSE EXCPDCB CLOSE THE DCB
L 13,4(,13) LOAD ADDR OF THE PREVIOUS SAVE AREA
RETURN (14,12),T,RC=0 RESTORE REGISTERS AND RETURN
SAVEAREA DC 18F'0' SAVE AREA
PUSH PRINT
PRINT NOGEN
EXCPDCB DCB MACRF=E,DDNAME=INPUT DCB
POP PRINT
EXCPECB DC F'0' I/O ECB
* THE OPERATING SYSTEM ADDS A FULL SEEK COMMAND BEFORE THIS CHANNEL
* PROGRAM EXECUTES AS WELL AS A SET FILE MASK COMMAND TO RESTRICT
* THE COMMANDS IN THE REMAINDER OF THE CHANNEL PROGRAM.
* THE SEARCH ID EQUAL COMMAND CAUSES THE CONTROL UNIT TO READ THE
* TRACK TO THE NEXT COUNT AREA, THEN COMPARE THE STORAGE WITH THE
* RECORD ID PORTION OF THE COUNT AREA. IF THE COMPARE IS EQUAL, THE
* NEXT CCW IS SKIPPED. IF THE COMPARE IS NOT EQUAL, THE NEXT CCW IS
* EXECUTED.
READCCWS CCW X'31',IOBSEEK+3,X'40',5 SEARCH ID EQUAL
CCW X'08',READCCWS,0,0 TRANSFER IN CHANNEL IF ID X
WAS NOT EQUAL
CCW X'06',IOBUF,X'20',L'IOBUF READ DATA
IOB DC 0XL40'0',AL1(X'42',0,0,0),A(EXCPECB,0,0,READCCWS,EXCPDCB>
,0,0) IOB
IOBSEEK DC XL8'0' BMMCCHHR STORED HERE
LTORG , DEFINE THE LITERAL POOL
DC 0D'0'
IOBUF DS XL(32*1024) I/O BUFFER
END READR1