
/ PAGE 1

/PDP-8/S MULTIPROCESSING SYSTEM FOR
/ONE OR TWO CHARACTER DEVICES
/(TY'S AND/OR H.S. READER-PUNCH)
/WITH CIRCULAR BUFFERS

/FEATURES:
/SIMULTANEOUS I/O AND CALCULATIONS.
/SEMI-AUTOMATIC EDITING OF INPUT
/OPTIONAL AUTOMATIC ECHO.

/INITIAL BUFFER ASSIGNMENTS.

KBUF=2000   
TBUF=2140
PBUF=2160
RBUF=2200
SPARE=2310

RESUM=0 
SMP=6101

*0001

	NOP 		/(RESUM=1)-FOR PDP-5
	JMP I .+1
	NTRPT


/ /STANDARD PARTS
/LOCATION 7347 OF DDT MUST CONTAIN "DEBUG".
	DEBUG 		/DDT IN INTERRUPT MODE.
BREAK,	7452	/FOR DDT.

/CONSTANTS
M5,	-5
M1,	-1
//////

//////

*0020

LF,	212
CR,	215
SPLAT,	243
MCR,	-215
RTMSK,	0077
LFMSK,	7700


/ PAGE 2

/SYSTEM PARTS.

INTSW,	0	/PNZ IF INTERRUPT IS ON.
RCOUNT,	0	/NO. OF LINES FROM READER IN BUFFER.
KCOUNT,	0	/NO. OF KEYBOARD LINES IN BUFFER.
LCHAR,	0
	/INTERUPT CHARACTER STORAGE.MCHAR,	0
TESTCK=.
TESTCR=.
	TESTC

/BUFFER POINTERS./
KSTART,	KBUF
KNEXT,	KBUF	/NEXT OUT OF BUFFER.
KLLINE,	KBUF
KCLEAR,	KBUF 		/-Y
KEND,	TBUF 		/LAST+1

TSTART=KEND
TNEXT,	TBUF 		/NEXT OUTPUT FROM THE BUFFERS.
TCLEAR,	TBUF 		/AVAILABLE
TEND,	PBUF 		/START OF NEXT BUFFER INPUT SPACE.

PSTART=TEND
PNEXT,	PBUF
PCLEAR,	PBUF
PEND,	RBUF

RSTART=PEND
RNEXT,	RBUF
RLLINE,	RBUF 		/POINTS TO THE FIRST 0  IN THIS LINE.
RCLEAR,	RBUF	/NEXT INTO BUFFER.
REND,	SPARE

/BUFFER ASSIGNMENT ORDER:
/ KBUF-TBUF-PBUF-RBUF-SPARE

/ PAGE 3

/USER ADDRESSES::

/READER PROCESSOR ADDRESS.
RADR,	0
KADR,	0

/PNZ TO ECHO THE INPUT.
KCHOSW,	0
RCHOSW,	0

/OUTPUT SUBROUTINE ADDRESSES.
OUTCP0,	OUTCP
OUTCT0,	OUTCT
GETCX,	GETCK
OUTCX,	OUTCT
TERROR,	0

/INPUT SUBROUTINE ADDRESSES.
GETCK0,	GETCK
GETCR0,	GETCR




/ PAGE 4

*177


/ALL USER PROGRAMS JUMP TO THIS PROGRAM WHEN
/AWAITING INPUT FROM I/O DEVICES.
/IT CHECKS TO SEE WHETHER THE USER HAS TOLD
/IT WHERE TO GO WHEN A CARRIAGE RETURN HAS
/BEEN RECIEVED.

IDLE,	CLA CLL
	ION	/FAILSAFE AND DEBUG AID.
	TAD I RSWCHI	/TEST H.S. READER.
	SNA CLA
	RFC 		/START READER
	TAD KCOUNT	/COMPARE NO. OF LINES IN EACH.
	CIA
	TAD RCOUNT
	SMA CLA	/CHOSE THE HIGHER.
	JMP IDLEK
IDLER,	TAD KADR
	SNA CLA 		/ADDRESS GIVEN YET 
	JMP IDLEK
	TAD KCOUNT 	/YES
	SNA SPA CLA 	/IS THE LINE DONE?
	JMP IDLEK
	TAD M1 		/YES
	IOF
	TAD KCOUNT 	/COUNT DOWN.
	DCA KCOUNT
	ION
	JMP I KADR 	/GO PROCESS IT.
IDLEK,	TAD RADR 		/TEST HIGH SPEED READER OR QDEV.
	SNA CLA
	JMP IDLER 	/MUST BE KEYBOARD DEPENDENT.
	TAD RCOUNT
	SNA SPA CLA 	/IS A LINE DONE YET? 
	JMP IDLER
	TAD M1
	IOF
	TAD RCOUNT	/COUNT DOWN.
	DCA RCOUNT
	ION
	JMP I RADR 	/START PROGRAM.
////////////


/ PAGE 5

/THIS SECTION PROCESSES THE INTERRUPT AND TESTS ALL FLAGS.
/IF THE KEYBOARD FLAG WAS ON IT DOUBLE CHECKS THE 
/READER FLAG TO TRY TO IMPROVE THE TIMEING.

NTRPT,	DCA SAVAC 	/SAVE THE MACHINE STATES.
	RAL
	DCA SAVLK 	/SAVE THE LINK.
	DCA INTSW 	/TURN OFF THE INTERUPT INDICATOR.
	RSF 		/(6011)-FOR HS ., (6411)-FOR QDEV.
	SKP
	JMS I RINTI
	KSF 		/TEST KEYBOARD.
	SKP
	JMS I KINTI
	SMP 		/SKIP IF MEMORY PARITY IS OK.
	HLT 		/(NOP)-IF NO MEM-PAR CHK ON COMPUTER.
	PSF 		/TEST HIGH SPEED PUNCH OR QDEV PRINTER.
/(6021)-FOR HS., (6401)-FOR QDEV.
	SKP
	JMS I PINTI
	TSF 		/TEST TYPEWRITER FLAG.
	SKP
	JMS I TINTI
	NOP 		/(JMS I USRFLG)- FOR OTHER DEVICE TESTS
	TAD RTMSK
	DCA INTSW 	/TURN ON THE INTERRUPT INDICATOR.
/RESTORE THE MAIN PROGRAM AND RESUME IT.
	TAD SAVLK 	/RESTORE THE LINK.
	CLL RAR
	TAD SAVAC 	/MACHINE STATE RESTORED.
	ION 		/RESTORE INTERRUPT MODE.
	JMP I RESUM 	/RESUME THE MAIN PROGRAM.
/(5401)-FOR PDP-5.
/////
SAVAC,	0
SAVLK,	0
RSWCHI,	RSWCH	/POINTER TO H.S. READER SWITCH.

/DEVICE INTERRUPT HANDLER SUBROUTINE POINTERS.
PINTI,	PINT
TINTI,	TINT
RINTI,	RINT
KINTI,	KINT
USRFLG,	00 		/ADDRESS OF USER SUBROUTINE
////////

/ PAGE 6

/THIS SUBROUTINE TESTS THE INPUT
/CHARACTER TO SEE WHETHER IT IS
/AN EDIT OR A TERMINATOR CHARACTER.

TESTC,	0 
	TAD M5
	DCA TC
	TAD TX
	DCA TCP
TESTC1,	ISZ TCP
	TAD LCHAR
	TAD I TCP
	SNA CLA
	JMP I TESTC
	ISZ TESTC
	ISZ TC
	JMP TESTC1
	JMP I TESTC
TX,	.
MRO,	-377
MBA,	-337
	-215
MBL,	-000
MLT,	-200
TC,	0
TCP,	0


/ PAGE 7

/THESE TWO ROUTINES ARE CALLED FROM THE USER PROGRAM
/TO GET EDITED CHARACTERS OUT OF THE BUFFERS.
/THEY MAY NOT BE CALLED AFTER A C.R. IS RECIEVED 
/WITHOUT FIRST GOING TO IDLE.
/
/THE FIRST RETURN IS FOR C.R. WITH (AC)=0.
/THE 2AND IS FOR OTHERS WITH (AC) = OTHER.


GETCR,	0 
	TAD I RNEXT 	/LOAD AND SAVE CHARACTER.
	DCA MCHAR 	/SAVE FOR RETURN.
	TAD RNEXT
	CMA
	ISZ RNEXT
	TAD REND
	SZA CLA 		/AROUND THE END
	JMP .+3
	TAD RSTART
	DCA RNEXT
	TAD MCHAR
	TAD MCR
	SNA CLA
	JMP I GETCR
	ISZ GETCR
	TAD MCHAR
	JMP I GETCR
////////////
GETCK,	0 
	TAD I KNEXT
	DCA MCHAR 	/SAVE IT.
	TAD KNEXT
	CMA
	ISZ KNEXT
	TAD KEND
	SZA CLA
	JMP .+3
	TAD KSTART
	DCA KNEXT
	TAD MCHAR
	TAD MCR
	SNA CLA
	JMP I GETCK
	ISZ GETCK
	TAD MCHAR
	JMP I GETCK
////////

MCHAR,	0


/ PAGE 8

/INPUT FROM KEYBOARD SUBROUTINES.

*400

KINT,	0  		/KEYBOARD INTERRUPT
	TAD KCLEAR	/TEST YOUR BUFFERS.
	CMA
	TAD KNEXT
	SNA
	JMP .+5	/TROUBLE.
	TAD KEND
	CIA
	TAD KSTART
	SNA CLA 		/FULL?
	HLT 		/INPUT IS TOO FAST.
/SYSTEM OVERFLOW, USE BIGGER BUFFER.
/
/RECOVERY IS POSSIBLE AT THIS POINT:
/TYPE C.R. OR RUBOUT  OR RUBOUT AND HIT CONTINUE.
/
/READ AND PROCESS THE CHARACTER.
	KRB 		/READ THE BUFFER
	DCA LCHAR
	TAD LCHAR
	DCA I KCLEAR 	/STORE CHARACTER
	ISZ KCLEAR 	/INCREMENT POINTERS
	TAD KCLEAR
	CIA
	TAD KEND
	SZA CLA 		/TURN OVER BUFFER?
	JMP .+3
	TAD KSTART 	/YES
	DCA KCLEAR
	JMS I TESTCK 	/TEST CHARACTER
	JMP KROR
	JMP KBAR
	JMP KECR
	JMP KIGNOR
	JMP KIGNOR
	JMP KECHO
//////




/ PAGE 9

/INPUT CHARACTER PROCESSING.

KECR,	ISZ KCOUNT 	/CRLF.
	TAD KCLEAR
	DCA KLLINE	/SET END OF LINE.
KECHO,	TAD KCHOSW
	SNA CLA	/TEST FOR ECHO
	JMP I KINT
	TAD LCHAR
	JMS OUTCT
	JMP I KINT
/ ////////////
/CREVAT EMPTOR:
/
/NO CHECK FOR ECHO CONFLICT IS MADE;
/IF THE PROGRAM COUNTER IS WITHIN 
/THE SYSTEM/USER SUBROUTINES TO 
/OUTPUT A CHARACTER THEN IT MIGHT
/CREATE AN OUTPUT-INTERMESH FAILURE IF 
/AN ECHO WERE MADE AT THAT TIME
////////
KROR,	JMS BACKK1 	/BACKUP POINTER
	TAD KCLEAR	/DO NOT GO PAST
	CIA
	TAD KLLINE	/THE END OF THE LINE.
	SNA CLA 		/LINE?
	JMP I KINT 	/YES
	TAD SPLAT 	/PRINT # FOR EACH
	DCA LCHAR 	/RUBOUT CHARACTER USED.
KIGNOR,	JMS BACKK1
	JMP KECHO
//////////
KBAR,	TAD KLLINE	/RESTART THE LINE.
	DCA KCLEAR
	JMP KECHO/GO TEST FOR ECHO.
////////
BACKK1,	0  		/BACKUP THE POINTERS.
	TAD KCLEAR
	CIA
	TAD KLLINE
	SZA CLA 		/AT START?
	JMP .+5
	TAD KEND 		/YES
	TAD M1
	DCA KCLEAR
	JMP I BACKK1
	TAD KCLEAR
	JMP .-4
////////




/ PAGE 10

/OUTPUT VIA TELEPRINTER.

TINT,	0  		/OUTPUT COMPLETED.
	TCF	/CLEAR FLAG
	CLA CMA		/TEST FOR -1.
	TAD TSWCH
	SNA CLA		/ANY OUTPUT LEFT?
	JMP TINTX	/NO,LEAVE.
	TAD I TNEXT	/YES,GET IT.
	TLS	/OUTPUT IT.
	ISZ TNEXT	/MOVE POINTERS.
	CLA CMA
	TAD TSWCH
TINTX,	DCA TSWCH	/COUNT DOWN.
	TAD TNEXT
	CIA
	TAD TEND
	SZA CLA 		/AROUND THE END? 
	JMP I TINT 	/NO.
	TAD TSTART 	/YES
	DCA TNEXT 	/RESTART BUFFER
	JMP I TINT

/ PAGE 11

OUTCT,	0 
	DCA NCHAR	/SAVE CHARACTER.
	TAD NCHAR
	DCA I TCLEAR	/STORE CHARACTER.
	IOF	/INTERRUPTS OFF.
	ISZ TSWCH	/COUNT UP.
	ISZ TCLEAR	/MOVE POINTERS.
	TAD TEND
	CIA
	TAD TCLEAR
	SZA CLA	/CHECK LIMITS.
	JMP .+3
	TAD TSTART	/AROUND END SO
	DCA TCLEAR	/RESTART POINTERS.
/
	CLA CMA
	TAD TSWCH
	SZA CLA	/FIRST INTO BUFFER?
	JMP .+3	/NO.
	ISZ TSWCH	/YES,COUNT AN EXTRA ONE.
	JMS TINT	/PRETEND OUTPUT.
	TAD INTSW
	SZA CLA
	ION
	TAD TSWCH
	TAD TMLNGT	/TEST LENGTH.
	SNA CLA	/BUFFER FULL?
	JMP .-3	/YES,WAIT.
	TAD NCHAR	/NO.
	TAD MCR
	SZA CLA
	JMP I OUTCT
	TAD LF 		/ AUTOMATIC CR-LF.
	JMP OUTCT+1
NCHAR,	0	/TEMPORARY STORAGE.
TSWCH,	0
TMLNGT,	TBUF-PBUF-1	/WAIT FOR AT LEAST TWO SPACES.
/THE FOLLOWING ROUTINE CAN PERMIT DDT AND DDT-JR.
/TO BE USED WITH THIS SYSTEM WITH THE INTERRUPT ON.

//LOCATION 4 MUST CONTAIN DEBUG.
/IN DDT LOC 7347 MUST CONTAIN DEBUG.
//"BREAK" MUST ALSO CONTAIN THE RIGHT ADDRESS.

	PSWCH
DEBUG,	TAD TSWCH
	TAD I .-2
	SZA CLA
	JMP DEBUG	/WAIT FOR EMPTY TTY BUFFER.
	IOF
	JMP I BREAK



/ PAGE 13

/HIGH SPEED I/O.
/OR A QDEV (2AND TTY VIA LT08).


*600

/////
RINT,	0 
	TAD RCLEAR 	/CHECK FOR OVERLAY ONTO NEXT OUTPUT.
	CMA
	TAD RNEXT
	SNA 		/SKIP IF OK SO FAR.
	JMP .+5 		/LEAVE READER SWITCH OFF.
	TAD REND 		/TEST BOUNDARIES.
	CIA
	TAD RSTART
	NOP	/(SNA CLA)-FOR QDEV
	DCA RSWCH 	/NO,TURN ON.;(HLT)-FOR QDEV.
	RRB
	DCA LCHAR 	/SAVE INPUT CHARACTER.
	TAD LCHAR
	DCA I RCLEAR 	/STORE THE INPUT.
	ISZ RCLEAR
	TAD RCLEAR
	CIA
	TAD REND
	SZA CLA 		/END OF BUFFER?
	JMP .+3
	TAD RSTART 	/YES; RESTART IT.
	DCA RCLEAR
	TAD RSWCH
	SZA CLA 		/SHOULD WE CONTINUE TO RUN THE READER?
	RFC 		/-YES.    (NOP)-FOR QDEV.
///
	JMS I TESTCR
	JMP RROR 		/(JMP RIGNOR)-FOR CERTAIN H.S. CASES.
	JMP RBAR
	JMP RECR
	JMP RIGNOR
	JMP RIGNOR
	JMP RECHO
//////


/ PAGE 14

RECR,	ISZ RCOUNT 	/CR. L.F.
	TAD RCLEAR
	DCA RLLINE 	/RESET LINE POINTER
RECHO,	NOP	/(TAD RCHO)-FOR QDEV.SW
	SNA CLA
	JMP I RINT
	TAD LCHAR
	JMS OUTCP
	JMP I RINT
////////////
RROR,	JMS BACKR1 	/ELIMINATE 
	TAD RCLEAR
	CIA
	TAD RLLINE 	/ALREADY AT THE END
	SNA CLA
	JMP I RINT
	TAD SPLAT
	DCA LCHAR
RIGNOR,	JMS BACKR1 	/FORGET THIS CHARACTER.
	JMP RECHO		/GO SEE IF AN ECHO IS DESIRED.
///////
RBAR,	TAD RLLINE 	/RESET THIS LINE
	DCA RCLEAR
	JMP RECHO
//////
BACKR1,	0  		/BACKUP READER POINTER
	TAD RCLEAR
	CIA
	TAD RSTART
	SZA CLA
	JMP .+5
	TAD REND
	TAD M1
	DCA RCLEAR
	JMP I BACKR1
	TAD RCLEAR
	JMP .-4
RSWCH,	0	/ON-OFF INDICATOR FOR H.S. READER.
//////


/ PAGE 15 A

/OUTPUT VIA H.S. PUNCK

PINT,	0  		/OUTPUT COMPLETED.
	PCF
	CMA CLA
	TAD PSWCH
	SNA CLA
	JMP PINTX	/NO.
	TAD I PNEXT 	/YES
	PLS
	ISZ PNEXT
	CLA CMA
	TAD PSWCH
PINTX,	DCA PSWCH
	TAD PNEXT
	CIA
	TAD PEND
	SZA CLA 		/AROUND THE END? 
	JMP I PINT 	/NO.
	TAD PSTART 	/YES
	DCA PNEXT 	/RESTART BBUFFER
	JMP I PINT
//////

/ PAGE 15 B

/H.S. OUTPUT SUBROUTINES.

OUTCP,	0 
	DCA OCHAR
	TAD OCHAR
	DCA I PCLEAR 	/PLACE INTO BUFFER.
	IOF
	ISZ PSWCH
	ISZ PCLEAR 	/MOVE POINTERS.
	TAD PEND 		/CHECK LIMITS.
	CIA
	TAD PCLEAR
	SZA CLA 		/OVER THE END?
	JMP .+3
	TAD PSTART
	DCA PCLEAR 	/YES.
	CMA	/CHECK FOR FIRST CHARACTER.
	TAD PSWCH
	SZA CLA
	JMP .+3	/NOT FIRST.
	ISZ PSWCH	/COUNT AN EXTRA TIME.
	JMS PINT	/INITIATE OUTPUT.
	TAD INTSW	/TEST FOR INTERRUPT.
	SZA CLA
	ION
	TAD PSWCH	/TEST FOR FULL BUFFER.
	TAD PMLNGTH
	SNA CLA
	JMP .-3	/YES,WAIT.
	TAD OCHAR	/TEST FOR C.R.
	TAD MCR
	SZA CLA
	JMP I OUTCP
	TAD LF 		/ AUTOMATIC CR-LF.
	JMP OUTCP+1
OCHAR,	0	/TEMPORARY STORAGE.
PSWCH,	0
PMLNGTH,	PBUF-RBUF-1



/ PAGE 16

/TEST THE TIME SHARING SYSTEM.

*1000

	IOF 		/BE SURE INTERRUPT IS OFF
	TAD KSTART 	/INITIALIZE THE
	DCA KNEXT 	/BUFFER POINTERS.
	TAD KSTART
	DCA KCLEAR
	TAD KSTART
	DCA KLLINE
	TAD TSTART
	DCA TNEXT
	TAD TSTART
	DCA TCLEAR
	TAD PSTART
	DCA PCLEAR
	TAD PSTART
	DCA PNEXT
	TAD RSTART
	DCA RCLEAR
	TAD RSTART
	DCA RNEXT
	TAD RSTART
	DCA RLLINE
	DCA RCOUNT 	/CLEAN UP COUNTERS.
	DCA KCOUNT
/CLEAR ALL POSSIBLE FLAGS.
	6764
	6772
	6042
	6402
	6022
	6102
	6012
	6032
	6412
/INITIALIZE PROCESS ADDRESSES.
	TAD TK
	DCA KADR
	TAD RK
	DCA RADR
/CLEAR ALL SWITCHES.
	DCA INTSW
	DCA I .+6
	DCA I .+4
	DCA I .+2
	JMP I START
	TSWCH 		/SWITCH LIST
	PSWCH
	RSWCH
START,	IDLE 		/STARTING ADDRESS.
TK,	KTEST 		/PROCESS ADDRESSES
RK,	RTEST

/ PAGE 17

/BIT 0 - HOLD THIS DEVICE.
/BIT 1 - LOOP 8192 TIMES.
/BIT 2 - PLAYBACK.
/BITS 3,4,5 - HIGH SPEED DEVICE.
/BIT 11 - HOLD ACTIVATED FOR BOTH.
/
KTEST,	LAS
	DCA XTST
	TAD GETCK0	/SETUP I/O-POINTERS.
	DCA GETCX
	TAD OUTCT0
	JMP XTEST
RTEST,	LAS
	RTL
	RAL
	DCA XTST
	TAD GETCR0
	DCA GETCX
	TAD OUTCP0
XTEST,	DCA OUTCX
	LAS	/READ SW POINTERS.
	RTR
	AND XTST
	SPA CLA
	JMP .-4
	TAD XTST
	RAL
	SMA
	JMP .+3
	ISZ XCNT
	JMP .-1
	RAL
	DCA XTST
XGET,	JMS I GETCX
	JMP XOUT
	DCA XCHAR
	TAD XTST
	SMA CLA
	JMP XGET
	DCA RCHOSW	/TURN OFF ECHOS.
	DCA KCHOSW
	TAD XCHAR
	JMS I OUTCX
	JMP XGET
//////
XOUT,	TAD XTST
	SMA CLA
	JMP .+3
	TAD CR
	JMS I OUTCX
	TAD XECH
	DCA KCHOSW
	TAD XRECH
	DCA RCHOSW
	JMP IDLE
///
XTST,	0
XCHAR,	0
XCNT,	0
XECH,	0
XRECH,	0
	$
