
PDP-9 FORTRAN II INTERRUPT I/O 7/7/66

/INTERRUPT SERVICE ENTRY ROUTINES


INTRP,	DAC Z#C
	RSF	SKP	JMP TAPINT	/PERFORATED TAPE READER
	PSF	SKP	JMP PUNINT	/PERFORATED TAPE PUNCH
	TSF	SKP	JMP TYPINT	/TELETYPE TELEPRINTER
	IORS		/INPUT/OUTPUT STATUS TO AC
	HLT
	KRB		/READ KEYBOARD BUFFER.

DISMIS=JMP .
	LAC 0	RAL	LAC ZC	ION	JMP I 0

/CLEAR ALL FLEA BAGS

CLFLAG,	CAF
	CLA
	LAC (JMP INTRP
	DAC 1
	ION
	EXIT

/TAPE INTERRUPT ROUTINE

GCR,	LAC TAPO		/INITIALIZED TO LAW TAPBUF
	SAD (LAW TAPBUF+TN
	JMP GCR2		/HALF BUFFER FILLED

GCR0,	ISZ TAPCNT
	JMP GCR1		/GET ANOTHER CHARACTER
	LAC R#ON		/NO MORE CHARACTERS IN BUFFER
	SPA		/IF FLAG SET, TURN READER ON AGAIN
	RSA
	DZM RON
	LAC TAPCNT		/WAIT FOR PTR INTERRUPT
	SMA
	JMP .-2
	JMP GCR0

GCR1,	LAC MEDIAT		/INITIALIZED TO 0
	SZA
	JMP GCR6
	LAC I TAPO		/GET A CHARACTER
	ISZ TAPO
GCR4,	SKP		/MODIFIED, DEPENDING IN WHICH HALF OF RING CHAR IS CONTAINED
	RAR9
GCR5,	XX		/SKP IF FIODEC, NOP IF ASCII
	JMS ATF
GCR7,	AND (77		/CHAR. IN RIGHT HALF OF AC
	EXIT
GCR6,	DZM MEDIAT
	LAC TAPCNT
	TAD (-0
	DAC TAPCNT
	LAC ITEMB
	JMP GCR7

/START AT BEGINNING OF BUFFER, OTHER HALF OF WORD

GCR2,	LAW TAPBUF
	DAC TAPO
	LAC GCR4
	XOR (SKP-NOP	/MODIFY SKP + NOP
	DAC GCR4		/NOP IF CHAR ALREADY IN RIGHT HALF OF WORD
	JMP GCR0
WAIT=JMS .
	0
	LAC PON
	SZA
	JMS OPB
	LAC PON
	SNA
	JMP .-2
	JMP I WAIT-JMS

/COME HERE ON A TAPE INTERRUPT

TAPINT,	RRB
	JMS ENDTAP		/CHECK END OF TAPE
	RSA
	SNA
	DISMIS		/BLANK TAPE
TAPX,	DAC TA#PTEM
TAPY,	AND (100		/MODIFIED, JMP TAPINY IF ASCII
	SZA
	DISMIS		/DELETED CHAR
TAPIN4,	LAC TAPTEM
	RTL	RTL	RTL	RTL	RAL
	ADD TAPTEM		/FORM BUFFER RING
	XOR I TAPI
	AND TAPMSK	/HALF OF BUFFER BEING FILLED DETERMINED
	XOR I TAPI	/BY TAPMSK
	DAC I TAPI
	ISZ TAPI
	LAC TAPI
	SAD (LAW TAPBUF+TN
	JMP TAPIN2	/HALF OF BUFFER FILLED

/COUNT AND CHECK FOR FULL BUFFER

TAPIN1,	LAM -1
	ADD TAPCNT
	DAC TAPCNT
	SAD (-TN-TN+1
	JMP TAPINW	/NO MORE ROOM IN BUFFER TO READ  IN CHARS
	DISMIS

/SWITCH WORD HALFS, AND SET POINTER TO BEGINNING OF BUFFER

TAPIN2,	LAC TAPMSK
	CMA		/MASK OUT OTHER HALF OF WORD
	DAC TAPMSK
	LAW TAPBUF	/RESET POINTER
	DAC TAPI
	JMP TAPIN1
ENDTAP,	0
	DAC RRRB#
	IORS
	AND (1000		/BIT 8, PTR EMPTY
	SZA
	JMP .+3		/NO MORE TAPE IN PTR
	LAC RRRB
	JMP I ENDTAP
	DZM RON		/DO NOT SELECT READER AGAIN
	DISMIS

/SET NEXT INTERRUPT TO TURN OFF READER

TAPINW,	LAC RON
	SPA
	DISMIS
	LAC (JMP .+3	/LET PROCESSING CATCH UP
	DAC TAPINT
	DISMIS
	LAC . 4		/COME HERE ON NEXT INTERRUPT
	DAC TAPINT
	CLC
	DAC RON		/SET FLAG TO TURN READER ON AGAIN
	RRB
	JMS ENDTAP
	JMP TAPINT 3

/INITIALIZE READER AND PUNCH SERVICE ROUTINES

STREAD,	LAW TAPBUF
	DAC TA#PI
	DAC TA#PO
	DZM R#ON
	LAC (SKP
	DAC GCR4
	DAC OPBM
	LAC (777
	DAC TAPM#SK
	DAC PUNM#SK
	LAW PUNBUF
	DAC PU#NO
	DAC PU#NI
	LAM -PN-PN+1
	DAC P#UNCNT
	CLC
	DAC P#ON
	DAC TAP#CNT
	DZM OPBF#LG
	RSA
	LAS
	AND (200
	SZA
	JMP TAPINX	/ASCII INPUT
	LAC (AND KONA
	DAC TAPY
	LAC (SKP
	DAC GCR5
TAPINZ,	DZM MEDIA#T
	LAC (200
	DAC AFC#ASE
	DZM FTACAS
	EXIT
KONA,	100

TAPINX,	LAC (JMP TAPINY
	DAC TAPY
	LAC (NOP
	DAC GCR5
	JMP TAPINZ
TAPINY,	SAD (377
	DISMIS
	JMP TAPIN4



/PUNCH FOR INTERRUPT

IPB,	AND (377
	DAC IPBTTM
	LAS
	AND (400
	SZA
	JMS FTA		/BIT 9, ASCII OUTPUT
	LAC IPBTTM
	RCL
	RTL
	RTL
	RTL
	RTL
	ADD IPBT#TM	/FORM BUFFER RING
	XOR I PUNI
	AND PUNMSK	/PUNMSK DETERMINES IN WHICH HALF OF WORD CHARACTERS ARE BEING PUT
	XOR I PUNI
	DAC I PUNI
	ISZ PUNI
	LAC PUNI
	SAD (LAW PUNBUF+PN	/CHECK END OF BUFFER HALF
	JMP IPB1

/CHECK COUNT FOR FULL BUFFER AND LEAVE

IPB0,	ISZ P#UNCNT
	EXITR
	LAC P#ON		/NO MORE ROOM IN BUFFER
	SPA
	JMS OPB		/TURN PUNCH ON AGAIN IF OFF
	LAC PUNCNT	/LET PUNCHING CATCH UP
	SMA
	JMP .-2
	EXITR

/CHANGE WORD HALFS, START AT BUFFER BEGINNING

IPB1,	LAC PUNMSK
	CMA		/MASK OTHER HALF OF WORD
	DAC PUNMSK
	LAW PUNBUF	/RESET BUFFER POINTER
	DAC PUNI
	JMP IPB0

/GET A CHARACTER FROM THE BUFFER AND PUNCH IT

/COME HERE ON PUNCH INTERRUPT

PUNINT,	JMS OPB
	DISMIS

/PUNCH ONE CHARACTER FROM THE PUNCH BUFFER

OPB,	0
	LAC OPBFLG	/CARRIAGE RETURN FLAG
	SZA
	JMP OPBLF		/IF LAST CHAR PUNCHED A CR, PUNCH A LINE FEET TOO
	LAC PUNO
	SAD (LAW PUNBUF+PN
	JMP OPB1		/SWITCH BUFFER HALFS
	LAC PUNCNT
	SAD (-PN-PN+1
	JMP OPBF		/NOTHING LEFT IN BUFFER TO PUNCH
	TAD (-0
	DAC PUNCNT
	LAC I PUNO
	ISZ PUNO
OPBM,	SKP		/IN NOP, DEPENDING ON WHICH HALF OF BUFFER
	JMP OPBM1		/CHARACTER IN LEFT HALF, SHIFT OVER
	AND (377
	SAD (215
	ISZ OPBFLG	/CARRIAGE RETURN, SET FLAG
OPBPUN,	JMS NOTAPE
	PLS
	DZM PON
	JMP I OPB
OPBLF,	DZM OPBFLG
	LAC (212		/LINE FEED
	JMP OPBPUN

OPB1,	LAW PUNBUF	/SET BUFFER PNTR
	DAC PUNO
	LAC OPBM
	XOR (SKP-NOP	/SKP IF IN RIGHT HALF OF BUFFER ALREADY
	DAC OPBM
	JMP OPB+4

OPBM1,	RAR
	RTR
	RTR
	RTR
	RTR
	JMP OPBM+2

OPBF,	PCF		/TURN OFF PUNCH INTERRUPT, LET BUFFER FILL UP
	CLC
	DAC PON		/SET FLAG TO RE-ENABLE IT
	JMP I OPB
NOTAPE,	0
	DAC PUNTEN#
	IORS
	AND (400		/BIT 9, PTP EMPTY
	SNA
	JMP .+4		/RETURN
	CLC		/IF NO MORE TAPE IN PTP
	HLT		/SET AC TO ALL ONES AND
	JMP .-6		/WAIT TIL PUNCH REFILLED
	LAC PUNTEN
	JMP I NOTAPE

/TYPE

TYPIT,	0
	DAC TYP#BTA
	703301
	SKP
	JMS BTA
	TLS
	JMS TYPTES
	JMP .
	JMP I TYPIT

TYPINT,	TCF
	ISZ
	DISMIS

TYPTES,	0
	LAC TYPIT
	RAL
	LAC TYPBTA
	JMP I TYPTES

/BAUDOT TO ASCII CONVERSION
BTA,	0
	AND (37
	SAD (37
	JMP BLETT
	SAD (33
	JMP BFIG
	ADD (LAC BTAT
	DAC BTAA
	LAC B#FLC
	RAL
BTAA,	XX
	SNL
	RAR9
	JMP I BTA
BLETT,	CLA!SKP
BFIG,	CLC
	DAC BFLC
	JMS TYPTES
	JMP I TYPIT

BTAT,	200200
	324265
	215215
	317271
	240240
	310243
	316254
	315256
	212212
	314251
	322264
	307246
	311270
	320260
	303272
	326273
	305263
	332242
	304244
	302277
	323211
	331266
	306241
	330257
	301255

	327262
	312247
	200200
	325267
	321261
	313250
	200200

/FIODEC TO ASCII
FTA,	0
	LAC PLK
	DAC FTAPL#K
	LAC IPBTTM
	AND (77
	SAD (72
	JMP FTAL
	SAD (74
	JMP FTAU
	SAD (77
	JMP FTACR
	ADD (LAC TFTA
	DAC FTAA
	LAC FT#ACAS
	RAR
FTAA,	XX
	SZL
	RAR9
FTAX,	AND (377
	DAC IPBTTM
	LAC FTAPLK
	DAC PLK
	JMP I FTA
FTAL,	CLA!SKP
FTAU,	LAW 1
	DAC FTACAS
	CLC
	JMP FTAX
FTACR,	LAC (215
	JMP FTAX
TFTA,	240240
	242261
	247262
	337263
	245264
	241265
	246266
	274267
	276270
	336271
	200200
	214214
	377377
	377377
	377377
	377377
	300260
	277257
	323323
	324324
	325325
	326326
	327327
	330330
	331331
	332332
	377377

	275254
	377377
	377377
	211211
	377377
	244377
	312312
	313313
	314314
	315315
	316316
	317317
	320320
	321321
	322322
	377377
	377377
	253255
	335251
	334243
	333250
	377377
	301301
	302302
	303303
	304304
	305305
	306306
	307307
	310310
	311311
	377377
	252256
	377377
	377377
	377377
	215215

/ASCII TO FIODEC
ATF,	0
	AND (377
	TAD (-237
	SPA
	JMP ATFL	/NOT IN TABLE - LOW
	TAD (-77
	SMA
	JMP GCR	/NOT IN TABLE - HIGH, EXIT
	TAD (400100
	RCR
	ADD (IASC
	DAC .+1
	XX
	SNL
	RAR9
	DAC IT#EMB
	AND (300
	XOR AFCASE	/INITIALLY 200
	SNA
	JMP ATFC
ATF1,	LAC ITEMB
	JMP I ATF
ATFL,	SAD (-26
	LAC (236	/TAB
	SAD (-23
	LAC (13	/STOP CODE
	SAD (-22
	LAC (277	/CARRIAGE RETURN
	SPA
ATF4,	JMP GCR	/ELIMINATE ANY OTHER "LOW" CHARS
	JMP I ATF
ATFC,	LAC AFCASE
	CMA
	AND (300
	DAC AFCASE
	SAD (100
	CLA!SKP
	LAM -1
	TAD (274
	ISZ MEDIAT
	JMP I ATF
/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
START
