
PDP-9 ASSEMBLER PART III-A

/INPUT/OUT BASIC SUBROUTINES FOR INTERRUPT.

INTER,


	DAC A#C
	RSF	SKP	JMP TAPIN
	PSF	SKP	JMP COPB
	TSF	SKP	JMP TYINT
	LSDF	SKP	JMP PRNINT
	LSEF	SKP	JMP SPCINT
	IORS
	HLT
	CAF
	LEAVE

COPB,	JMS OPB

LEAVE=JMP .
	LAC
	RAL
	LAC AC
	ION
	JMP I

/TAPE INTERRUPT ROUTINE

GCR,	0		/GET A CHARACTER FROM THE BUFFER
	LAC TAPO
	SAD (LAW TAPEND	/CHECK FOR END OF BUFFER
	LAW TAPBUF
	DAC TAPO
	LAC TAP#CNT
	ADD (20		/READING MUST BE 20 CHARS. AHEAD OF PROCESSING
	SMA
	JMP GCR0 2	/IF NOT, LET READING GET AHEAD

GCR0,	ISZ TAPCNT
	JMP GCC1		/READ IS > 20 CHARS AHEAD, SO PROCESS
	LAC R#ON
	SPA
	RSA		/READER "ON" AGAIN
	DZM RON
	LAC TAPCNT
	SMA
	JMP .-2
	JMP GCR0

GCC1,	LAC MEDIAT
	SZA
	JMP GCC3
	LAC I TAPO
GCC2,	NOP	/SKP IF FIODEC
	JMS ATF
GCC4,	DAC FC#HR
	JMP I GCR

GCC3,	DZM MEDIAT
	LAC TAPCNT
	TAD (-0
	DAC TAPCNT
	LAC ITEMB
	JMP GCC4

/COME HERE ON A TAPE INTERRUPT

TAPIN,	RRB
	JMS ENDTAP		/CHECK TAPE IN READER (ON PDP-9)
	RSA
	SNA
	LEAVE	/BLANK TAPE
	DAC I TAPI
	AND (100
TAPINH,	NOP	/OR CLA IF ASCII
	SZA
	JMP TAPI1		/FIODEC RUBOUT
	LAC TAPI
	SAD (LAW TAPEND		/CHECK FOR END OF BUFFER
	LAW TAPBUF
	DAC TAPI
	LAM -1		/DECREMENT COUNTER
	ADD TAPCNT
	DAC TAPCNT
	SAD (TAPBUF-TAPEND+2	/IF READING IS BUFFER LENGTH AHEAD
	JMP TAPINW		/OF PROCESSING, TURN READER "OFF"
	LEAVE

TAPINW,	LAC RON
	SPA
	LEAVE
	LAC (JMP .+3
	DAC TAPIN
	LEAVE
	LAC . 4		/COME HERE ON NEXT INTERRUPT,
	DAC TAPIN		/DO NOT SELECT READER
	CLC		/SET FLAG TO TURN READER ON
	DAC RON		/AGAIN, AFTER PROCESSING CATCHES UP
	RRB
	JMS ENDTAP

	JMP TAPIN 3

TAPI1,	LAM -1		/THROW AWAY RUBOUT
	ADD TAPI
	DAC TAPI
	LEAVE

ENDTAP,	0
	DAC RRRB#
	IORS
	AND (1000		/BIT 8, PTR EMPTY FLAG
	SZA
	JMP .+3
	LAC RRRB		/OK, SO RETURN
	JMP I ENDTAP
	DZM RON		/PTR EMPTY, DO NOT TURN
	LEAVE		/READER ON AGAIN

ATF,	0
	DAC IT#EMA
	TAD (-237
	SPA
	JMP ATFL	/NOT IN TABLE - LOW
	TAD (-77
	SMA
	JMP ATF4	/NOT IN TABLE - HIGH, EXIT
	TAD (400100
	RCR
	ADD (IASC
	DAC .+1
	XX
	SNL
	JMS RR9
	DAC ITEMA	/ODD CODES IN RIGHT HALF, EVEN CODES IN LEFT HALF
	AND (77
	DAC IT#EMB
	LAC (400
	AND ITEMA
	RCR
	XOR ITEMB	/PUT PARITY BIT
	DAC ITEM#B
	LAC ITEMA
	AND (300
	XOR AFCASE
	SNA
	JMP ATFC
ATF1,	LAC ITEMB
	JMP ATF4 1
ATFL,	SAD (-26
	LAC (236
	SAD (-23
	LAC (13
	SAD (-22
	LAC (277
	SPA
ATF4,	JMP GCR 1
	AND (377
	JMP I ATF
ATFC,	LAC AFCASE
	CMA
	AND (300
	DAC AFCASE
	SAD (100
	CLA!SKP
	LAM -1
	TAD (274
	DAC ITEMA
	LAC ITEMA
	ISZ MEDIAT
	JMP ATF4 1
/TABLE FOR ASCII TO FIODEC CONVERSION
/CODE TRANSLATION CONVENTIONS ARE THOSE OF CANUTE
/WITH THE TWO EMENDATIONS, VIZ,
/(1) ASCII NUMBER SIGN SERVES AS FIODEC OVERBAR
/(2) ASCII DOLLAR SIGN SERVES AS FIODEC UNDERBAR
/COLON AND SEMICOLON ARE TRANSLATED AS SPACES
/NINE BIT CODES FOR EVEN ASCII MOD(240) IN LEFT HALF, ODD ASCII RIGHT HALF
/CASE CARRIED AS 100 FOR LC, 200 FOR UC, ALL LETTERS LC
/INITIAL BIT IS PARITY BIT IN NINE BIT EQUIVALENCE SCHEME
IASC,	500605
	201556
	240204
	606202
	157555
	273254
	533154
	173521
	120101
	102503
	104505
	506107
	110511
	500500
	207633
	210621
	220161
	162563
	164565
	566167
	170571
	541542
	143544
	145146
	547550
	151522
	123524
	125126
	527530
	131257
	656655
	611603
/PUNCH FOR INTERRUPT

IPB,	0		/PUT A [8 BIT] CHARACTER IN THE BUFFER
	DAC I PUNI
	LAC PUNI
	SAD (LAW PUNEND	/CHECK FOR END OF BUFFER
	LAW PUNBEG
	DAC PUNI

IPB0,	ISZ P#UNCNT
	JMP I IPB		/STILL ROOM IN BUFFER 80 RETURN
	LAC P#ON		/PUNCHING IS WHOLE BUFFER BEHIND
	SPA		/LOADING THE BUFFER
	JMS OPB		/LET PUNCHING CATCH UP A LITTLE
	LAC PUNCNT
	SMA
	JMP .-2
	JMP I IPB

/GET A CHARACTER FROM THE BUFFER AND PUNCH IT
OPB,	0
	LAC PUNO
	SAD (LAW PUNEND	/CHECK IF END OF BUFFER
	LAW PUNBEG
	DAC PUNO
	LAC PUNCNT
	SAD (PUNBEG-PUNEND+1
	JMP OPBF		/NO MORE CHARS IN BUFFER TO PUNCH
	TAD (-0		/DECREMENT COUNTER
	DAC PUNCNT
	IORS
	AND (400		/1 CHECK OF PTP EMPTY
	SNA
	JMP .+4
	CLC		/IF SO, SET AC TO ALL ONES
	HLT
	JMP .-6		/WAIT TIL PUNCH REFILLED
	LAC I PUNO
	PLS

	DZM PON
	JMP I OPB

OPBF,	PCF	/TURN OFF INTERRUPT TIL BUFFER FILLED
	CLC
	DAC PON		/SET FLAG TO RE-ENABLE INTERRUPT
	JMP I OPB


/TELETYPE AND ANELEX OUTPUT ROUTINES

TYINT,	ISZ 0
	TCF
	LEAVE

OTY,	0
	DAC S#UCHR
	LAT
	AND (100
	SZA
	JMP ANELX	/LINE PRINTER OUTPUT, BIT 11 ON
	LAC SUCHR
	TLS
	JMP .
	JMP I OTY

ANELX,	LAC SUCHR
	AND (37
	SAD (33
	JMP ANXU	/FIGURES
	SAD (37
	JMP ANXL	/LETTERS
	SAD (10
	JMP ANXLN	/LINE FEED
	SAD (2
	JMP ANXO	/CARRIAGE RETURN
	CLL
	ADD (LAC TANX
	ADD ANX#C	/ADD CASE CODE
	DAC .+2
	CLL
	XX
ANX2,	XCT ANXR
	ADD S#V3C
	DAC SV3C
	ISZ .-3
ANXO,	LAC SUCHR	/RETURN
	JMP I OTY
ANXR,	JMS RR7	/FIRST CHAR IN BITS 0-5
	JMS RL6	/SECOND IN BITS 6-11
	JMP .+1	/THIRD IN BITS 12-17
	ADD SV3C
	DAC SV3C
	LAC PNTF
	SZA
	JMP .-2	/WAIT FOR INTERRUPT FROM LAST IOT
	ISZ PNTF
	LAC SV3C
	ISZ ANXCNT
	LPLD	/LOAD THE THREE CHARS
ANX3,	LAC (XCT ANXR
	DAC ANX2	/REINITIALIZE FOR NEXT 3 CHARS
	DZM SV3C
	JMP ANXO
ANXU,	LAC (40
	DAC ANXC	/UPPER CASE=40
	JMP ANXO
ANXL,	DZM ANXC	/LOWER CASE = 0
	JMP ANXO

/INTERRUPTS FROM LINE PRINTER TYPE 647 COME HERE

SPCINT,	LAC (525252
	HLT
	LSEF
	LEAVE	/ERROR FLAG=0
	JMP SPCINT	/ERROR

PRNINT,	DZM PNTF
	LPCF	/CLEAR DONE FLAG
	LEAVE

ANXLN,	LAC SV3C
	SNA
	JMP ANXLNE
	AND (7777	/MUST FILL UP WITH SPACES
	SNA
	JMP .+3
	LAC (40	/1 SPACE
	SKP
	LAC (4040	/2 SPACES
	XOR SV3C
	DAC SV3C
	LAC PNTF
	SZA
	JMP .-2
	ISZ PNTF
	LAC SV3C
	LPLD
ANXLNE,	LAM -50
	DAC AN#XCNT	/RESET LINE LENGTH COUNTER
	LAC PNTF
	SZA
	JMP .-2
	ISZ PNTF
	LAC SPCIND
	LPPS	/PRINT AND SPACE
	DZM SPCIND
	ISZ MMS
	JMP ANX3
	JMS MRX
	JMP ANX3

TANX,	40	24	40	17
	40	10	16	15
	40	14	22	07
	11	20	03	26
	05	32	04	02
	23	31	06	30
	01	27	12	40
	25	21	13	40
	40	65	40	71
	40	43	54	56
	40	51	64	53
	70	60	72	73
	63	42	44	77
	40	66	41	57
	55	62	47	40
	67	61	50	40

START
