Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-08 - 43,50473/dtcert.mac
There is 1 other file named dtcert.mac in the archive. Click here to see a list.
	SUBTTL	SYMBOLS FOR DTCERT PROGRAM AND DECTAPE FUNTIONS

	OPDEF	DISMIS	[JRST	RESTR(I)]
	OPDEF	ERROR	[JSP	P,ERR(I)]
	OPDEF	WAIT	[JSR	DISPAT(I)]
	OPDEF	SETFST	[TLO	I,400000]
	OPDEF	CLRFST	[TLZ	I,400000]
	OPDEF	GOFAST	[JSP	P,FST.E(I)]
	OPDEF	GOWORD	[JSP	P,OUT.E(I)]
	OPDEF	RETURN	[JRST	STOP(I)]

;PI ASSIGNMENT
	PIA=1		;PRIORITY INTERUPT PRIORITY
	PID=<PIA*8>	;PI ASSIGNMENT (DATA)
	PIF=<PIA>	;PI ASSIGNMENT (FLAGS)

;	Note on PI assignment.  DTCERT must run on a channel high enough
;	so it does not get the error message DATA MISSED.  Anything higher
;	is nice but not necessary.  PI1 is the highest priority level and
;	PI7 is the lowest.  The easiest way to find out what channel to run
;	DTCERT on is by trial (unless your system programmer knows what is on
;	what channel.  If so, DTCERT will need to be higher than the clock).
;
;	Start by making the symbol PIA=4.  Assemble DTCERT as per the
;	instructions below.  Run DTCERT and try to certify some tapes.  If
;	you get the message DATA MISSED, reassemble for a higher PI channel.
;	If you get the message RATTRP UUO FAILED,  you either are not privilaged
;	or the PI channel is occupied by a BLKI/O and cannot be used by this
;	program.  Try all the PI channels until you have tried PI1 if necessary.
;
;	DTCERT must interupt the processer once ever 400uS when writing the
;	timing marks and spends about 50uS to 90uS at interupt level when doing
;	so.  Therefore if you get DATA MISSED even on the highest PI channel.
;	It may be possable to not get the error and certify tapes on an unloaded
;	system (not on prime shift).  DTCERT will use about 12% to 20% of
;	the processer when certifying tapes depending on the processer used.
;	The author has certified DECTAPEs in the middle of the day when the
;	system was heavily loaded on KI-10s and on KL-10s and I find that
;	I still get DATA MISSED errors every 3 to 4 tapes certified.  Nothing
;	can be done.  Some one is clearly spending too much time with the PI
;	system disabled or at a higher channel every once in a while.  Just put
;	the tape back at the beginning and recertify it.  Also I have noticed
;	that a certain drive will not certify a certain tape but change drives
;	or a different tape and all works well.  The drive was later able to
;	read the same tape with no difficulty.  I've seen stanger things happen.
;
;	Just one note on mounting the DECTAPEs, allow only enough tape on the
;	reel to keep the reel from spinning.  I find this is easy to do by
;	placing the drive in LOCAL, holding on to the feed reel and unwinding
;	enough tape to drape over the (spinning) take-up reel.  Now just
;	light presure from a finger on the draped tape around the tape-up
;	reel will cause the tape to stick to it and wrap all the way around
;	it.  All this time you are slowly feeding it tape from the feed reel
;	as needed.  When enough tape has been payed out and finaly finishes
;	the first wrap (and maybe a little more) around the take-up reel the
;	take-up reel will stop spinning.  Now put the drive in REMOTE and
;	WRITE-ENABLED.  As hard and confusing as this sounds, it is much
;	easer in real life and takes about 5 seconds to do.  Seeing is
;	believing.
;
;	If you have any problems with the program or find a bug, please
;	contact the University of Arizona Computer Center, Henry Schneiker,
;	C/O the systems staff, Tucson, Arizona, 85721, USA.
;
;	Assembly instructions.
;
;	.R MACRO
;	*DTCERT,DTCERT/CREF=DTCERT
;	*^C
;	.LOAD DTCERT.REL
;	.SAVE DTCERT
;	.R CREF
;	*DTCERT.LST=DTCERT.CRF
;	*^C
;

;REGISTER SAVE AREA **** FOR EXCLUSEIVE USE OF INTERUPT ROUTINES ****
	AA:	1	;FOR INTERUPT USE ONLY
	CC:	3
	DD:	4
	EE:	5	;THING TO BE OUTPUT BY DATAO
	PP:	6	;JSP LINK REGISTER
	II:	7	;AN INDEX
	TT1:	11	;TEMPORARY REGISTORS
	TT2:	12

;REGISTER DEFINITIONS
	F=0		;FLAG REG
	A=1
	B=2
	C=3
	D=4
	E=5
	P=6		;INTERUPT LEVEL JSP LINK REGISTER
	I=7		;INTERUPT LEVEL RELOCATION INDEX
	U=10		;DECTAPE UNIT NUMBER
	T1=11
	T2=12

;FLAGS
	WAIT=1		;WE WAITED FOR THE OPR

;MISC DEFINITIONS
;	LONG=0		;WRITE 582 BLOCK LONG DECTAPES (LESS WAIST)
	LONG=1		;WRITE 578 BLOCK LONG DECTAPES (STANDARD DECTAPE)
	ZONSIZ=^D2500	;SIZE OF ENDZONES (2500 (4704) ABOUT 10 FEET OF TAPE)
	BLKSIZ=200	;SIZE OF DEC-10 BLOCK
	IFE	LONG,<	; Not known to work
	TITLE	DTLONG - ONLINE DECTAPE CERTIFICATION, 582 BLOCKS, 128 WORDS
	IF1,<PRINTX	DTCERT - LONG TAPE (582 BLOCK) VERSION>
	BLKNUM=1106	;BLOCKS PER TAPE
>
	IFN	LONG,<
	TITLE	DTCERT - ONLINE DECTAPE CERTIFICATION, 578 BLOCKS, 128 WORDS
	IF1,<PRINTX	DTCERT - NORNAL TAPE, 578 BLOCKS, 128 WORDS/BLOCK>
	BLKNUM=1102	;BLOCKS PER TAPE
>
;I/O BITS
	SEL=30000	;SELECT DEVICE
	DESEL=10000	;DESELECT DEVICE
	FWD=200000	;FORWARD MOTION SELECT
	RVS=100000	;REVERSE MOTION SELECT
	CHG=300000	;CHANGE DIRECTION
	STP=400000	;STOP TAPE MOTION
	ENDZON=1B22	;END ZONE
	WRTLCK=1B24	;WRITE LOCKED
	WRTSW=1B25	;WRTM SWITCH
	DTS=324		;DECTAPE STATUS
	DTC=320		;DECTAPE CONTROL
	PION=200	;TURN ON THE PI SYSTEM
	PIOFF=400	;TURN OFF THE PI SYSTEM
	IOERR=775700	;IF THESE ARE SET AN ERROR HAPPENED
	SELERR=100	;SELECT ERROR

;DECTAPE FUNCTION CODES
	NOP=000		;DO NOTHING (NO OP)
	READA=100	;READ ALL
	READB=200	;READ BN
	READD=300	;READ DATA
	WMT=400		;WRITE MARK TRACK
	WRITEA=500	;WRITE ALL
	WRITEB=600	;WRITE BN
	WRITED=700	;WRITE DATA
	SUBTTL DTCERT - MAIN CODE FOR ONLINE CERTIFICATION OF DECTAPES
ASCIZ\
	AUTHOR/SORCE	Henry Schneiker/University of Arizona
					Computer Center.

	DATE		March 1976

	Another quality product of BPI,
	Bandit Programmers International.

	Developed and payed for by the University of Arizona, state of
	Arizona.  This program is in the public domain and may not be sold.

	Let the user of this program beware.  This program requires
	absolute power to run.  Absolute power corrupts absolutely.
\

; Edit history
;
; 1	Change name from DTCRT to DTCERT.  Do not confuse this with the
;	the distributed DTCERT that never worked.
;
; 2	Instead of writing zeros for half an endzone at the start of tape,
;	write it with endzone markers.  When operations mounted DECtapes for
;	user FILE/MOUNT requests, it was possible to confuse the controller
;	into thinking it was at the wrong end of the tape.
;
;
;TAKE IT FROM THE TOP
;
DTCERT:	OUTSTR	STMSG		;PRINT THE INITIAL BS
DTCRTX:	RESET
	MOVE	P,[IOWD	10,PDLST]
	SETZ	F,		;CLEAR THE FLAGS
	PUSHJ	P,GETDTA	;GET THE DECTAPE DRIVES
	TLZE	F,WAIT		;DID WE WAIT?
	OUTSTR	[ASCIZ/Thank you
/]				;YES
	MOVEI	B,CCTRP		;ADR TO TRAP CONTROL-C'S AT
	MOVE	I,[XWD	1,1]	;LOCK US IN CORE
	LOCK	I,		;DO IT
	 JRST	NOLOCK		;FAILED
	LSH	I,^D9		;CONVERT FROM PAGE # TO ADR
	MOVEM	I,II		;SAVE THE INDEX
	MOVEI	A,RTBLK
	RTTRP	A,		;ASK FOR REAL TIME PRIVILAGES
	 JRST	NORTT		;FAILED
	MOVEM	B,134		;TRAP CONTROL-C'S NOW

	MOVEI	A,INTADR(I)	;GET THE ADR FOR INTERUPT TO TRAP TO
	HRRM	A,INTEND	;SAVE IT
	MOVEI	A,II(I)		;WHERE TO GET THE INDEX
	HRRM	A,INTST		;PUT IT AWAY
WRTMCK:	CONSO	DTS,WRTSW	;SKIP IF ALREADY SET
	OUTSTR	[ASCIZ/
Set the WRTM switch when a DECtape is ready to be certified.
/]				;TELL THEM WHAT TO DO

WRTCK:	MOVEI	A,1		;TIME TO WAIT
	SLEEP	A,		;SLEEP FOR A WHILE
	CONSO	DTS,WRTSW	;WAITING FOR THE OPR?
	JRST	WRTCK		;YES--CHECK AGAIN

	SETZB	U,ERRFLG	;START WITH DRIVE 0
WRTMOK: LSH	U,11		;SET UP FOR I/O
	CONO	DTC,STP+SEL(U)	;SELECT THE DRIVE
	CONSO	DTS,SELERR	;SELECT ERROR?
	 JRST	SELOK		;NO--USE THIS DRIVE
	LSH	U,-11		;JUSTIFY IT
TAPES:	CAIG	U,4		;MORE DRIVES?
	AOJA	U,WRTMOK	;YES--TRY THE NEXT ONE
	OUTSTR	[ASCIZ/
% At least one drive must be set to REMOTE and write enabled
/]
	MOVEI	A,^D15		;WAIT FOR 15 SECONDS
	SLEEP	A,		;
	JRST	WRTMCK		;AND TRY AGAIN
SELOK:	CONSZ	DTS,WRTLCK	;IS THE DRIVE WRITE ENABLED?
	 JRST	TAPES		;NO--TRY FOR ANOTHER DRIVE

	MOVE	I,II		;GET THE INDEX
	TLZ	I,777777	;SCREW AROUND WITH IT
	MOVEM	I,II		;AND PUT IT BACK

;THE DECTAPE HAS SEVERAL AREAS.  THE ENDZONE,BLOCKS,ENDZONE
;THE FIRST ENDZONE HAS ENDZON/2 ZEROS, ENDZON ENDZONE MARKS
;THE BLOCK HAVE 2 BNS AND 128 DATA WORDS
MARKS:	PUSHJ	P,WRTMK1	;WRITE THE TIMING MARKS
	OUTSTR	[ASCIZ/
Remount tape (if necessary), then turn off WRTM switch
/]
WRTOFF:	CONSO	DTS,WRTSW	;CHECK FOR THE SWITCH BEING OFF
	JRST	WTOFF		;OK--IT IS OFF
	MOVEI	A,1		;TIME TO SLEEP
	SLEEP	A,		;SLEEP
	JRST	WRTOFF		;LOOP TILL THE OPR RESPONDS

WTOFF:	PUSHJ	P,TMKBM			;WRITE THE BLOCK MARKS
	PUSHJ	P,DMPRTP		;GIVE THE CONTROLER BACK TO THE SYSTEM
	OUTSTR	[ASCIZ/Tape OK
Please type in the DECtape label for DTA/]
	LSH	U,-11			;RIGHT JUSTIFY THE DRIVE NUMBER
	MOVEI	A,60(U)			;MAKE INTO A NUMBER
	OUTCHR	A			;PRINT THE DECTAPE DRIVE NUMBER
	OUTSTR	[ASCIZ/: /]		;FOR CONFUSED OPERATORS
	PUSHJ	P,GETNAM		;GET THE LABEL FOR THE TAPE
	DPB	U,[POINT 4,.+1,12]
	USETO	U,144			;WRITE THE DIRECTORY BLOCK NEXT
	DPB	U,[POINT 4,.+1,12]
	OUTPUT	U,DIRECT		;OUTPUT THE DIRECTORY
	DPB	U,[POINT 4,.+1,12]
	MTAPE	U,11			;REWIND/UNLOAD THE DECTAPE
	JRST	DTCRTX			;AND START OVER AGAIN

GETDTA:	ZZ=0
	SALL				;WE KNOW IT WORKS
	MOVEI	A,0
	DEFINE	DTINIT(ZZ)
		<	
			OPEN ZZ,[117
			SIXBIT /DTA'ZZ/
			0]
			JRST NODTA
			MOVEI	A,1(A)
>
	REPEAT 8,<	DTINIT(\ZZ)
			ZZ==ZZ+1>
	HRRM	A,TAPES			;SAVE THE NUMBER OF DRIVES
CPOPJ:	POPJ	P,			;AND RETURN

NODTA:	HRRM	A,TAPES			;SAVE FOR LATER
	ADDI	A,20			;MAKE SIXBIT
	LSH	A,^D12			;POSITION TO DTAX
	HRLI	A,(SIXBIT/DTA/)		;ADD DTA TO X
	DEVCHR	A,			;FIND OUT ABOUT DTAX:
	JUMPE	A,CPOPJ			;DOES NOT EXIST, RETURN
	TLON	F,WAIT			;PRINT SOMETHING THE FIRST TIME ONLY
	OUTSTR	[ASCIZ/
% Someone has a DECtape drive other than me.
% Please free all DECtape drives.
/]
	MOVEI	A,1			;TIME TO SLEEP
	SLEEP	A,			;SLEEP
	RESET				;DEASIGN THE DRIVES
	JRST	GETDTA			;AND TRY AGAIN

NOLOCK:	TTCALL	3,[ASCIZ/
LOCK UUO failed!
/]
	EXIT

NORTT:	TTCALL	3,[ASCIZ/
? The RAT TRAP UUO failed, error code in AC0
/]
	MOVE	0,A		;SAVE THE ERROR CODE
	RESET
	EXIT
WRTMK1:	SETZM	DTACSO
	MOVNI	A,ZONSIZ/2	;2342 OCTAL
	MOVEM	A,AA		;SAVE IT
	MOVE	A,[WRTST(I)]	;PLACE TO START
	MOVEM	A,DISPAT
	MOVEI	A,ERRA		;PREPARE FOR THE WORST
	MOVEM	A,MSG		;AND SAVE IT
	SETZM	DONFLG
	MOVE	A,[404404,,404404]	; End zone mark
	MOVEM	A,EE		;WRITE end zone marks FOR A WHILE
	MOVEI	A,1		;
	SLEEP	A,		;SLEEP FOR A WHILE
	MOVE	I,II		;GET THE INDEX
	SETFST			;SET UP FOR FAST INTERUPT SERVICE
	MOVEM	I,II		;AND PUT IT BACK
	MOVEI	A,3		;BITS TO SKIP ON
	CONO	PI,PIOFF	;TURN OFF THE PI SYSTEM
	CONO	DTS,770000	;ENABLE ALL BITS
	CONO	DTC,FWD+SEL+WMT+PIF+PID(U)	;START THING GOING
	JRST	CHKERR		;FINISH UP AND CHECK FOR ERRORS

RTBLK:	XWD	PIA,INTADR
	XWD	1,APRTRP	;EXECT	MODE	RAT-TRAPPING
	CONSO	DTS,@DTACSO
	Z

;HERE TO EXCHANGE THE REGISTERS.  IF WE DON'T SAVE THE WORLD, WHO WILL?
;THIS CODE IS EXECUTED AS PART OF THE MONITOR.  IF SOMETHING GOES
;WRONG, KISS THE SYSTEM GOOD-BYE.


INTADR:	0			;FIRST PLACE TO GO ON AN INTERUPT
INTST:	EXCH	I,II		;SAVE I AND GET INDEX
	JUMPL	I,FSTINT(I)	;JUMP FOR FAST INTERUPT SERVICE
	EXCH	A,AA(I)		;SAVE A
	EXCH	C,CC(I)		;SAVE C
	EXCH	D,DD(I)		;SAVE D
	EXCH	E,EE(I)		;SAVE E
	EXCH	P,PP(I)		;SAVE P
	JRST	@DISPAT(I)	;GO TO THE PROPER ROUTINE

DISPAT:	0			;RETURN HERE TO RESTORE THE REGISTORS
RESTR:	EXCH	A,AA(I)		;RESTORE A
	EXCH	C,CC(I)		;RESTORE C
	EXCH	D,DD(I)		;RESTORE D
	EXCH	E,EE(I)		;RESTORE E
	EXCH	P,PP(I)		;RESTORE P
FSTEND:	EXCH	I,II(I)		;RESTORE I
INTEND:	JRSTF	@INTADR		;RETURN TO THE USER WE INTERUPTED
				;WE HAVE NOW USED FROM 50 TO 90 uS.

APRTRP:	0
	JRST	STOP(I)		;CALL IT QUITS

;
;HERE TO WRITE THE TIMING MARKS AT INTERUPT LEVEL
;
WRTST:	DATAO	DTC,E			;FINISH WRITING small end zone leader

	MOVNI	A,ZONSIZ		;GET THE SIZE OF THE ENDZONE
	MOVE	E,[404404,,404404](I)	;ZONE MARKS
	GOFAST				;OUTPUT THE MARKS

	MOVEI	D,BLKNUM		;NUMBER OF BLOCKS PER DECTAPE
WMTBLK:	MOVE	A,[-4,,-4](I)		;INDEX FOR TABLE
	MOVEI	C,TICKMK(I)		;RELOCATE ADDRESS
	HRRM	C,.+1(I)		;SAVE FOR LATER USE
WMTFBN:	MOVE	E,(A)			;GET THE PROPER WORD
	GOWORD				;OUTPUT IT
	AOBJN	A,WMTFBN(I)		;LOOP TIL DONE WITH FWD + 1/2 DATA WD

	MOVE	E,TICKMK(I)		;TIMING MARKS FOR DATA
	MOVNI	A,<BLKSIZ-1>-3		;WRITE BLKSIZ-3 MARKS (-2 -1/2 -1/2)
	GOFAST				;WRITE THE DATA MARKS

	MOVE	A,[-4,,-3](I)		;NEW INDEX
	MOVEI	C,TICKND(I)		;RELOCATE TABLE
	HRRM	C,.+1(I)		;SAVE IT
WMTRBN:	MOVE	E,(A)			;NOW GET THE PROPER WORD
	GOWORD				;OUTPUT E
	AOBJN	A,WMTRBN(I)		;LOOP TIL DONE WITH REAR BLOCK NUMBER
	SOJG	D,WMTBLK(I)		;LOOP TIL DONE WITH ALL THE BLOCKS

	MOVE	E,[040040,,040040](I)
	MOVNI	A,ZONSIZ		;SIZE OF THE END ZONE
	GOFAST				;OUTPUT THE ENDZONE
	RETURN				;RETURN
;
;WHEN WE ARE ALL DONE WITH THE INTERUPT ROUTINES
;
STOP:	CONI	DTS,TT1(I)		;SAVE THE WAY THINGS ARE
	CONO	DTS,1			;STOP ALL TAPE FUNTIONS
	CONO	DTC,STP			;STOP THE TAPE
	CONO	DTC,DESEL		;DESELECT THE TAPE
	SETOM	DONFLG(I)		;REMEMBER WE FINISHED
	SETZM	DTACSO(I)		;CLEAR CONSO BITS
	TLZN	I,400000		;FAST INTERUPT?
	DISMIS				;NO--JUST RETURN
	JRST	FSTEND(I)		;YES--END IT THE FAST WAY

;FST.E SETS UP FOR FAST INTERUPT SERVICE.  GOOD FOR OUTPUTING LOTS OF
;THE SAME DATA.  THE COUNT IS IN 'A'.  THE DATA IS IN 'E'

FST.E:	SETFST			;SET FOR FAST INTERUPTS

;
;HERE TO DO AN OUTPUT (DATAO) FROM THE CONTENTS OF 'E'.  WE WAIT FOR AN
;INTERUPT BEFORE WE DO ANY OUTPUT
;
OUT.E:	WAIT			;WAIT FOR AN INTERUPT
	CONSZ	DTS,IOERR	;DID AN ERROR OCCUR?
	 ERROR			;YES--GO DO SOME THING
	DATAO	DTC,E		;OTHER WISE OUTPUT IT
	JRST	(P)		;AND RETURN

;
;HERE TO READ BACK DATA AND COMPARE IT WITH WHAT IS IN E
;
IN.D:	WAIT			;WAIT FOR AN INTERUPT
	CONSZ	DTS,IOERR	;CHECK FOR ERRORS
	 ERROR			;JUST FOUND ONE
	DATAI	DTC,D		;GET THE WORD
	CAMN	E,D		;IS IT THE SAME?
	JRST	(P)		;GOOD--RETURN
	JRST	DATERR(I)	;NO--PRINT AN ERROR MESSAGE

;FSTINT GIVES FAST SERVICE TO INTERUPTS. ONLY REGISTER 'I' IS SAVED.
;FAST INTERUPT SERVICE IS SIGNALED BY THE SIGN BIT BEING ON
;IN THE INDEX REGISTER.

FSTINT:	CONSZ	DTS,IOERR	;ANY ERRORS?
	 JRST	FSTERR(I)	;YES--DO SOMETHING HANLEY
	DATAO	DTC,EE(I)	;OUTPUT THE INFO
	AOSL	AA(I)		;DECREMENT THE COUNT BY ONE
	 CLRFST			;CLEAR THE FAST INTERUPT FLAG
	JRST	FSTEND(I)	;AND RETURN
;
;HERE TO CHECK FOR ERRORS WHEN WE ARE DONE WITH INTERUPTS
;
CHKERR:	MOVEM	A,DTACSO	;SAVE THE BITS TO SKIP ON
	CONO	PI,PION		;TURN BACK ON THE PI SYSTEM
	MOVEI	A,5		;TIME TO SLEEP
	SLEEP	A,		;SLEEP FOR A WHILE
	SKIPN	DONFLG		;HAS THE INTERUPT SIDE FINISHED?
	 JRST	.-3		;NO--SLEEP SOME MORE

	SKIPE	APRTRP		;DID WE GET AN APR ERROR?
	 JRST	APRERR		;YES--AND THE SYSTEM IS STILL RUNNING!!!!
	SKIPN	ERRFLG		;CHECK FOR AN ERROR
	 POPJ	P,		;NO ERRORS
	OUTSTR	@MSG		;PRINT OUR ERROR MESSAGE
	MOVE	A,TT1		;GET THE CONI BITS
	TRNE	A,400000	;PARITY ERROR?
	OUTSTR	[ASCIZ/? Tape parity error
/]
	TRNE	A,200000	;DATA MISSED?
	OUTSTR	[ASCIZ/? Data missed
/]
	TRNE	A,40000		;ILLEGAL OPERATION?
	OUTSTR	[ASCIZ/? Illegal operation
/]
	TRNE	A,20000		;END ZONE FOUND?
	OUTSTR	[ASCIZ/? End zone when data request expected
/]
	TRNE	A,10000		;BLOCK MISSED?
	OUTSTR	[ASCIZ/? Block missed
/]
	TRNE	A,200		;TIMING MARK ERROR?
	OUTSTR	[ASCIZ/? Mark track error
/]
	TRNE	A,100		;SELECT ERROR?
	OUTSTR	[ASCIZ/? Select error
/]
	TRNE	A,1		;DATA REQUEST?
	OUTSTR	[ASCIZ/? Data request when end zone expected
/]
	OUTSTR	[ASCIZ/% The DECtape must be recertified
% Remount it with as LITTLE leader as possible
/]				;TELL THEM THE PROBLEMS
	CONO	DTC,RVS+SEL(U)	;REVERSE THE CURRENT DRIVE
	CONO	DTC,DESEL	;AND FORGET ABOUT IT (IT WILL UNLOAD)
	TLZ	F,WAIT		;CLEAR THE FLAG
ERRFIN:	CONSO	DTS,WRTSW	;SKIP IF THE WRTM SWITCH IS ON
	 JRST	DTCRTX		;OFF--LET THE OPR TRY AGAIN
	TLON	F,WAIT		;SKIP AFTER THE FIRST TIME
	OUTSTR	[ASCIZ/% Please turn off the WRTM switch
/]
	MOVEI	A,1		;TIME TO WAIT
	SLEEP	A,		;WAIT FOR THE OPR TO RESPOND
	JRST	ERRFIN		;AND RECHECK
;
;HERE TO WRITE BLOCK NUMBERS AND DATA ON THE DECTAPE.
;
TMKBM:	SETZM	DONFLG		;CLEAR DONE FLAG
	MOVE	[LSTDST(I)]	;FIRST INTERUPT SHOULD GO HERE
	MOVEM	DISPAT		;SAVE IT
	MOVEI	ERRB		;CURRENT ERROR MESSAGE
	MOVEM	MSG		;SAVE IT
	CONO	DTC,RVS+SEL(U)	;START BACKING UP
	MOVEI	A,3		;TIME TO DELAY
	SLEEP	A,		;BACK OUT INTO THE DATA PART OF THE TAPE
	MOVEI	A,3		;CONSO SKIP BITS
	CONO	PI,PIOFF	;KILL THE PI SYSTEM
	CONO	DTS,770000	;ENABLE ALL BITS
	CONO	DTC,CHG+WRITEA+PIF+PID	;BACK TO THE ENDZONE, WRITE ALL
	JRST	CHKERR		;FINISH UP AND CHECK FOR ERRORS

;
;HERE ARE THE INTERUPT LEVEL ROUTINES FOR WRITING BLOCK NUMBERS AND TEST DATA
;
LSTDST:	CONSZ	DTS,ENDZON		;END ZONE?
	 JRST	MOVFWD(I)		;YES--ALL DONE WITH THIS PASS
	CONSZ	DTS,IOERR		;WAS IT A DATA (BN) REQUEST?
	 ERROR				;NO--PRINT AN ERROR MESSAGE
	DATAO	DTC,DATA(I)		;WRITE DATA ALL OVER EVERYTHING
	DISMIS				;AND DISMISS THE INTERUPT

MOVFWD:	CONO	DTC,FWD			;FORWORD JAMES
	CONO	DTC,CHG+WRITEA+PIF+PID	;CHANGE DIRECTION AND WRITE ALL

	MOVEI	C,BLKNUM-1		;FIRST BLOCK NUMBER ENCOUNTERED
BNNBLK:	MOVEI	E,(C)			;GET THE FORWARD LEADING BN
	GOWORD				;OUTPUT IT

	 SOJL	C,CHKBN(I)		;TIME TO LEAVE

	SETCMI	E,(C)			;FORWARD TRAILING BN
	JSP	P,REVERS(I)		;REVERSE IT
	GOWORD				;OUTPUT IT

	MOVE	E,DATA(I)		;GET THE DATA TO WRITE
	MOVNI	A,<BLKSIZ-1>+2		;WRITE 130 (128+2) WORDS OF DATA
	GOFAST				;OUTPUT ALL OF THEM
	JRST	BNNBLK(I)		;LOOP TIL ALL THE BLOCKS ARE DONE
;
;HERE ARE THE INTERUPT LEVEL ROUTINES FOR CHECKING THE BN'S AND TEST DATA
;
CHKBN:	WAIT				;WAIT FOR THE NEXT INTERUPT
	CONSZ	DTS,ENDZON		;LOOK FOR THE END ZONE
	 JRST	CHKPAS(I)		;FOUND IT
	CONSZ	DTS,IOERR		;IO ERROR?
	 ERROR				;YES
	DATAO	DTC,[0](I)		;OUTPUT FILLER
	DISMIS				;TRY THE NEXT INTERUPT

CHKPAS:	CONO	DTC,RVS			;CONTINUE INTO THE END ZONE
	CONO	DTC,CHG+READA+PIF+PID	;THEN A QUICK REVERSE (FORWARD)
	MOVEI	P,ERRC			;NEXT ERROR MESSAGE
	MOVEM	P,MSG(I)		;SAVE FOR LATER

	MOVEI	C,1			;START WITH THE FIRST BLOCK
RDNBLK:	SETCMI	E,-1(C)			;COMPLEMENT IT
	JSP	P,REVERS(I)		;REVERSE IT
	JSP	P,IN.D(I)		;CHECK THE FORWARD TRAILING BN

	MOVEI	E,(C)			;PICK UP THE FORWARD LEADING BN
	JSP	P,IN.D(I)		;CHECK IT

	MOVNI	A,BLKSIZ+2		;TIMES DATA SHOULD BE THERE (128+2)
	MOVE	E,DATA(I)		;WHAT SHOULD BE THERE
RDBLK:	JSP	P,IN.D(I)		;CHECK IT
	AOJL	A,RDBLK(I)		;LOOP FOR WHOLE DATA AREA
	MOVEI	C,1(C)			;GO TO THE NEXT BLOCK
	CAIGE	C,BLKNUM		;END YET?
	JRST	RDNBLK(I)		;NOPE-KEEP GOING
;
;HERE TO WRITE ZERO DATA ON THE DECTAPE AT INTERUPT LEVEL
;
	WAIT				;WAIT FOR THE NEXT INTERUPT
	CONSZ	DTS,ENDZON		;WAS IT AN ENDZONE?
	 JRST	FINDAT(I)		;YES--FINISH UP
	CONSZ	DTS,IOERR		;ALL OK FOR LAST BN?
	 ERROR				;NO--
	DATAI	DTC,E			;FIX THE DATA REQUEST FLAG
	DISMIS				;TRY THE NEXT INTERUPT

FINDAT:	MOVEI	A,ERRD			;NEXT ERROR MESSAGE
	MOVEM	A,MSG(I)		;AND SAVE IT
	CONO	DTS,760000		;TRIP ON ALL BUT BLOCK MISSED
	CONO	DTC,FWD			;INTO THE ENDZONE
	CONO	DTC,CHG+WRITED+PIF+PID	;REVERSE THINGS AND SET FOR WRITE DATA

	WAIT				;WAIT FOR AN INTERUPT
	CONSZ	DTS,745700		;SKIP IF NO ERRORS
	 ERROR				;FOUND ONE
	CONSZ	DTS,ENDZON		;END ZONE?
	 RETURN				;YES--EVERY THING IS OK, QUIT NOW
	CONSO	DTS,1			;MAKE SURE IT WAS A DATA REQUEST
	 ERROR				;NO DATA REQUEST
	DATAO	DTC,[0](I)		;WRITE THE ZEROS
	DISMIS				;AND LET IT GO
;
;HERE ARE THE VARIOUS ERROR MESSAGES AND ROUTINES
;
APRERR:	OUTSTR	[ASCIZ/? APR error at interupt level - Call a systems programmer
/]
	EXIT			;BEFORE WE MESS UP SOMETHING ELSE

;WHEN AN ERROR HAPPENS WHILE WRITING THINGS THE FAST WAY
;
FSTERR:	TLO	I,004700	;HANLEY ALLEN STRAPPMAN WAS HERE.  RNAA 47

;NORMAL ERROR COME HERE
;
ERR:	SETOM	ERRFLG(I)	;REMEMBER THE ERROR
	JRST	STOP(I)		;AND FINISH UP

	XLIST	;LABELS INSIDE ARE ERRA, ERRB, ERRC, ERRD, DATERR.
ERRA:	ASCIZ/% Error during write of timing marks
/

ERRB:	ASCIZ\% Error during write of block numbers/Data
\

ERRC:	ASCIZ\% Error during read of block numbers/Data
\

ERRD:	ASCIZ/% Error while writing zero data
/

DATER1:	ASCIZ/% Previously written data is no longer correct
/
	LIST

DATERR:	MOVEI	A,DATER1
	MOVEM	A,MSG(I)	;SAVE IT FOR LATER
	 ERROR		

;
;OTHER MESSAGES OF INTEREST
;
	XLIST	;LABELS INSIDE ARE STMSG.
STMSG:	ASCIZ/
Mount DECtapes to be certified on an available drive and make
the drive ready.  This program will pick up the drive
automaticly and instruct you from there.  The drives must be set
REMOTE and write enabled.  Use as LITTLE leader as possible when
mounting tapes.
/
	LIST

;
;TIMING BITS
;
	040404040440	;FWD BN
	044040004000	;REV GUARD
	004000004000	;REV CHKSUM AND 1ST HALF DATA WD
	004000444000	;2ND +3RD HALF DATA WORD
TICKMK:	444000444000	;REST OF DATA
	444000444044	;LAST-3 + LAST-1 HALF DATA WORDS
	444044444044	;LAST HALF DATA WD AND FWD CHKSUM
	444044404004	;FWD GUARD
TICKND:	400404040404	;RVS BN

DATA:	252525,,252525	;DATA FOR DATA AREAS

;
;HERE TO REVERSE THE NUMBER IN E
;
REVERS:	EXCH	T1,TT1(I)	;SAVE TEMP 1
	EXCH	T2,TT2(I)	;SAVE TEMP 2
	MOVE	T1,E		;COPY E FOR REVERSAL
	REPEAT	6,<
		ROTC	T1,-3
		ROT	T2,6>
	ROT	T2,-3
	HRLO	E,T2		;PLACE RESULT BACK INTO E
	EXCH	T1,TT1(I)	;RESTORE TEMP 1
	EXCH	T2,TT2(I)	;RESTORE TEMP 2
	JRST	(P)		;RETURN

;
;HERE WHEN SOMEONE TYPES A CONTROL-C
;
CCTRP:	4,,CCDIE		;WHERE TO GO WHEN WE GET ONE
	0,,2
CCPC:	EXP 0,0

CCDIE:	SETZM	CCPC		;RESET THE INTERUPT
	JSP	A,.+1		;GET OUR PC
	TLNN	A,4000		;USER I/O?
	 JRST	DIE		;NO--JUST DIE
	CONO	DTS,1		;FUNTION STOP
	CONO	DTC,STP+SEL(U)	;STOP THE DRIVE
	CONO	DTC,DESEL	;DESELECT THE DRIVE
	PUSHJ	P,DMPRTP	;GIVE BACK ALL DEVICES
	SETOM	DONFLG		;CALL IT FINISHED
	SETZM	DTACSO		;CLEAR THE SKIP ADR
	RESET			;LET THE MONITOR CLEAN UP
DIE:	SETZM	134		;DISABLE THE INTERCEPT
	RESET			;PUT THE WORLD BACK TOGETHER
	EXIT	1,		;EXIT FOR NOW
	OUTSTR	[ASCIZ/
[ Restarting DTCERT ]
/]
	JRST	DTCRTX		;RESTART IF HE WANTS

;
;HERE TO PICK UP THE LABEL FOR THE DECTAPE
;
GETNAM:	SETZM	LABEL
	MOVE	T1,[POINT 6,LABEL]
INNAM:	INCHWL	A			;WAIT FOR A LINE TO BE TYPED IN
	CAIL	A,40			;SOME CONTROL CHR?
	 JRST	CHGOOD			;WE LIKE WHAT HE TYPED IN
DMPCHR:	INCHRS	A			;GET THE NEXT CHR
	 POPJ	P,			;ALL DONE
	JRST	DMPCHR			;LOOP TILL ALL GONE

CHGOOD:	CAILE	A,137			;IS IT UPPER CASE?
	 TRZ	A,40			;NO--MAKE IT UPPER CASE
	TRC	A,40			;MAKE IT SIXBIT
	IDPB	A,T1			;PLACE THE CHR AWAY
	TLNE	T1,770000		;ANY MORE CHR TO BE FITTED?
	 JRST	INNAM			;YES--SEE IF HE TYPED THEM
	JRST	DMPCHR			;NO MORE--THROUGH THE REST AWAY

;HERE WE GIVE BACK THE DEVICES TO THE MONTOR SO STRANGE THINGS DON'T HAPPEN
;
DMPRTP:	MOVEI	A,DRTBLK	;GET THE ZERO BLOCK
	CONO	DTS,0		;TURN OFF THE WORLD
	RTTRP	A,		;DUMP THE DEVICES
	OUTSTR	[ASCIZ/
% RTTRP to dismis devices fails
/]				;LET THEM KNOW IT HAPPENED
	POPJ	P,		;AND RETURN

DRTBLK:	XWD	0,0		;
	XWD	0,0		;
	CONSO	DTS,0		;TURN OFF EVERY THING
	XWD	0,0		;
;
;THIS IS WHAT THE ZEROED DIRECTORY SHOULD LOOK LIKE
;
DIRECT:	IOWD	200,DTADIR	;I/O POINTER
	0			;END OF POINTER
	XLIST	;LABELS INSIDE ARE DTADIR, LABEL.
DTADIR:	BYTE	(5)36,36,0,0,0,0,0					;0
	EXP	0,0,0,0,0,0,0,0,0,0,0,0,0				;13
	BYTE	(5)0,36,0,0,0,0,0					;14
	EXP	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		;37
	EXP	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		;59
	EXP	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		;81
	IFE	LONG,<
	0
>
	IFN	LONG,<
	BYTE	(5)0,0,0,37,37,37,37					;82
>
	EXP	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		;104
	EXP	0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		;126
LABEL:		0							;127
	LIST


;
;STORAGE
;
MSG:	Z		;MESSAGE POINTER
DONFLG:	Z		;DONE FLAG
ERRFLG:	Z		;ERROR FLAG
DTACSO:	Z		;CONSO SKIP BITS
PDLST:	BLOCK	10

	END	DTCERT