Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50035/ecmser.mac
There are no other files named ecmser.mac in the archive.
	TITLE ECMSER - PDP-8 CONNECTED TO PDP-10 MEMORY SERVICE ROUTINE
	SUBTTL PETER M. HURLEY  JULY 30,1969  V001

	ENTRY ECMSER
ECMSER:
	INTERNAL ECMDSP,ECMDDB,ECMDDS,ECMTYP,AOSPC
	INTERNAL DVAINT,DVBINT,ERRCNT
	INTERNAL DEVTRP,DEVIPC


	;ECMDSP    -   ECM DISPATCH TABLE

	JRST ECMINI	;INITIALIZATION
	JRST ECMHNG	;HUNG DEVICE
ECMDSP:	JRST ECMRLS	;RELEASE
	POPJ PDP,	;CLOSE
	POPJ PDP,	;NON-DUMP OUTPUT
	POPJ PDP,	;NON-DUMP INPUT
	JRST ECMENT	;ENTER (SET PDP-8 OUTPUT ADDRESS)
	JRST ECMLKP	;LOOKUP (SET PDP-8 INPUT ADDRESS)
	JRST ECMOUT	;DUMP OUTPUT
	JRST ECMIN	;DUMP INPUT
	JRST ECMRQ	;USETO (GENERATE INTERRUPT)
	JRST ECMSET	;USETI (SET INTERRUPT ENTRY)
	JRST ECMDSM	;UGETF (DISMISS INTERRUPT)
	POPJ PDP,	;RENAME
	POPJ PDP,	;CLOSE INPUT
	POPJ PDP,	;UTPCLR
	POPJ PDP,	;MTAPE
	;ECMDDB  -  ECM DEVICE DATA BLOCK

ECMDDB:	SIXBIT /ECM0/	;DEVNAM
	XWD 4*HUNGST,0	;DEVCHR
	0		;DEVIOS
	EXP ECMDSP	;DEVSER
	XWD DVLNG+DVDIR+DVIN+DVOUT,140000
	0		;DEVLOG
	0		;DEVBUF - POINTER TO COMMAND LIST
	0		;DEVCIA - STARTING ADDRESS OF PDP-8 INPUT
	0		;DEVCOA - STARTING ADDRESS OF PDP-8 OUTPUT
	0		;DEVCTR - NEXT IOWD TO BE DONE
	0		;DEVTRP
	0		;DEVIPC
	0		;DEVINF
	0		;DEVREQ
	0		;DEVICW
	0		;DEVSTS
	10*2000		;DEVLIM - ASSUME 8K PDP-8

ECMDDS=.-ECMDDB		;DEVICE DATA BLOCK SIZE
	;BIT DEFINITIONS

	;DEVIOS DEVICE DEPENDENT BIT ASSIGNMENTS

	RDY=400000	;READY TO SEND OUT INFORMATION TO THE PDP-8
	REPT=200000	;REPEATING TRANSFER
	CP=100000	;CHARACTER PENDING TO GO OUT
	IRP=40000	;INTERRUPT REQUEST PENDING
	IOP=20000	;IO PENDING
	IOIP=4000	;IO IN PROGRESS
	EIP=2000	;ECHO IN PROGRESS
	RIP=1000	;REQUEST IN PROGRESS
	RCB=400		;REQUEST OR CHARACTER BIT
	RF8=200		;REQUEST FROM PDP-8
	JSI=100		;JOB IS CURRENTLY SERVICING AN INTERRUPT
	PARITY=400

	;REQUEST DEFINITIONS

	CHREQ=1		;CHARACTER REQUEST
	INTREQ=2	;INTERRUPT REQUEST
	INREQ=4		;INPUT REQUEST
	OUTREQ=3	;OUTPUT REQUEST

	;DDB DEFINITIONS

	DEVCIA=7
	DEVCOA=10
	DEVTRP=12
	DEVIPC=13
	DEVINF=14
	DEVREQ=15
	DEVICW=16
	DEVSTS=17
	DEVLIM=20
	;OTHER DEFINITIONS

	;AC DEFINITIONS

	DDB=DEVDAT
	CHREC=TEM
	LINE=TAC1
	STS=DAT

	DEVA=450
	DEVB=454

	;DA-25 FLAGS

	EOT=20
	WCOF=40
	INOUT=4000
	REQ=10
	SCAN=20000
	DONE=10

	AOSPC=2


	;EXTERNAL DEFINITIONS

	EXTERNAL ADRERR,COMCHK,CPOPJ,CPOPJ1,PIOFF,PION,PJOBN,PUNIT
	EXTERNAL SETACT,SETIOD,UADCK1,UADRCK,JBTADR,ERRDEV,PCSTOP,WSYNC
	EXTERNAL RECINT,XMTINT

	EXTERNAL CLKFLG,IRQUE,IRQU1,JBTADR,JBTSTS,JOB,JOBPD1,REQCLK
	EXTERNAL TIMSKP,UUOTRP

	EXTERNAL DVACHN,DVACHL,DVASAV,DVBCHN,DVBCHL,DVBSAV
	EXTERNAL ECMN,ECONLN,ETYTAB

	MLON
ECMINI:	SETZM	DAFLG			;MARK DA25 NOT IN USE
	SETZM	ERRCNT			;CLEAR OUT ERROR COUNT
	MOVNI	TAC1,ECMN		;GET # OF PDP-8'S
	HRLZS	TAC1			;SET UP LOOP COUNTER
	MOVEI	DDB,ECMDDB		;GET FIRST PDP-8 DDB ADDRESS
INILOP:	SETZM	DEVSTS(DDB)		;CLEAR OUT DEVICE DEPENDENT BITS
	HLRZ	TEM,ETYTAB(TAC1)	;GET PDP-8 CORE SIZE
	MOVEM	TEM,DEVLIM(DDB)		;STORE IN DDB
	HRRM	DDB,ETYTAB(TAC1)	;SAVE DDB ADDRESS IN ETYTAB
	HLRZ	DDB,DEVSER(DDB)		;GET NEXT DDB ADDRESS
	AOBJN	TAC1,INILOP		;LOOP BACK
	CONO	DEVA,SCAN+DVACHN	;SET SCAN MODE
	POPJ	PDP,			;RETURN


ECMRLS:	SETZM	DEVCOA(DDB)		;CLEAR DDB LOCATIONS
	SETZM	DEVCIA(DDB)
	SETZM	DEVTRP(DDB)
	SETZM	DEVIPC(DDB)
	SETZM	DEVINF(DDB)
	MOVSI	TAC,IRP+IOP+IOIP+JSI	;CLEAR IOS BITS
	ANDCAB	TAC,DEVSTS(DDB)
	JRST	RDYCK			;RETURN


ECMHNG:	MOVSI	TAC,IOP+IOIP+IRP+RIP	;CLEAR DEVIOS
	ANDCAB	TAC,DEVSTS(DDB)
RDYCK:	CONO	PI,PIOFF		;TURN OFF INTERRUPTS
	MOVE	TAC,DEVSTS(DDB)		;GET IOS WORD
	TLNN	TAC,CP			;CHARACTER?
	TLZ	TAC,RDY			;NO, TURN OFF RDY BIT
	MOVEM	TAC,DEVSTS(DDB)		;STORE IT AWAY
	CONO	PI,PION			;ENABLE INTERRUPTS AGAIN
	POPJ	PDP,			;RETURN
ECMOUT:	TLOA	IOS,IO		;OUTPUT
ECMIN:	TLZ	IOS,IO		;INPUT
	PUSHJ	PDP,COMCHK	;CHECK VALIDITY OF COMMAND LIST
	JRST	ADRERR		;ERROR RETURN
	MOVSI	STS,IOP+RDY	;MARK IO PENDING
	SOS	UUO		;TO BE COUNTED UP LATER
	MOVEM	UUO,DEVBUF(DDB)	;STORE LIST POINTER
SETREQ:	PUSHJ	PDP,SETACT	;SET DEVICE ACTIVE BIT AND STORE IOS
	PUSHJ	PDP,GETDA	;GET CONTROL OF THE DA-25
	SKIPN	DAFLG		;DA-25 FREE?
	PUSHJ	PDP,DELYC1	;YES, USE IT
	MOVE	IOS,DEVIOS(DDB)	;RESTORE IOS
	JRST	WSYNC		;PUT JOB IN A WAIT

ECMRQ:	HRLM	UUO,DEVICW(DDB)	;STORE REQUEST BITS
	MOVSI	STS,IRP+RDY	;SET READY BITS
	JRST	SETREQ		;GO PROCESS REQUEST

ECMTYP:	PUSH	PDP,LINE	;SCNSRF NEEDS THIS SAVED
	PUSH	PDP,DDB		;SAVE THIS ALSO
	PUSH	PDP,ITEM	;AND THIS
	SUBI	LINE,ECONLN	;GET LINE # OF PDP-8
	MOVE	DDB,ETYTAB(LINE)	;GET DDB ADDRESS
	HRRM	CHREC,DEVICW(DDB)	;STORE CHARACTER
	MOVSI	STS,CP+RDY	;SET PROPER BITS
	PUSHJ	PDP,GETDA	;GET CONTROL OF DA-25
	SKIPN	DAFLG		;IS THE DA-25 FREE?
	PUSHJ	PDP,DELYC1	;YES,GO USE IT
	POP	PDP,ITEM	;RESTORE ITEM
	POP	PDP,DDB		;RESTORE DDB
	POP	PDP,LINE	;RESTORE LINE
	POPJ	PDP,		;NO, JUST RETURN

GETDA:	CONO	PI,PIOFF	;DISALLOW INTERRUPTS
	SKIPN	DAFLG		;IS THE 25-25 FREE?
	CONO	DEVA,0		;YES, TURN IT OFF
	IORM	STS,DEVSTS(DDB)	;STORE STS
	CONO	PI,PION		;TURN INTERRUPT SYSTEM BACK ON
	POPJ	PDP,		;RETURN
ECMENT:	SKIPN	TEM,[XWD 400000+DDB,DEVCOA]
ECMLKP:	MOVE	TEM,[XWD DDB,DEVCIA]
	HRRZ	AC1,UUO		;GET USER ADDRESS
	PUSHJ	PDP,UADCK1	;IS IT LEGAL
	HRRZ	TAC,@UUO	;YES, GET PDP-8 ADDRESS
	CAML	TAC,DEVLIM(DDB)	;IS IT LEGAL
	POPJ	PDP,		;NO, TAKE THE ERROR RETURN
	TRO	TAC,100000	;SET THE ENABLE BIT
	HRRM	TAC,@TEM	;STORE ADDRESS IN DDB
	JRST	CPOPJ1		;TAKE SKIP RETURN

ECMSET:	MOVEI	AC1,1(UUO)	;CHECK USER ENTRY POINT + 1
	PUSHJ	PDP,UADRCK	;IS IT LEGAL
	HRLI	AC1,USRMOD	;YES, FORM PC WORD
	TLO	AC1,200		;PREVENT SYSTEM FROM INCREMENTING IT
	MOVEM	AC1,DEVTRP(DDB)	;STORE TRAP ADDRES IN DDB
	POPJ	PDP,		;AND RETURN

ECMDSM:	SKIPN	TEM,DEVIPC(DDB)	;IS THERE REALLY AN INTERRUPT IN PROGRESS
	POPJ	PDP,		;NO, JUST IGNORE IT
	MOVSI	TAC1,JSI		;CLEAR JSI BIT
	CONO	PI,PIOFF
	SKIPN	TAC,DEVINF(DDB)	;IS INTERRUPT IN PROGRESS
	ANDCAM	TAC1,DEVSTS(DDB)	;CLEAR SERVICE BIT
	CONO	PI,PION		;ENABLE PI AGAIN
	JUMPE	TAC,ECMDS1	;IF NO FURTHER REQUESTS GO RESTORE USER
	SETZ	TAC,
	MOVE	TAC1,DEVTRP(DDB)	;GET TRAP PC
	MOVEM	TAC1,JOBPD1(JDAT)	;STORE OVER HIS RETURN PC
	ADDI	TAC1,-1(PROG)	;TAC1: = ABSOLUTE INTERRUPT ENTRY -1
	EXCH	TAC,DEVINF(DDB)	;GET AND CLEAR LATEST BITS 
	MOVEM	TAC,(TAC1)	;GIVE BITS TO USER
	POPJ	PDP,		;TRAP BACK

ECMDS1:	SETZM	DEVIPC(DDB)	;CLEAR USERS SAVED PC
	MOVE	ITEM,JOB	;GET CURRENT JOB#
	MOVE	TAC,JBTSTS(ITEM);GET JOB STATUS
	TLZE	TAC,AOSPC	;DID SYSTEM TRY TO SKIP RETURN TO USER
	AOS	TEM		;YES, INCREMENT PC
	MOVEM	TAC,JBTSTS(ITEM);STORE STATUS
	MOVEM	TEM,JOBPD1(JDAT)	;RESTORE USERS INTERRUPT PC
	POPJ	PDP,
DVAINT:	CONSO	DEVA,3770	;REQUEST, EOT, OR ERRORS
	JRST .-1
	JSR	DVASAV		;SAVE THE ACS
	SETOM	DAFLG		;MARK THAT THE DA-25 IS IN USE
	CONI	DEVA,TAC	;GET THE STATUS BITS
	LDB	LINE,[POINT 4,TAC,21]	;GET LINE #
	CAIL	LINE,ECMN	;IS THIS LINE # TOO HIGH?
	JRST	DELYC1		;YES
	MOVE	DDB,ETYTAB(LINE);GET DDB ADDRESS
	MOVE	IOS,DEVIOS(DDB)	;SET UP PROPER IOS
	MOVE	STS,DEVSTS(DDB)	;SET UP STATUS WORD
	TRNN	TAC,REQ		;REQUEST INTERRUPT?
	JRST	EOT8		;NO, TRY 8-EOT
	TLNN	STS,IOIP	;INPUT TO PDP-10 READY?
	JRST	REQFR8		;NO, MUST BE 8 REQUEST
	DATAO	DEVA,DEVCTR(DDB);SET UP -WC,,SA-1
	DATAO	DEVB,[0]	;CLEAR THE DATA BUFFER
	MOVEI	TAC,243460+DVBCHN	;GET CONO DEVB BITS
	TRNE	IOS,1		;PACKED OR UNPACKED MODE
	TRZ	TAC,2000	;UNPACKED!
	CONO	DEVB,(TAC)	;INITIATE TRANSFER
	POPJ	PDP,		;DISMISS
REQFR8:	TLO	STS,RF8		;MARK THIS AS REQUEST FROM PDP-8
	MOVEM	STS,DEVSTS(DDB)	;STORE STS
	DATAO	DEVB,[0]	;CLEAR DEVB DATA BUFFER
	CONO	DEVB,243060+DVBCHN	;INITIATE TRANSFER
	POPJ	PDP,		;DISMISS

EOT8:	TRNN	TAC,EOT+WCOF		;IS IT AN EOT?
	JRST	DAERR		;NO, MUST BE AN ERROR
	TLZE	STS,RF8		;IS THIS THE END OF A PDP-8 REQUEST?
	JRST	DELYCK		;YES, WE ARE THROUGH
NXTIO:	TLZN	STS,IOIP	;IO IN PROGRESS?
	JSR	SYNCER		;SYNC ERROR
	HLRE	TAC,DEVCTR(DDB)	;PICK UP LAST IOWD
	MOVNS	TAC		;MAKE IT POSITIVE
	TRNN	IOS,1		;PACKED OR UNPACKED MODE
	IMULI	TAC,3		;PACKED MODE
	TLNE	IOS,IO		;OUTPUT?
	JRST	[ADDB	TAC,DEVCOA(DDB)	;YES
		JRST	CHKSIZ]
	ADDB	TAC,DEVCIA(DDB)	;YES
CHKSIZ:	TRZ	TAC,700000	;CUT ADDRESS TO 15 BITS
	CAMGE	TAC,DEVLIM(DDB)	;IS IT TOO LARGE?
	JRST	DELYCK		;NO, GO DO IT
	MOVEM	STS,DEVSTS(DDB)	;STORE STS
	PUSHJ	PDP,ECMRLS	;GO RELEASE DEVICE
	JSP	TAC,ERRDEV	;PRINT OUT ERROR MESSAGE
	ASCIZ	/TRIED TO ACCESS NON EXISTENT PDP-8 CORE/
JOBSTP:	PUSHJ	PDP,DELYC1	;START DA25 GOING
	LDB	ITEM,PJOBN	;GET JOB NUMBER
	JRST	PCSTOP		;AND STOP JOB

NXTCOM:	AOSA	TAC,DEVBUF(DDB)	;GET NEXT IOWD
	HRRM	TAC,DEVBUF(DDB)	;STORE NEW POINTER
	MOVE	TAC,@TAC	;GET ACTUAL COMMAND
	JUMPL	TAC,CPOPJ	;COMMAND? YES, RETURN
	JUMPG	TAC,NXTCOM+1	;GO-TO-WORD  GET NEXT COMMAND
	POP	PDP,TAC		;COMMAND LIST IS DONE
	TLZ	STS,IOIP+IOP	;CLEAR BITS
ENDIO:	TLZE	IOS,IOW		;IS JOB IN A WAIT
	PUSHJ	PDP,SETIOD	;YES, SET IO DONE
	TRZ	IOS,IOACT	;CLEAR IO ACTIVE BIT
ENDREQ:	TLNN	STS,IOP+IRP+CP	;ANY OTHER DELAYED REQUESTS?
	TLZ	STS,RDY		;NO, CLEAR RDY BIT
	MOVEM	STS,DEVSTS(DDB)	;STORE STS WORD
	MOVEM	IOS,DEVIOS(DDB)	;STORE THIS IOS WORD
	POP	PDP,DDB		;RESTORE DDB FROM DELYCK
	JRST	DELYC1		;LOOK FOR MORE REQUESTS
DVBINT:	CONSO	DEVB,DONE
	JRST	.-1
	JSR	DVBSAV		;SAVE THE AC'S
	CONI	DEVA,TAC	;READ IN THE STATUS BITS
	LDB	LINE,[POINT 4,TAC,21]	;GET PDP-8 LINE #
	CAIL	LINE,ECMN	;IS THIS LINE TOO BIG
	JRST	DELYC1		;YES
	HRRZ	DDB,ETYTAB(LINE);GET DDB ADDRESS
	MOVE	IOS,DEVIOS(DDB)	;SET UP IOS
	MOVE	STS,DEVSTS(DDB)	;SET UP STS
	TLNE	STS,RF8		;REQUEST FROM PDP-8
	JRST	REQ8		;YES
	TLZN	STS,RIP		;REQUEST DONE?
	JRST	NXTIO		;NO, CHECK FOR IO BEING DONE
	TLNE	STS,IOIP	;WAS THIS AN IO REQUEST
	JRST	DOIO		;YES
	PUSH	PDP,DDB		;STORE FOR LATER RESTORE
	TLZN	STS,RCB		;CHAR OR INTERRUPT
	TLZA	STS,IRP		;INTERRUPT
	TLZA	STS,CP		;CHARACTER
	JRST	ENDIO		;DO A SETIOD
	JRST	ENDREQ		;LOOK FOR OTHER COMMANDS
IOREQ:	TLO	STS,IOIP	;MARK THAT IO IS IN PROGRESS
	LDB	ITEM,PJOBN	;GET JOB #
	MOVE	PROG,JBTADR(ITEM)	;SET UP RELOCATION CONSTANT
	PUSHJ	PDP,NXTCOM	;GET NEXT IOWD
	ADDI	TAC,(PROG)	;RELOCATE
	MOVEM	TAC,DEVCTR(DDB)	;STORE IT FOR LATER USE
	HLRES	TAC		;GET -WC
	TRNN	IOS,1		;PACKED OR UNPACKED MODE?
	IMULI	TAC,3		;PACKED MODE
	MOVEM	TAC,DEVREQ(DDB)	;STORE IT IN REQUEST WORD
	MOVE	TAC,DEVCIA(DDB)	;GET INPUT STARTING ADDRESS
	TLNE	IOS,IO		;INPUT OR OUTPUT?
	MOVE	TAC,DEVCOA(DDB)	;OUTPUT, SO GET PROPER ADDRESS
	DPB	TAC,[POINT 18,DEVREQ(DDB),23]
	MOVEI	TAC,INREQ	;INPUT REQUEST #
	TLNE	IOS,IO		;IN OR OUT
	MOVEI	TAC,OUTREQ	;REALLY WANT OUTREQ
	JRST	ROUT		;GO SEND REQUEST OUT

DOIO:	MOVEM	STS,DEVSTS(DDB)	;STORE STS
	TLNN	IOS,IO		;IS THIS AN INPUT REQUEST
	JRST	DELYC1		;YES, GO WAIT FOR PDP-8 REQUEST
	CONI	DEVA,TAC	;GET STATUS BITS
	TRO	TAC,INOUT+DVACHN
	TRZ	TAC,33770	;CLEAR UNWANTED BITS
	CONO	DEVA,(TAC)	;SET STATUS BITS
	DATAO	DEVA,DEVCTR(DDB);OUTPUT WC AND SA
	DATAO	DEVB,[0]	;ZERO DEVB DATA BUFFER
	MOVEI	TAC,3460+DVBCHN
	TRNE	IOS,1		;PACKED OR UNPACKED MODE?
	TRZ	TAC,2000	;SET PACKING MODE TO 1
	CONO	DEVB,(TAC)	;SET DEVB CONTROL BITS
	POPJ	PDP,		;DISMISS
REQ8:	DATAI	DEVB,TAC	;READ IN REQUEST
	MOVEM	TAC,ECMREQ	;SAVE IT FOR LATER
	TLNE	TAC,100		;CHARACTER?
	PUSHJ	PDP,INCHAR	;YES
	MOVE	TAC,ECMREQ	;SET UP TAC AGAIN
	TLNE	TAC,200		;ECHO?
	PUSHJ	PDP,ECHOCH	;YES
	MOVE	TAC,ECMREQ	;RESTORE TAC ONCE MORE
	TLNE	TAC,400		;INTERRUPT REQUEST
	PUSHJ	PDP,INTUSR	;YES
	POPJ	PDP,		;DISMISS AND WAIT FOR EOT
DELYCK:	MOVEM	IOS,DEVIOS(DDB)
	MOVEM	STS,DEVSTS(DDB)	;STORE STS
DELYC1:	PUSH	PDP,DDB		;SAVE DDB
DELYC2:	MOVEI	TAC1,ECMN	;GET # OF PDP-8'S
	MOVEI	DDB,ECMDDB	;GET ADDRESS OF FIRST DDB
CHKLOP:	SKIPGE	STS,DEVSTS(DDB)	;PICK UP STS WORD REQUESTS
	JRST	PROCES		;GO PROCESS THIS REQUEST
NOPROC:	HLRZ	DDB,DEVSER(DDB)	;GET NEXT DDB ADDRESS
	SOJG	TAC1,CHKLOP	;LAST ONE?
	SETZM	DAFLG		;MARK THAT DA-25 IS NOT BUSY
	CONO	DEVA,SCAN+DVACHN	;SET TO SCANNING MODE
	POP	PDP,DDB		;RESTORE DDB
	POPJ	PDP,		;RETURN

PROCES:	TLNE	STS,IOIP	;IO IN PROGRESS
	JRST	NOPROC		;YES, DON'T DO ANYTHING
	MOVE	IOS,DEVIOS(DDB)	;GET IOS WORD
	LDB	TAC1,PUNIT	;GET UNIT #
	MOVEI	TAC,4000+DVACHN	;SET UP CONO BITS
	DPB	TAC1,[POINT 4,TAC,21]
	SETOM	DAFLG		;MARK DA25 IN USE
	CONO	DEVA,(TAC)	;SET UP FOR REQUEST
	TLNE	STS,IOP		;IO PENDING?
	JRST	IOREQ		;YES
	TLNE	STS,IRP		;INTERRUPT REQUEST
	JRST	INTRPT		;YES, GO GET IT
	TLNN	STS,CP		;CHARACTER?
	JSR	SYNC1		;NO,SYNC ERROR
	TLO	STS,EIP		;ARE WE STILL ECHOING LAST CHAR
	HRRZ	TAC,DEVICW(DDB)	;PICK UP CHARACTER TO GO OUT
	DPB	TAC,[POINT 12,DEVREQ(DDB),35]
	MOVEI	TAC,CHREQ	;GET REQUEST NUMBER
	TLOA	STS,RCB		;MARK THAT A CHARACTER IS GOING OUT
ROUT:	TLZ	STS,RCB		;MARK INTERRUPT REQUEST GOING OUT
	DPB	TAC,[POINT 6,DEVREQ(DDB),5]
	TLO	STS,RIP		;MARK THAT REQUEST IS IN PROGRESS
	MOVEM	STS,DEVSTS(DDB)	;STORE STS
	DATAO	DEVB,DEVREQ(DDB);SEND OUT REQUEST
	CONO	DEVB,43060+DVBCHN
	POP	PDP,DDB		;RESTORE DDB
	POPJ	PDP,		;DISMISS

INTRPT:	HLRZ	TAC,DEVICW(DDB)	;GET INTERRUPT REQUEST WORD
	DPB	TAC,[POINT 12,DEVREQ(DDB),23]
	MOVEI	TAC,INTREQ	;GET REQUEST NUMBER
	JRST	ROUT		;SEND OUT REQUEST
INCHAR:	PUSH	PDP,LINE	;SAVE LINE #
	LDB	CHREC,[POINT 7,ECMREQ,35]	;GET CHARACTER
	ADDI	LINE,ECONLN	;GET LINE # IN TTYTAB
	PUSHJ	PDP,RECINT	;SEND OUT CHARACTER
EDONE:	POP	PDP,LINE	;RESTORE LINE
	MOVE	DDB,ETYTAB(LINE);AND DDB
	POPJ	PDP,		;RETURN

ECHOCH:	PUSH	PDP,LINE	;SAVE LINE
	HRRZ	CHREC,DEVICW(DDB)	;GET LAST CHARACTER
	ADDI	LINE,ECONLN	;GET LINE # IN TTYTAB
	MOVSI	TAC,EIP		;MARK THAT ECHO IS DONE
	ANDCAM	TAC,DEVSTS(DDB)
	PUSHJ	PDP,XMTINT	;ECHO THE CHARACTER
	JRST	EDONE
INTUSR:	SKIPN	TAC1,DEVTRP(DDB);IS USER ENABLED FOR INTERRUPTS
	POPJ	PDP,		;NO, IGNORE IT
	MOVE	STS,DEVSTS(DDB)	;PICK UP STS WORD
	LDB	ITEM,[POINT 12,ECMREQ,23]	;GET PDP-8 REQUEST WORD
	MOVNS	ITEM		;MAKE IT NEGATIVE
	MOVSI	TEM,400000
	LSH	TEM,(ITEM)	;SET APPROPRIATE BIT IN INTERRUPT LOCATION
	IORM	TEM,DEVINF(DDB)	;STORE IN DDB
	TLOE	STS,JSI		;JOB SERVICING INTERRUPT
	POPJ	PDP,		;YES
	MOVEM	STS,DEVSTS(DDB)	;RESTORE STS
	LDB	ITEM,PJOBN	;GET JOB #
	SETZM	DEVINF(DDB)	;CLEAR BITS
	MOVE	PROG,JBTADR(ITEM)	;GET STARTING ADDRESS OF JOB
	ADDI	PROG,-1(TAC1)	;ADD USER'S INTERRUPT ADDRESS
	MOVEM	TEM,(PROG)	;GIVE USER THE BITS
	MOVE	DAT,DVBCHL	;GET INTERRUPT PC
	TLNE	DAT,USRMOD	;IS IT IN USER MODE?
	CAME	ITEM,JOB	;IS CURRENT JOB THE RIGHT ONE
	JRST	RSCHED		;NO, GO MAKE SCHEDULER REQUEST
	MOVEM	TAC1,DVBCHL	;YES, TRAP IMMEDIATELY
	MOVEM	DAT,DEVIPC(DDB)	;SAVE THE INTERRUPT PC
	MOVEM	ITEM,TIMSKP	;GUARANTEE ONE CLOCK TICK
	POPJ	PDP,

RSCHED:	HRLM	DDB,ITEM	;FORM REQUEST WORD, XWD DDB ADR, JOB#
	AOS	TAC1,IRQUE	;INCREMENT REQUEST QUEUE POINTER
	MOVEM	ITEM,IRQUE(TAC1)	;STORE REQUEST
	SETZM	IRQU1(TAC1)	;CLEAR NEXT WORD IN QUEUE
	SETOM	UUOTRP		;SCHEDULE NEXT TIME
	SETOM	CLKFLG		;CAUSE A CLOCK INTERRUPT
	CONO	PI,REQCLK	;ON PI LEVEL 7
	POPJ	PDP,		;DISMISS
	;STORAGE LOCATIONS

DAFLG:	Z
ECMREQ:	Z
ERRCNT:	Z

DAERR:	TRNE	TAC,PARITY	;WAS THIS A PARITY ERROR
	JRST	RETRY		;YES, GO TRY IT AGAIN
DAER1:	SETZM	DEVSTS(DDB)	;CLEAR OUT ALL BITS
	PUSHJ	PDP,ECMRLS	;RELEASE THE DEVICE
	LDB	TAC,[POINT 6,DEVNAM(DDB),23]
	ADDI	TAC,40		;PUT DEVICE NUMBER IN ERROR MESSAGE
	DPB	TAC,[POINT 7,MESS+1,20]
	LDB	TAC,[POINT 6,DEVNAM(DDB),29]
	ADDI	TAC,40
	DPB	TAC,[POINT 7,MESS+1,27]
	PUSHJ	PDP,DELYC1	;GO GET NEXT REQUEST FROM DA-25
	JSP	TAC,ERRDEV	;PRINT OUT THE FOLLOWING MESSAGE
MESS:	ASCIZ	/PDP-8 #   NOT RESPONDING/
	JRST	JOBSTP		;STOP THE JOB

RETRY:	CONI	DEVB,TAC	;READ THE STATUS BITS
	DATAI	DEVB,TAC1	;READ IN THE BAD DATA
	LDB	TEM,PTRST		;PICK UP STATE
	SKIPE	TEM		;MEMORY MODE PARITY ERROR
	JRST	DAER1		;NO, NO WAY OUT OF ERROR
	TRZ	TAC,500000	;CLEAR UNWANTED BITS
	CONO	DEVB,200020(TAC)	;CLEAR ERRORS AND CONTINUE
	AOS	ERRCNT		;COUNT UP ERROR COUNT
	POPJ	PDP,		;DISMISS

PTRST:	POINT 3,TAC,23

SYNC1:	Z
	POP	PDP,DDB		;RESTORE DDB
	HALT	SYNC2		;CHANGE HALT TO A JRST ********

SYNCER:	Z
	HALT	.+1		;REMOVE THIS LINE *************
SYNC2:	SETZM	DEVSTS(DDB)		;ZERO STATUS WORD
	AOS	ERRCNT		;COUNT UP ERROR COUNT
	JRST	DELYC1		;RETURN TO NORMAL FLOW

	END