PEDRO - POP2 EXECUTIVE FOR DECTAPE RECORD OUTPUT
/OUTPUTS DECTAPE FILES DURING MULTI-POP TO PUNCH OR LINE PRINTER
/R J COWE, COMPUTER-AIDED DESIGN PROJECT, UNIVERSITY OF EDINBURGH
/DATE 10.8.70
/USES FODDER FILE READING ROUTINES AND DTBTRN
ATSEND=2	/EXEC ROUTINE TO GENERATE AN ATTENTION
FIXED=3000	/START OF USER AREA
FIXED/	0
	HLT
	HLT
FIXED 6/	JMP 3006	/DO NOTHING
FIXED 20/	0	HLT	/USER CAL
FIXED 22/	JMP XOPEN	/OPENS A FILE WHEN REQUESTED
FIXED 23/	JMP XNEXT	/GETS NEXT BLOCK OF FILE
XUNIT=FIXED+24
NMBUFF=FIXED+25
XSTAT=FIXED+32
FIOBUF=FIXED+33
XOPEN=FIOBUF+400
NMBUFF+4/	401	/NO OF WORDS TO BE TRANSFERRED TO 4130
/******
/******
/START OF FILE READING ROUTINES
XOPEN/	LAC XUNIT	/INFORMATION BLOCK SENT FROM 4130
	DAC NB-1	/TRANSPORT NUMBER
	JMS DBREAD	/READ DIRECTORY
	JMS VCHECK	/SEE IF NAME VALID
	JMP XNEXT1	/NAME NOT FOUND
	LAC SAVE#	/HERE IF NAME VALID - INDEX NUMBER
	JMS DENTRD	/GET DIRECTORY ENTRY
	LAC NMBUFF+3	/START BLOCK
	AND (1777)
XOP2,	DAC NB
	LAC 2	/SAVE TRAP CALL
	DAC TEMP#
	LAC (JMP .+3)
	DAC 2	/NEXT INSTRUCTION CAUSES TRAP TO BE SWITCHED OFF
		/AND CONTROL TO GO TO DECTAPE ROUTINES
	IOF	/WILL BE TRAPPED
	JMS TREAD
	LAC TEMP	/RESTORE TRAP CALL
	DAC 2
	ITON	/SWITCH TRAP ON
	DZM XSTAT	/O.K.
XOP1,	LAW NMBUFF+4
	CAL ATSEND	/GENERATE ATTENTION
	JMP .-1
	JMP .	/DO NOTHING UNTIL 4130 ASKS
XNEXT,	JMS DIRGET
	LAC FIOBUF+377
	ADD NB
	DAC DIRSAV#
	LAC FIOBUF+377
	SMA	/EOF?
	JMP XOP2
	LAC (4)
	SKP
XNEXT1,	LAC (1)
	DAC XSTAT
	JMP XOP1
TREAD,	0	/READS A BLOCK
	LAM -2
	DAC #TRIES
	LAC DIRSAV	/SET DIRECTION
	DAC NB+4
	DZM #DFAULT
	LAC (FIOBUF)	/INITIALISE BUFFER
	DAC PTR
	LAC (1)
	JMS DTBTRN
	1	/HANDLER NUMBER - ASSUMES UNIT 1 ON FIRST LOADING
NB,	-0	/BLOCK NUMBER
	RHANLR	/WORD HANDLING ROUTINE
	DECERR	/ERROR HANDLER
	0	/READ
	0	/FORWARD OR REVERSE
TRDEND,	LAC DFAULT
	SNA
	JMP I TREAD
	ISZ TRIES
	JMP TREAD+5
	LAC (2)	/HARDWARE ERROR
	JMP XNEXT1+1
DECERR,	0
	DAC DFAULT
	MMRS
	AND (1000)	/SEE IF TAPE UNABLE BIT SET
	SGZ
	JMP I DECERR
	CLA
	MMLC	/STOP TAPE
	LAC (3)	/TAPE NOT READY
	JMP XNEXT1+1
DBREAD,	0	/LOADS DIRECTORY BLOCK (100)
	DZM DIRSAV
	LAC (100)
	DAC NB
	LAC 2	/SAVE TRAP CALL
	DAC TEMP
	LAC (JMP .+3)
	DAC 2
	IOF
	JMS TREAD
	LAC TEMP
	DAC 2	/RESTORE TRAP CALL
	ITON
	JMP I DBREAD
RHANLR,	0	/FOR READING
	DAC I #PTR
	ISZ PTR
	JMP I RHANLR
VCHECK,	0	/CHECKS VALIDITY OF A FILE NAME IN NMBUFF
	LAC NMBUFF
	SNA	/EXAMINE FIRST THREE CHARACTERS FOR A
		/ZERO ENTRY WHICH IS ILLEGAL
	JMP VCK2	/EXECUTE ERROR EXIT
	LAW FIOBUF+40	/BUFFER START FOR DIRECTORY ENTRY
	DAC ADD#SVE
	DZM SAVE	/ZERO INDEX COUNTER
	LAM -67	/NO OF FILES
	DAC SCN#T
VCK1,	DZM DCHECK	/CHECK COUNTER TO SEE IF ENTRY
			/EXISTS UNDER SAME NAME
	LAC I ADDSVE
	SAD NMBUFF
	ISZ DCHECK
	ISZ ADDSVE
	LAC I ADDSVE
	SAD NMBUFF+1
	ISZ DCHECK#
	ISZ ADDSVE
	LAC I ADDSVE
	SAD NMBUFF+2
	ISZ DCHECK
	ISZ ADDSVE
	LAC DCHECK
	SAD (3)	/IF 3 NAME HAS ALREADY BEEN USED
	JMP VCK2	/ERROR EXIT IF ESTABLISHING
			/A NEW FILE, BUT IS CORRECT
			/EXIT IF DELETING OR RENAMING
	ISZ ADDSVE
	ISZ SAVE	/INCREMENT INDEX COUNTER
	ISZ SCNT	/FINISHED?
	JMP VCK1
	JMP I VCHECK	/CORRECT EXIT
VCK2,	ISZ VCHECK
	JMP I VCHECK	/ERROR EXIT
/EXITS WITH AC ALL 1'S IF NAME EXISTS
DFTRAN,	0	/ SWOPS N WORDS
	DAC SCNT
	LAC I FADDR	/ FROM
	DAC I FSAVER	/ TO
	ISZ SCNT
	JMP .-3
	JMP I DFTRAN
/AUTO-INDEX REGISTERS
FADDR=13
FSAVER=14
DENTRD,	0	/READS OFF DIRECTORY ENTRY. INDEX IS IN AC AT ENTRY
	ALSS+2
	ADD (FIOBUF+37)
	DAC FADDR
	LAW NMBUFF-1
	DAC FSAVER
	LAM -3
	JMS DFTRAN
	JMP I DENTRD
DIRGET,	0	/ESTABLISHES READ DIRECTION
	XCT I DIRGET	/FIRST PARAMETER (DATA LINK)
	ISZ DIRGET
	CMA
	XCT I DIRGET	/2ND. PARAMETER (LAST BLOCK)
	SMA!CLA
	LAM
	ISZ DIRGET
	JMP I DIRGET
START

