	.TITLE *** TDV FUNCTION "DIRECTORY" FOR DECTAPE
/ 
/ 
/                   FIRST PRINTING, FEBRUARY 1974
/ 
/ THE INFORMATION IN THIS DOCUMENT IS SUBJECT TO 
/ CHANGE WITHOUT NOTICE AND SHOULD NOT BE CONSTRUED
/ AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPON-
/ SIBILITY FOR ANY ERRORS THAT MAY APPEAR IN THIS
/ DOCUMENT.
/ 
/ THE SOFTWARE DESCRIBED IN THIS DOCUMENT IS FUR-
/ NISHED TO THE PURCHASER UNDER A LICENSE FOR USE ON
/ A SINGLE COMPUTER SYSTEM AND CAN BE COPIED (WITH
/ INCLUSION OF DIGITAL'S COPYRIGHT NOTICE) ONLY FOR 
/ USE IN SUCH SYSTEM, EXCEPT AS MAY OTHERWISE BE PRO-
/ VIDED IN WRITING BY DIGITAL.
/ 
/ DIGITAL EQUIPMENT CORPORATION ASSUMES NO RESPONSIBILITY
/ FOR THE USE OR RELIABILITY OF ITS SOFTWARE ON EQUIP-
/ MENT THAT IS NOT SUPPLIED BY DIGITAL.
/ 
/ COPYRIGHT (C) 1974, BY DIGITAL EQUIPMENT CORPORATION
/ 
/ 
        .EJECT
/
/	EDIT #15	6 FEB 72	C. PROTEAU
/			28 APR 72	W.A. DESIMONE
/
/ COPYRIGHT 1971, 1972 DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS.
/
/ TDV (TASK DEVELOPMENT) FUNCTION, CALLED "DTD...", USED TO LIST INFORMATION
/ ABOUT THE FILES THAT EXIST ON A DECTAPE.
/
/////////////////////////////////////////////////
/						/
/ CALL:	TDV>DTD					/
/						/
/ SAMPLE DIRECTORY PRINTOUT:			/
/						/
/	DECTAPE UNIT 4				/
/	    31-DEC-71				/
/	  1004 FREE BLKS			/
/	     3 USER FILES			/
/	    10 SYSTEM BLKS			/
/	FILNAM EXT      1     15		/
/	TABLE  BIN      2     23		/
/	DTD.1  SRC      3     24		/
/						/
/////////////////////////////////////////////////
/
/ THERE ARE 1100 OCTAL BLOCKS ON A DECTAPE, AT LEAST 8 OF WHICH ARE
/ SYSTEM BLOCKS (BLOCKS 71 THRU 100 OCTAL, USED FOR FILE DIRECTORY
/ INFORMATION).
/
/ ALL NUMBERS, EXCEPT THE DATE, ARE PRINTED IN OCTAL.
/
/ IN THE PRINTOUT, EACH LINE ENTRY FOR A FILE CONSISTS OF FILE NAME,
/ FILE NAME EXTENSION, FIRST BLOCK NUMBER, AND THE FILE SIZE.
/
/ THERE ARE 2 TYPES OF DIRECTORY FORMAT. THE NORMAL FORMAT FOR BLOCK
/ 100 IS THAT THE FIRST 40 OCTAL WORDS IS THE MASTER BIT MAP FOR THE
/ TAPE FOLLOWED BY 340 OCTAL WORDS OF FILE ENTRIES. EACH FILE ENTRY
/ CONSISTS OF 4 WORDS, SO ON A NORMAL TAPE ONE CAN HAVE UP TO 70
/ OCTAL (56 DECIMAL) FILES. EACH FILE HAS A FILE BIT MAP OF 40 OCTAL
/ WORDS LOCATED IN A CORRESPONDING POSITION IN BLOCKS 71 THRU 77.
/ BLOCK 71 CONTAINS THE FIRST 8 FILE BIT MAPS, AND SO ON. A 1-BIT IN
/ THE BIT MAP INDICATES AN OCCUPIED BLOCK.
/
/ EACH FILE ENTRY OF 4 WORDS IS FORMATTED AS FOLLOWS:
/
/	WORD 0 -- .SIXBT "FIL"
/	WORD 1 -- .SIXBT "NAM"
/	WORD 2 -- .SIXBT "EXT"
/	WORD 3 -- STARTING BLOCK NUMBER IN BITS 8-17
/		  (BIT 0=1 FOR SYSTEM FILE ENTRIES (SEE BELOW))
/
/
/ THE SECOND FORMAT IS FOR A SYSTEM TAPE, ONE USED IN PDP-9/15 SYSTEMS
/ IN WHICH THE OPERATING SYSTEM PROGRAMS RESIDE ON THE DECTAPE IN CORE
/ IMAGE FORM. ON SUCH A TAPE, THE MASTER BIT MAP STILL OCCUPIES THE FIRST
/ 40 OCTAL WORDS OF BLOCK 100. THE NUMBER OF USER FILE ENTRIES IS CUT
/ DOWN TO 30 OCTAL (24 DECIMAL). THE SECOND HALF OF BLOCK 100 STARTS
/ WITH A 40 OCTAL WORD SYSTEM BIT MAP, CORRESPONDING TO THE BLOCKS
/ OCCUPIED BY ALL THE SYSTEM PROGRAMS.
/
/ THERE MAY BE UP TO 30 OCTAL SYSTEM FILE ENTRIES, EACH 4 WORDS LONG.
/ THERE IS NO CORRESPONDING FILE BIT MAP IN BLOCKS 71 THRU 77 FOR
/ SYSTEM FILE ENTRIES.
/
/ ******************** MASTER DIRECTORY BLOCK 100 **********************
/
/	NORMAL TAPE				SYSTEM TAPE
/	-----------				-----------
/
/	*****************			*****************
/	*		*			*		*
/	* 40 OCTAL WORD *			* 40 OCTAL WORD *
/	* MASTER BITMAP *			* MASTER BITMAP *
/	*		*			*		*
/	*****************			*****************
/	*		*			*		*
/	* 70 OCTAL	*			* 30 OCTAL	*
/	* 4-WORD USER	*			* 4-WORD USER	*
/	* FILE ENTRIES	*			* FILE ENTRIES	*
/	*		*			*		*
/	*		*			*****************
/	*		*			*		*
/	*		*			* 40 OCTAL WORD *
/	*		*			* SYSTEM BITMAP *
/	*		*			*		*
/	*		*			*****************
/	*		*			*		*
/	*		*			* 30 OCTAL	*
/	*		*			* 4-WORD SYSTEM *
/	*		*			* FILE ENTRIES	*
/	*		*			*		*
/	*****************			*****************
/
/	WORD 203 OCTAL CORRESPONDS		WORD 203 OCTAL IS PART OF
/	TO THE LAST WORD IN THE			THE SYSTEM BIT MAP. BIT 3
/	31ST FILE ENTRY. BIT 3 MUST		IN THE WORD CORRESPONDS
/	BE 0.					TO BLOCK 71, WHICH IS AL-
/						WAYS OCCUPIED. BIT 3 MUST
/						BE 1.
/
	.EJECT
/ AT COMPLETION OF THE DIRECTORY LISTING, THE TERMINATING CHARACTER OF THE
/ COMMAND LINE IS EXAMINED. IF IT IS A CARRIAGE RETURN, THE RESIDENT TDV
/ TASK IS 'REQUESTED' AND THIS TASK EXITS. IF THE LINE IS TERMINATED BY AN
/ ALTMODE, THIS TASK EXITS WITHOUT 'REQUESTING' 'TDV...'. A CTRL T TYPEIN
/ IS THEN NECESSARY TO RE-ESTABLISH TDV DIALOGUE.
/
IDX=ISZ				/USED WHEN THE SKIP IS NOT INTENDED.
X10=10				/AUTOINCREMENT REGISTER 10.
X11=11				/AUTOINCREMENT REGISTER 11.
X12=12				/AUTOINCREMENT REGISTER 12.
	.DEC
DTPLUN=19			/DECTAPE INPUT LUN.
TDVTTY=13			/TDV TTY ERROR LUN.
TDVOUT=13			/TDV PRINTOUT LUN.
	.OCT
/
	.EJECT
DTD	CAL	XFER		/TRANSFER THE COMMAND LINE READ BY 'TDV...'.
	CAL	WAITFR
	LAC	EV		/SAVE THE EVENT VARIABLE FOR REFERENCE AT
	DAC	XFEREV		/EXIT TIME.
/
/ ATTACH THE "PRINTER".
/
	CAL	ATCHLP
	CAL	WAITFR
	LAC	EV
	SAD	(-6)
	JMP	DOHINF		/"ATTACH" UNIMPLEMENTED.
	SPA
	JMP	ERR1		/"ATTACH" ERROR.
/
/ MAKE SURE THAT THE LISTING DEVICE IN FACT CAN PERFORM OUTPUT AND
/ THAT IT DOES NOT HAVE A DIRECTORY.
/
DOHINF	CAL	HINFLP
	CAL	WAITFR
	LAC	EV
	RTL
	SPA!RAL
	SPA
	JMP	ERR2		/NOT A LISTING DEVICE -- CAN'T DO OUTPUT.
				/NOT A LISTING DEVICE -- HAS A DIRECTORY.
/
/ ATTACH THE DECTAPE.
/
	CAL	ATCHDT
	CAL	WAITFR
	LAC	EV
	SPA
	JMP	ERR1A		/"ATTACH" ERROR -- PERHAPS THIS ISN'T A DECTAPE.
/
/ MAKE SURE THAT THE INPUT DEVICE IS INDEED DECTAPE.
/
	CAL	HINFDT
	CAL	WAITFR
	LAC	EV
	AND	(77)		/CHECK THE DEVICE CODE.
	SAD	(4)
	SKP
	JMP	ERR2A		/NOT DECTAPE.
	LAC	EV
	LRS	6
	AND	(7)
	DAC	UNIT		/SAVE THE DECTAPE UNIT #.
/
	.EJECT
/ READ IN DECTAPE BLOCKS 71-100. THE ORDER AND DIRECTION IN WHICH
/ BLOCKS ARE READ IS CHOSEN TO MINIMIZE TAPE MOTION.
/
	LAC	(FSZTAB+37)	/SET UP AUTOINDEX REGISTER 12 AS AN INDEX
	DAC	AX12		/TO THE FILE SIZE TABLE.
	LAC	(400075)	/READ IN FILE BIT MAP BLOCKS, SOME IN THE
	JMS	READ		/REVERSE DIRECTION (400000 + NUMBERS) AND SOME
	LAC	(FSZTAB-1)	/FORWARD. THOSE READ IN REVERSE WILL BE
	DAC	AX12		/TURNED INTO THEIR COMPLEMENT OBVERSE
	LAC	(400071)	/PATTERN. FOR THE 7 FILE BIT MAP BLOCKS,
	JMS	READ		/THE FILE SIZES ARE COMPUTED AND STORED
	LAC	(FSZTAB+7)	/IN A FILE SIZE TABLE. THE SAME IS DONE
	DAC	AX12		/FOR BLOCK 100 IN ORDER TO GET A COUNT
	LAC	(+72)		/FOR THE MASTER FILE BIT MAP AND (IN CASE
	JMS	READ		/THIS IS A SYSTEM TAPE) A COUNT OF THE
	LAC	(FSZTAB+47)	/SYSTEM FILE BIT MAP.
	DAC	AX12
	LAC	(+76)
	JMS	READ
	LAC	(FSZTAB+57)
	DAC	AX12
	LAC	(400077)
	JMS	READ
	LAC	(FSZTAB+17)
	DAC	AX12
	LAC	(400073)
	JMS	READ
	LAC	(FSZTAB+27)
	DAC	AX12
	LAC	(+74)
	JMS	READ
	LAC	(FSZTAB+67)
	DAC	AX12
	LAC	(+100)
	JMS	READ
/
/ DETACH THE DECTAPE.
/
	CAL	DTCHDT
	CAL	WAITFR
	LAC	EV
	SPA
	JMP	ERR5A		/"DETACH" ERROR.
/
	.EJECT
/ CHECK WORD 203, BIT 3, TO SEE IF THIS IS A "NORMAL" RATHER THAN A
/ "SYSTEM" TAPE.
/
	DZM	SYSTAP		/0 MEANS NOT A SYSTEM TAPE.
	LAC	(BUF)
	AND	(7777)
	PAX			/BUFFER ADDRESS WITHOUT THE PAGE BITS.
	LAC	203,X
	AND	(040000)
	DAC	SYSTAP		/NON-0 MEANS IT IS A SYSTEM TAPE.
/
/ SETUP A COUNTER OF THE MAXIMUM NUMBER OF USER FILE ENTRIES ON THE TAPE.
/
	LAW	-70		/MAX. COUNT FOR A "NORMAL" TAPE.
	DAC	NTRIES
	LAC	SYSTAP		/IS THIS A SYSTEM TAPE?
	SNA
	JMP	.+3		/NO.
	LAW	-30		/YES -- MAX. COUNT FOR A "SYSTEM" TAPE.
	DAC	NTRIES
	LAC	NTRIES		/SAVE COUNTER FOR FILE ENTRY LOOP.
	DAC	ENTRYS
/
/ COUNT THE NUMBER OF BLOCKS OCCUPIED BY USER FILES. AS A PRECAUTION IN
/ CASE THE FILE BIT MAP IS NOT CLEARED WHEN THE FILE ENTRY IS FREED
/ AFTER A FILE HAS BEEN DELETED, DON'T ADD THE FILE BIT MAP COUNT UNLESS
/ THE FILE ENTRY EXISTS. ALSO, COUNT THE NUMBER OF USER FILES.
/
	LAC	(FSZTAB-1)	/SET UP AUTOINCREMENT REGISTER 10 TO PICK
	DAC*	(X10)		/UP THE FILE SIZES.
	DZM	USRTTL		/INITIALIZE THE COUNT OF THE TOTAL NUMBER
				/OF USER FILE BLOCKS.
	DZM	FILCNT		/INITIALIZE THE NUMBER OF USER FILES.
CTLOOP	LAC	43,X		/IS THE "FILE ACTIVE" BIT SET?
	SMA
	JMP	NOTSET		/NO -- EMPTY FILE ENTRY.
	LAC*	X10		/YES -- ADD THE FILE SIZE TO THE TOTAL.
	TAD	USRTTL
	DAC	USRTTL
	IDX	FILCNT
	SKP
NOTSET	LAC*	X10		/INCREMENT THE INDEX.
	AXR	+4
	ISZ	NTRIES
	JMP	CTLOOP
/
/ FIRST LINE -- PRINT THE DECTAPE UNIT NUMBER.
/
	LAC	(PRTBUF+1)	/INITIALIZE THE STORAGE POINTER TO THE
	DAC*	(X10)		/BEGINNING OF THE PRINT BUFFER.
	LAC	(011003)	/SET UP HEADER WORD 0 IN THE PRINT BUFFER.
	DAC	PRTBUF
	LAC	(040503)	/.SIXBT "DEC".
	JMS	SIXBIT		/CONVERT FROM .SIXBT AND STORE IN BUFFER.
	LAC	(240120)	/.SIXBT "TAP".
	JMS	SIXBIT
	LAC	(050025)	/.SIXBT "E U".
	JMS	SIXBIT
	LAC	(161124)	/.SIXBT "NIT".
	JMS	SIXBIT
	JMS	SPACE
	LAC	UNIT		/CONVERT THE UNIT # TO ASCII AND
	AAC	+60		/STORE IT IN THE BUFFER.
	DAC*	X10
	JMS	PRTOUT
/
/ SECOND LINE -- PRINT THE CURRENT DATE.
/
	CAL	DATE		/GET THE DATE & TIME FROM THE EXECUTIVE.
	LAC	(PRTBUF+1)	/RESET THE BUFFER STORAGE POINTER.
	DAC*	(X10)
	CLA			/STORE 4 SPACES.
	JMS	SIXBIT
	JMS	SPACE
	LAC	DAY		/CONVERT AND STORE THE DAY.
	JMS	TWODIG
	LAC	(55)		/- (HYPHEN).
	DAC*	X10
	LAC	MONTH		/LOOK UP THE MONTH IN A TABLE.
	TAD	(MONTAB-1)
	DAC*	(X11)
	LAC*	X11
	JMS	SIXBIT		/CONVERT AND STORE THE MONTH.
	LAC	(55)		/- (HYPHEN).
	DAC*	X10
	LAC	YEAR		/CONVERT AND STORE THE YEAR.
	JMS	TWODIG
	JMS	SPACE
	JMS	PRTOUT
/
/ THIRD LINE -- PRINT THE NUMBER OF FREE BLOCKS.
/
	LAC	(012003)	/SET UP HEADER WORD 0 IN THE PRINT BUFFER.
	DAC	PRTBUF
	LAC	FSZTAB+70	/# OF USED BLOCKS.
	TCA
	TAD	(1100)		/AC NOW HAS THE # OF FREE BLOCKS.
	JMS	OCTAL		/CONVERT AND STORE THE NUMBER.
	JMS	SPACE
	LAC	(062205)	/.SIXBT "FRE".
	JMS	SIXBIT
	LAC	(050002)	/.SIXBT "E B".
	JMS	SIXBIT
	LAC	(141323)	/.SIXBT "LKS".
	JMS	SIXBIT
	JMS	PRTOUT
/
/ FOURTH LINE -- PRINT THE NUMBER OF USER FILES.
/
	LAC	(013003)	/SET UP HEADER WORD 0 IN THE PRINT BUFFER.
	DAC	PRTBUF
	LAC	FILCNT		/# OF USER FILES.
	JMS	OCTAL		/CONVERT AND STORE IN THE PRINT BUFFER.
	LAC	(002523)	/.SIXBT " US".
	JMS	SIXBIT
	LAC	(052200)	/.SIXBT "ER ".
	JMS	SIXBIT
	LAC	(061114)	/.SIXBT "FIL".
	JMS	SIXBIT
	LAC	(052300)	/.SIXBT "ES ".
	JMS	SIXBIT
	JMS	PRTOUT
/
/ FIFTH LINE -- PRINT THE NUMBER OF SYSTEM BLOCKS.
/
	LAC	USRTTL		/THE NUMBER OF SYSTEM
	TCA			/BLOCKS = THE TOTAL NUMBER OF BLOCKS USED
	TAD	FSZTAB+70	/(FROM THE MASTER BIT MAP) MINUS THE
				/NUMBER OF USER FILE BLOCKS.
	JMS	OCTAL
	LAC	(002331)	/.SIXBT " SY".
	JMS	SIXBIT
	LAC	(232405)	/.SIXBT "STE".
	JMS	SIXBIT
	LAC	(150002)	/.SIXBT "M B".
	JMS	SIXBIT
	LAC	(141323)	/.SIXBT "LKS".
	JMS	SIXBIT
	JMS	PRTOUT
/
/ CONVERT THE FILE ENTRY INFORMATION AND PACK IT IN IMAGE ASCII FORM IN THE
/ PRINT BUFFER.
/
	LAC	(016003)	/SET UP HEADER WORD 0 IN THE PRINT BUFFER.
	DAC	PRTBUF
	LAC	(FSZTAB-1)	/SET UP AUTOINDEX REGISTER 12 FOR PICKING
	DAC*	(X12)		/UP FILE SIZES.
	LAC	(BUF+40)	/FIRST ENTRY FOLLOWS 40-WORD MASTER BITMAP.
	AND	(7777)
NXNTRY	PAX
	DAC	XRVAL
/
/ CHECK FOR AN EMPTY FILE ENTRY, I.E., A NULL FILE NAME.
/
	LAC	0,X
	SNA
	JMP	EMPTY		/EMPTY SLOT.
/
/ CONVERT THE FILE ENTRY INFORMATION.
/
	LAC	0,X		/FIL
	JMS	SIXBIT
	LAC	1,X		/NAM
	JMS	SIXBIT
	JMS	SPACE
	LAC	2,X		/EXT
	JMS	SIXBIT
	JMS	SPACE
	LAC	3,X		/FILE'S 1ST BLOCK #.
	AND	(1777)
	JMS	OCTAL		/CONVERT TO 6 DIGITS -- SUPPRESS LEADING 0'S.
	JMS	SPACE
	LAC	SYSTAP		/IF NOW PRINTING THE SYSTEM FILES FROM
	SMA!CLA			/THE SECOND HALF OF A SYSTEM TAPE DIRECT-
				/ORY, THE FILE SIZE IN THE FILE BIT MAP
				/IS MEANINGLESS. PRINT 0 INSTEAD.
	LAC*	X12		/NUMBER OF BLOCKS IN THE FILE.
	JMS	OCTAL
	LAC*	(X12)		/SAVE AUTOINDEX 12.
	DAC	AX12
	JMS	PRTOUT
	LAC	AX12		/RESTORE AUTOINDEX 12.
	DAC*	(X12)
	SKP
/
/ MOVE ON TO THE NEXT ENTRY.
/
EMPTY	LAC*	X12		/ADD 1 TO AUTOINDEX REGISTER 12.
	LAC	XRVAL
	AAC	+4
	ISZ	ENTRYS
	JMP	NXNTRY
/
/ IF THIS IS A SYSTEM TAPE AND THE SYSTEM FILES HAVEN'T YET BEEN LISTED, DO SO.
/
	LAC	SYSTAP		/SYSTEM TAPE AND NOT FINISHED?
	SPA!SNA
	JMP	DONE		/NO.
	CLC			/YES -- SET FLAG NEGATIVE SO THAT NEXT
	DAC	SYSTAP		/TIME THROUGH HERE IT WILL BE FINISHED.
	LAW	-30		/SET COUNT OF THE # OF SYS FILE ENTRIES.
	DAC	ENTRYS
	LAC*	(X12)		/MOVE POINTER AHEAD TO BYPASS SYSTEM BITMAP.
	AAC	+10
	DAC*	(X12)
	LAC	XRVAL		/MOVE XR PAST LAST ENTRY AND SYSTEM BITMAP.
	AAC	+44
	JMP	NXNTRY
/
/ DETACH THE "PRINTER".
/
DONE	CAL	DTCHLP
	CAL	WAITFR
	LAC	EV
	SAD	(-6)
	CLA			/"DETACH" UNIMPLEMENTED.
	SPA
	JMP	ERR5		/"DETACH" ERROR.
/
/ DIRECTORY PRINTOUT COMPLETED. EXAMINE THE EVENT VARIABLE VALUE RETURNED
/ BY THE TRANSFER-COMMAND-LINE DIRECTIVE TO SEE IF THE LINE WAS TERMINATED
/ BY CARRIAGE RETURN (+2), ALTMODE (+1), OR IF THE LINE BUFFER IS TOO
/ SMALL (-16). REQUEST 'TDV...' UNLESS THE TERMINATOR WAS ALTMODE.
/
	LAC	XFEREV
	SAD	(1)
	SKP
EXIT	CAL	REQTDV		/REQUEST 'TDV...'.
	CAL	(10)		/EXIT.
/
	.EJECT
/ ERROR EXIT.
/
ERR1A	LAC	(MES1)		/"ATTACH" ERROR.
	SKP
ERR2	LAC	(MES2)		/NOT A LISTING DEVICE.
	SKP
ERR4	LAC	(MES4)		/PRINTOUT ERROR.
	SKP
ERR5A	LAC	(MES5)		/"DETACH" ERROR.
	DAC	TYPE+4
	LAC	EV		/SAVE EV VALUE SO THAT SOMEONE MAY EXAMINE
	DAC	ERRCOD		/IT USING THE "OPEN" MCR FUNCTION.
	JMP	DTLP
ERR2A	LAC	(MES2A)		/NOT DECTAPE.
	SKP
ERR3	LAC	(MES3)		/DECTAPE ERROR.
	DAC	TYPE+4
	LAC	EV
	DAC	ERRCOD
	CAL	DTCHDT		/DETACH THE DECTAPE.
	CAL	WAITFR
DTLP	CAL	DTCHLP		/DETACH THE "PRINTER".
	CAL	WAITFR
	JMP	TYPEIT
ERR1	LAC	(MES1)		/"ATTACH" ERROR.
	SKP
ERR5	LAC	(MES5)		/"DETACH" ERROR.
	DAC	TYPE+4
	LAC	EV		/SAVE EV VALUE SO THAT SOMEONE MAY EXAMINE
	DAC	ERRCOD		/IT USING THE "OPEN" MCR FUNCTION.
TYPEIT	CAL	TYPE
	CAL	WAITFR
	JMP	EXIT
/
	.EJECT
MES1	004002; 0; .ASCII "DTD-ATTACH ERR"<15>
MES2	006002; 0; .ASCII "DTD-NOT A LISTING DEV"<15>
MES2A	005002; 0; .ASCII "DTD-NOT DECTAPE"<15>
MES3	005002; 0; .ASCII "DTD-DECTAPE ERR"<15>
MES4	005002; 0; .ASCII "DTD-PRINTOUT ERR"<15>
MES5	004002; 0; .ASCII "DTD-DETACH ERR"<15>
/
/ SUBROUTINE READ -- READ IN THE INDICATED DECTAPE BLOCK IN THE INDICATED
/ DIRECTION. COMPLEMENT OBVERSE THE DATA IF THE BLOCK WAS READ IN THE
/ REVERSE DIRECTION. COMPUTE THE FILE SIZES FROM THE FILE BIT MAPS AND
/ STORE THE RESULTS IN THE FILE SIZE TABLE. THIS IS ALSO DONE FOR BLOCK
/ 100 IN ORDER TO COUNT THE NUMBER OF BLOCKS USED (FROM THE MASTER BIT
/ MAP) AND (IF THIS IS A SYSTEM TAPE) THE NUMBER OF SYSTEM BLOCKS (FROM
/ THE SYSTEM BIT MAP).
/
/ CALLING SEQUENCE:
/
/	AX12 SET UP FOR STORING FILE SIZES
/	+ OR - BLOCK # IN THE AC (+ = FORWARD; - = REVERSE)
/	JMS	READ
/	(RETURN IF NO READ ERROR OCCURRED)
/
/ ALTERED REGISTERS:
/
/	EFFECTIVELY ALL (DUE TO THE CAL)
/
READ	0
	DAC	DTGET+3		/STORE THE BLOCK NUMBER AND DIRECTION
				/INDICATOR IN THE "GET" CPB.
	CAL	DTGET		/READ IN THE TAPE BLOCK.
	CAL	WAITFR
	LAC	EV
	SPA
	JMP	ERR3		/DECTAPE ERROR.
	LAC	AX12
	DAC*	(X12)
/
/ IF THE TAPE WAS READ IN THE REVERSE DIRECTION, PERFORM THE COMPLEMENT
/ OBVERSE ON THE DATA.
/
	LAC	DTGET+3
	SMA
	JMP	FORWRD		/BLOCK READ FORWARD -- DATA O.K.
/
	.EJECT
	LAW	-200		/INTERCHANGE WORDS IN THE BLOCK, SO LOOP
	DAC	COUNT		/FOR ONLY HALF THE BLOCK SIZE.
	LAC	(BUF-1)		/SET UP POINTERS TO GET/PUT FROM THE
	DAC*	(X10)		/FRONT END OF THE BLOCK.
	DAC*	(X11)
	CLX			/SET UP THE XR TO GET/PUT FROM THE TAIL
				/END OF THE BLOCK WORKING BACKWARDS.
COBVLP	LAC*	X10		/PICK UP FRONT END DATA WORD, TURN IT INTO
	JMS	OBVERS		/ITS ONES COMPLEMENT OBVERSE, AND
	DAC	TEMP		/SAVE IT.
	LAC	BUF+377,X	/PICK UP TAIL END DATA WORD, TURN IT INTO
	JMS	OBVERS		/ITS ONES COMPLEMENT OBVERSE, AND
	DAC*	X11		/STORE IT.
	LAC	TEMP		/REPLACE THE TAIL END WORD.
	DAC	BUF+377,X
	AXR	-1		/BACK UP THE TAIL END INDEX.
	ISZ	COUNT
	JMP	COBVLP
	JMP	FORWRD		/DONE.
/
/ SUBROUTINE OBVERS -- UNSCRAMBLE THE WORD IN THE AC WHOSE BITS ARE
/ COMPLEMENTED AND ARRANGED IN THE FOLLOWING WAY:
/
/	15-16-17  12-13-14  9-10-11  6-7-8  3-4-5  0-1-2
/
/	F	  E	    D	     C	    B	   A
/
OBVERS	0
	CMA			/ F   E   D   C   B   A
	SWHA
	DAC	OBV1		/ C   B   A   F   E   D
	ALS	6		/ A   F   E   D   ?   ?
	XOR	OBV1
	AND	(700700)	/ A\C 0   0   D\F 0   0
	DAC	OBV2
	CLL
	LRS	6		/ 0   0   A\C 0   0   D\F
	XOR	OBV1		/ C   B   C   F   E   F
	XOR	OBV2		/ A   B   C   D   E   F
	JMP*	OBVERS
/
OBV1	0			/ C   B   A   F   E   D
OBV2	0			/ A\C 0   0   D\F 0   0
/
	.EJECT
/ COMPUTE THE SIZES OF THE 8 FILES REPRESENTED BY THE FILE BIT MAPS IN
/ THE BLOCK JUST READ.
/
FORWRD	LAW	-10		/8 FILES PER BLOCK.
	DAC	FILCNT
	LAC	(BUF-1)		/SET UP AUTOINDEX REGISTER 10 TO GET
	DAC*	(X10)		/WORDS FROM THE BLOCK.
/
FLLOOP	DZM	SIZE		/INITIALIZE THE FILE SIZE.
	LAW	-40		/40 OCTAL WORDS PER BIT MAP.
	DAC	MAPCNT
/
MAPLP	LAW	-22		/18 BITS PER WORD.
	DAC	WDCNT
	LAC*	X10		/GET BIT MAP WORD.
WDLOOP	RAL
	SZL			/SKIP ON A ZERO BIT.
	IDX	SIZE		/ADD 1 TO FILE SIZE.
	ISZ	WDCNT		/END OF WORD?
	JMP	WDLOOP		/NO.
	ISZ	MAPCNT		/END OF FILE BIT MAP?
	JMP	MAPLP		/NO.
	LAC	SIZE		/STORE THE SIZE IN THE FILE SIZE TABLE.
	DAC*	X12
	ISZ	FILCNT		/END OF THIS DECTAPE BLOCK?
	JMP	FLLOOP		/NO.
	JMP*	READ
/
	.EJECT
/ SUBROUTINE PRTOUT -- STORE CARRIAGE RETURN LINE FEED IN THE PRINT BUFFER,
/ PRINT THE LINE, AND THEN RESET THE POINTER TO THE BEGINNING OF THE
/ PRINT BUFFER.
/
/ CALLING SEQUENCE:
/
/	JMS	PRTOUT
/
/ ALTERED REGISTERS:
/
/	EFFECTIVELY ALL (DUE TO THE CAL)
/
PRTOUT	0
	LAC	(15)		/CARRIAGE RETURN.
	DAC*	X10
	LAC	(12)		/LINE FEED.
	DAC*	X10
	CAL	PRINT
	CAL	WAITFR
	LAC	EV
	SPA
	JMP	ERR4		/PRINT ERROR.
	LAC	(PRTBUF+1)	/RESET THE STORAGE POINTER.
	DAC*	(X10)
	JMP*	PRTOUT
/
	.EJECT
/ SUBROUTINE SIXBIT -- UNPACK THE 3 .SIXBT CHARACTERS IN THE AC, CONVERT
/ THEM TO ASCII, AND STORE THEM IN THE PRINT BUFFER.
/
/ CALLING SEQUENCE:
/
/	.SIXBT WORD IN THE AC
/	JMS	SIXBIT
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	AC, MQ & X10
/
SIXBIT	0
	LMQ
	JMS	BYTE
	JMS	BYTE
	JMS	BYTE
	JMP*	SIXBIT
/
BYTE	0			/SUBROUTINE USED BY "SIXBIT".
	CLA!CLL
	LLS	6		/GET NEXT .SIXBT CHARACTER FROM THE MQ.
	SZA			/CONVERT TO ASCII.
	AAC	40
	AND	(77)
	AAC	40
	DAC*	X10
	JMP*	BYTE
/
/ SUBROUTINE SPACE -- STORE A "SPACE" CHARACTER IN THE PRINT BUFFER.
/
/ CALLING SEQUENCE:
/
/	JMS	SPACE
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	AC & X10
/
SPACE	0
	LAC	(40)		/A "SPACE".
	DAC*	X10
	JMP*	SPACE
/
	.EJECT
/ SUBROUTINE OCTAL -- CONVERT THE NUMBER IN THE AC INTO 6 OCTAL DIGITS IN
/ ASCII, SUBSTITUTING SPACES FOR LEADING ZEROS. STORE THEM IN THE PRINT BUFFER.
/
/ CALLING SEQUENCE:
/
/	NUMBER IN THE AC
/	JMS	OCTAL
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	AC, MQ & X10
/
OCTAL	0
	LMQ
	LAW	-6		/SET COUNT FOR 6 DIGITS.
	DAC	DIGCNT
	DZM	ZFLAG		/INITIALIZE THE "LEADING ZERO SUPPRESS" FLAG.
AGAIN	CLA!CLL
	LLS	3		/GET NEXT DIGIT.
	SZA			/IS IT A 0?
	IDX	ZFLAG		/NO -- INDICATE SIGNIFICANT DIGIT ENCOUNTERED.
	SZA
	JMP	NONZER
	LAW	-1		/IS THIS THE LAST DIGIT?
	SAD	DIGCNT
	JMP	LAST0		/YES -- ALWAYS PRINT IT.
	LAC	ZFLAG		/NO -- SUPPRESS LEADING 0 IF ZFLAG=0.
LAST0	SZA!CLA
NONZER	AAC	20		/CONVERT TO ASCII.
	AAC	40
	DAC*	X10
	ISZ	DIGCNT
	JMP	AGAIN
	JMP*	OCTAL
/
	.EJECT
/ SUBROUTINE TWODIG -- CONVERT THE NUMBER IN THE AC INTO 2 DECIMAL DIGITS
/ IN ASCII, SUBSTITUTING A SPACE FOR A LEADING ZERO. STORE THEM IN THE
/ PRINT BUFFER.
/
/ CALLING SEQUENCE:
/
/	NUMBER IN THE AC
/	JMS	TWODIG
/	(UNCONDITIONAL RETURN)
/
/ ALTERED REGISTERS:
/
/	AC, LR, MQ & X10
/
TWODIG	0
	CLL
	IDIV			/DIVIDE NUMBER BY 10.
	.DEC
	10
	.OCT
	PAL			/SAVE REMAINDER IN LR.
	LACQ			/CONVERT AND STORE DIGIT 1.
	AAC	60
	DAC*	X10
	PLA			/CONVERT AND STORE DIGIT 2.
	AAC	60
	DAC*	X10
	JMP*	TWODIG
/
MONTAB=.-1			/TABLE OF MONTHS.
	.SIXBT	/JAN/
	.SIXBT	/FEB/
	.SIXBT	/MAR/
	.SIXBT	/APR/
	.SIXBT	/MAY/
	.SIXBT	/JUN/
	.SIXBT	/JUL/
	.SIXBT	/AUG/
	.SIXBT	/SEP/
	.SIXBT	/OCT/
	.SIXBT	/NOV/
	.SIXBT	/DEC/
/
	.EJECT
WAITFR	20			/"WAITFOR" CPB.
	EV
/
HINFLP	3600			/"HINF" CPB.
	EV
	TDVOUT			/TDV LISTING OUTPUT LUN.
/
HINFDT	3600			/"HINF" CPB.
	EV
	DTPLUN			/DECTAPE INPUT LUN.
/
ATCHLP	2400			/"ATTACH" CPB.
	EV
	TDVOUT			/TDV LISTING OUTPUT LUN.
/
ATCHDT	2400			/"ATTACH" CPB.
	EV
	DTPLUN			/DECTAPE INPUT LUN.
/
DTCHLP	2500			/"DETACH" CPB.
	EV
	TDVOUT			/TDV LISTING OUTPUT LUN.
/
DTCHDT	2500			/"DETACH" CPB.
	EV
	DTPLUN			/DECTAPE INPUT LUN.
/
DTGET	3000			/"GET DECTAPE BLOCK" CPB.
	EV
	DTPLUN			/DECTAPE INPUT LUN.
	XX			/BLOCK NUMBER FORWARD.  +400000(8) REVERSE.
	BUF			/CORE ADDRESS.
	400			/WORD COUNT.
/
PRINT	2700			/"WRITE" CPB.
	EV
	TDVOUT			/TDV LISTING OUTPUT LUN.
	3			/IMAGE ASCII DATA MODE.
	PRTBUF
/
PRTBUF	016003			/IMAGE ASCII PRINT LINE BUFFER.
	0			/HEADER WORD 0 WILL VARY AS THE WORD
	.BLOCK	30		/PAIR COUNT IS ALTERED.
	15			/CARRIAGE RETURN.
	12			/LINE FEED.
/
TYPE	2700			/"WRITE" CPB.
	EV
	TDVTTY			/TDV TTY ERROR LUN.
	2			/IOPS ASCII DATA MODE.
	XX			/MESSAGE ADDRESS.
/
/
REQTDV	1			/"REQUEST" CPB.
	0
	.SIXBT	"TDV"
	.SIXBT	"..."
	0			/USE THE DEFAULT PRIORITY.
/
XFER	37			/"TRANSFER TDV COMMAND LINE" CPB.
	EV
	BUF			/BUFFER ADDRESS.
	401			/BUFFER SIZE.
/
DATE	24			/"DATE & TIME" CPB.
	EV
MONTH	XX			/(1 - 12).
DAY	XX			/(1 - 31).
YEAR	XX			/(0 - 99).
HOURS	XX
MINS	XX
SECS	XX
/
/ VARIABLES.
/
XFEREV	0			/EVENT VARIABLE VALUE RETURNED BY THE
				/"XFER" DIRECTIVE.
EV	0			/EVENT VARIABLE.
NTRIES	0			/COUNTER -- NUMBER OF FILE ENTRIES.
ENTRYS	0			/COUNTER -- NUMBER OF FILE ENTRIES.
SYSTAP	0			/0 = NORMAL TAPE; NON-0 = SYSTEM TAPE.
				/+ NON-0 WHILE PRINTING USER FILES ON SYS TAPE.
				/- NON-0 WHILE PRINTING SYSTEM FILES.
USRTTL	0			/COUNT -- TOTAL NUMBER OF USER FILE BLOCKS.
XRVAL	0			/SAVED LOOP VALUE OF THE XR.
DIGCNT	0			/DIGIT COUNTER.
ZFLAG	0			/"LEADING ZERO SUPPRESS" FLAG -- SET NON-0
				/WHEN A SIGNIFICANT DIGIT IS ENCOUNTERED.
ERRCOD	0			/EV VALUE SAVED BEFORE ERROR PRINTOUT IN
				/CASE SOMEONE WANTS TO EXAMINE IT USING
				/THE "OPEN" MCR FUNCTION.
FILCNT	0			/COUNTER -- 8 FILE BIT MAPS PER BLOCK.
				/ALSO -- NUMBER OF USER FILES.
SIZE	0			/TEMPORARY COUNTER FOR FILE SIZE.
MAPCNT	0			/COUNTER -- 40 OCTAL WORDS PER BIT MAP.
WDCNT	0			/COUNTER -- 18 BITS PER WORD.
UNIT	0			/DECTAPE UNIT #.
COUNT	0			/COUNTER.
TEMP	0			/TEMPORARY STORAGE.
AX12	0			/TEMP STORAGE FOR X12 VALUE.
/
FSZTAB	.BLOCK	100		/FILE SIZE TABLE.
/
BUF	.BLOCK	401		/EXTRA WORD IS TO GUARD AGAINST POSSIBLE
				/HARDWARE TIMING ERROR WHEREIN DECTAPE
				/TRANSFERS AN EXTRA WORD.
/
	.END	DTD
