358360

/	DECMATE II ROM CONTENTS

/	DECODED AND DISASSEMBLED BY CHARLES J. LASNER.

/	LAST EDIT:	02-DEC-1991	02:00:00	CJL

/	MAY BE ASSEMBLED WITH '/J' (PAL8 '/F') SWITCH SET.

/	THIS IS THE CODE  USED  IN  THE DECMATE II PRIMARY CONTROL ROM.  IT RESIDES IN
/	THREE 2716 PACKAGES  KNOWN  AS  E113,  E114, E115.  THE THREE ROMS ARE ENCODED
/	INTO  A 12-BIT IMAGE  OF  AN  ENTIRE  FIELD  IN  THE  PARTICULAR  ORGANIZATION
/	ILLUSTRATED BELOW.  FOR ALL  ROM  CONTENTS:  0.X=BIT X IN THE SPACE 0000-3777,
/	4.X=BIT X IN THE SPACE 4000-7777.

/	E113:	0	1	2	3	4	5	6	7

/	BIT:	0.0	0.1	0.2	0.3	0.4	0.5	0.6	0.7

/	E114:	0	1	2	3	4	5	6	7

/	BIT:	4.0	4.1	4.2	4.3	4.4	4.5	4.6	4.7

/	E115:	0	1	2	3	4	5	6	7

/	BIT:	0.8	4.8	0.9	4.9	0.10	4.10	0.11	4.11

/	THIS IS THE ASSEMBLY OF THE RELEASED ROM SET KNOWN AS 358E2, 359E2, 360E2.

/	WHEN THE DECMATE II IS FIRST POWERED UP, ROM CONTROL IS ENABLED FOR ALL DIRECT
/	(IF)  AND  INDIRECT  (DF)  REFERENCES  TO CP MEMORY, THUS THE  CPU  STARTS  AT
/	ROM-BASED ADDRESS CP07777.  THE ROM CODE MOVES A LOADING PROGRAM  TO PAGE ZERO
/	OF  THE CORRESPONDING RAM IN FIELD ZERO OF CP MEMORY, WHICH IS  THEN  STARTED.
/	TO ACCOMPLISH THE INITIAL MOVE OF THE LOADER, THE DF CONTROL IS CHANGED TO RAM
/	WHILE RETAINING IF CONTROL IN THE ROM.

/	THE LOADER MOVES THE BULK OF THE ROM CODE TO CP FIELD SEVEN AND THEN STARTS IT
/	THERE.  NO CODE IS MOVED  TO ANY ADDRESS LOWER THAN 0100, SINCE THE CODE IMAGE
/	IS STORED OFFSET BY 100.  THIS  MEANS THAT ROM LOCATION 0000 WINDS UP IN FIELD
/	7 LOCATION 0100 AND SO ON.  DURING  THE  LOAD  OPERATION,  THE  IF  CONTROL IS
/	ALWAYS SET TO RAM BECAUSE AT THIS POINT THE  LOADER  IS  RUNNING.    THE DF IS
/	SWITCHED  BETWEEN ROM AND RAM AS NECESSARY TO ACCOMPLISH THE  LOAD  OPERATION.
/	AFTER LOADING IS COMPLETE, THE ROM IS TOTALLY DISABLED.
/	DEFINITIONS.

/	OPERATE INSTRUCTIONS.

	R3L=	7014			/ROTATE AC LEFT THREE WITHOUT AFFECTING LINK

/	COMBINED OPERATE INSTRUCTIONS.

	NL0001=	CLA IAC			/LOAD AC WITH 0001
	NL0002=	CLA CLL CML RTL		/LOAD AC WITH 0002
	NL002A=	CLA CLL IAC RAL		/LOAD AC WITH 0002 ON 8/I OR NEWER
	NL0003=	CLA CLL CML IAC RAL	/LOAD AC WITH 0003
	NL0004=	CLA CLL IAC RTL		/LOAD AC WITH 0004
	NL0006=	CLA CLL CML IAC RTL	/LOAD AC WITH 0006
	NL0010=	CLA IAC R3L		/LOAD AC WITH 0010
	NL0100=	CLA IAC BSW		/LOAD AC WITH 0100
	NL2000=	CLA CLL CML RTR		/LOAD AC WITH 2000
	NL3777=	CLA CLL CMA RAR		/LOAD AC WITH 3777
	NL4000=	CLA CLL CML RAR		/LOAD AC WITH 4000
	NL5777=	CLA CLL CMA RTR		/LOAD AC WITH 5777
	NL6000=	CLA CLL CML IAC RTR	/LOAD AC WITH 6000
	NL7775=	CLA CLL CMA RTL		/LOAD AC WITH 7775
	NL7776=	CLA CLL CMA RAL		/LOAD AC WITH 7776
	NL7777=	CLA CMA			/LOAD AC WITH 7777

/	PROCESSOR I/O INSTRUCTIONS.

	CPD=	6266			/FORCE DF TO REFER TO MAIN MEMORY
	GCF=	6256			/GET CURRENT FIELDS
	PEX=	6004			/EXIT FROM CP TO MAIN MEMORY
	PG0=	6003			/RESET HLTFLG FLIP-FLOP
	PRQ3=	6236			/TYPE 3 PANEL REQUEST
	PRS=	6000			/READ PANEL STATUS
	RSP1=	6207			/READ FIRST STACK POINTER
	RSP2=	6227			/READ SECOND STACK POINTER
	SPD=	6276			/FORCE DF TO REFER TO CP MEMORY
	WSR=	6246			/WRITE SWITCH REGISTER (ROM CONTROL), CLEAR AC

/	INTERNAL I/O INSTRUCTIONS.

	KEY=	03			/KEYBOARD DEVICE CODE
	TTY=	04			/SCREEN DEVICE CODE

/	VIDEO INTERRUPT INSTRUCTIONS.

	VIDINT=	06			/VIDEO INTERRUPT DEVICE CODE

	VFL=	VIDINT^10+6000		/SET VIDEO INTERRUPT FLAG
	VSF=	VIDINT^10+6001		/SKIP ON, CLEAR VIDEO INTERRUPT FLAG
	VCL=	VIDINT^10+6002		/NOP (CLEAR THE AC?)
	VNOP1=	VIDINT^10+6003		/(NOP?)
	VDUMM1=	VIDINT^10+6004		/(NOP?)
	VIE=	VIDINT^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	VDUMM2=	VIDINT^10+6006		/(NOP?)
	VDUMM3=	VIDINT^10+6007		/(NOP?)
/	VIDEO CONTROLLER INSTRUCTION.

	VIDDEV=	12			/VIDEO CONTROLLER DEVICE CODE

	APTFL=	VIDDEV^10+6000		/SET APT INTERRUPT FLAG
	APTSKP=	VIDDEV^10+6001		/SKIP ON, CLEAR APT INTERRUPT FLAG
	LSCREG=	VIDDEV^10+6002		/LOAD VIDEO REGISTER SELECT
	CGLOAD=	VIDDEV^10+6003		/LOAD CHARACTER GENERATOR ADDRESS/DATA
	VLOAD=	VIDDEV^10+6004		/LOAD SELECTED REGISTER FROM AC[4-11]
	APTIE=	VIDDEV^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	VIDCON=	VIDDEV^10+6006		/AC TO VIDEO CONTROL
	VREAD=	VIDDEV^10+6007		/READ SELECTED REGISTER

/	PRINTER INTERFACE INSTRUCTIONS.

	PRICON=	32			/PRINTER INPUT DEVICE CODE

	PRIFL=	PRICON^10+6000		/SET PRINTER INPUT FLAG
	PRISKP=	PRICON^10+6001		/SKIP ON, CLEAR PRINTER INPUT FLAG
	PRICLR=	PRICON^10+6002		/CLEAR THE AC
	PRINO1=	PRICON^10+6003		/NOP
	PRIRS=	PRICON^10+6004		/OR INPUT BUFFER WITH AC
	PRIIE=	PRICON^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	PRIRB=	PRICON^10+6006		/LOAD INPUT BUFFER INTO AC
	PRINO2=	PRICON^10+6007		/NOP

	PROCON=	33			/PRINTER OUTPUT DEVICE CODE

	PROFL=	PROCON^10+6000		/SET PRINTER OUTPUT FLAG
	PROSKP=	PROCON^10+6001		/SKIP ON, CLEAR PRINTER OUTPUT FLAG
	PRONO1=	PROCON^10+6002		/NOP
	PRSB=	PROCON^10+6003		/LOAD BAUD RATE PER AC[8-11]
	PROPC=	PROCON^10+6004		/OUTPUT CHARACTER FROM AC[4-11]
	PROIE=	PROCON^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	PROLS=	PROCON^10+6006		/OUTPUT CHARACTER FROM AC[4-11], CLEAR AC
	PRONO2=	PROCON^10+6007		/NOP

/	RD51D I/O INSTRUCTIONS.

	RDNOP=	6700			/RESERVED INSTRUCTION
	RDSR=	6701			/SKIP ON, CLEAR DATA REQUEST FLAG
	RDSC=	6702			/SEND COMMAND PER AC
	RDSD=	6703			/SKIP ON, CLEAR DONE FLAG
	RDTD=	6704			/TRANSFER DATA TO/FROM AC
	RDWE=	6705			/WRITE INTERRUPT ENABLE PER AC[11]
	RDSE=	6706			/SKIP ON, CLEAR ERROR FLAG
	RDTEST=	6707			/RESERVED TEST INSTRUCTION THAT CLEARS THE AC
					/ONLY IF THE RD51D IS INSTALLED.
/	COMMUNICATIONS PORT DEFINITIONS.

	PORTIN=	30			/COMMUNICATIONS PORT INPUT DEVICE CODE

	IFL=	PORTIN^10+6000		/SET COMMUNICATIONS PORT INPUT/OUTPUT FLAG
	ISF=	PORTIN^10+6001		/SKIP ON, CLEAR PORT INPUT/OUTPUT FLAG
	ICF=	PORTIN^10+6002		/NOP (CLEAR THE AC?)
	INOP1=	PORTIN^10+6003		/(NOP?)
	IRS=	PORTIN^10+6004		/READ COMMUNICATIONS PORT RECEIVE BUFFER
	IIE=	PORTIN^10+6005		/PORT I/O INTERRUPT ENABLE PER AC[11]
	IRB=	PORTIN^10+6006		/READ COMMUNICATIONS PORT RECEIVE BUFFER
	INOP2=	PORTIN^10+6007		/(NOP?)

	PORTOUT=31			/COMMUNICATIONS PORT OUTPUT DEVICE CODE

	DUMBFL=	PORTOUT^10+6000		/SET COMMUNICATIONS PORT DUMMY FLAG
	DUMBSF=	PORTOUT^10+6001		/SKIP ON, CLEAR COMMUNICATIONS PORT DUMMY FLAG
	DUMBCF=	PORTOUT^10+6002		/NOP (CLEAR THE AC?)
 	ONOP1=	PORTOUT^10+6003		/(NOP?)
	OPC=	PORTOUT^10+6004		/LOAD COMMUNICATIONS PORT TRANSMIT BUFFER
	DUMBIE=	PORTOUT^10+6005		/PORT DUMMY INTERRUPT ENABLE PER AC[11]
	OLS=	PORTOUT^10+6006		/LOAD COMMUNICATIONS PORT TRANSMIT BUFFER
	ONOP2=	PORTOUT^10+6007		/(NOP?)

	PORTCON=36			/COMMUNICATIONS PORT CONTROL DEVICE CODE

	MFL=	PORTCON^10+6000		/SET MODEM CHANGE FLAG
	MSF=	PORTCON^10+6001		/SKIP ON, CLEAR MODEM CHANGE FLAG
	MLC=	PORTCON^10+6002		/LOAD MODEM CONTROL REGISTER
	MSB=	PORTCON^10+6003		/LOAD BAUD RATE REGISTER
	MRS=	PORTCON^10+6004		/READ MODEM STATUS REGISTER
	MIE=	PORTCON^10+6005		/MODEM CHANGE INTERRUPT ENABLE PER AC[11]
	MPSCC=	PORTCON^10+6006		/ACCESS MULTIPROTOCOL SERIAL CONTROLLER
	MPRESET=PORTCON^10+6007 	/RESET MULTIPROTOCOL SERIAL CONTROLLER
/	TTY: TRAP DEFINITIONS.

	TTYCON=	07			/DEVICE CODE FOR TTY: TRAP

	TTYFL=	TTYCON^10+6000		/SET TTY: TRAP FLAG
	TTYSF=	TTYCON^10+6001		/SKIP ON, CLEAR TTY: TRAP FLAG
	TTYCLR=	TTYCON^10+6002		/CLEAR THE AC
	TTNOP1=	TTYCON^10+6003		/NOP
	TTNOP2=	TTYCON^10+6004		/NOP
	TTYIE=	TTYCON^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	TTNOP3=	TTYCON^10+6006		/NOP
	TTNOP4=	TTYCON^10+6007		/NOP

/	CLOCK DEFINITIONS.

	CLKCON=	13			/REAL-TIME CLOCK DEVICE CODE

	CLFL=	CLKCON^10+6000		/SET CLOCK FLAG
	CLSK=	CLKCON^10+6001		/SKIP ON, CLEAR CLOCK FLAG
	CLNOP1=	CLKCON^10+6002		/NOP
	CLNOP2=	CLKCON^10+6003		/NOP
	CLNOP3=	CLKCON^10+6004		/NOP
	CLIE=	CLKCON^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	CLNOP4=	CLKCON^10+6006		/NOP
	CLNOP5=	CLKCON^10+6007		/NOP

/	KEYBOARD DEFINITIONS.

	KBICON=	11			/KEYBOARD INPUT DEVICE CODE

	KBIFL=	KBICON^10+6000		/SET KEYBOARD INPUT FLAG
	KBISF=	KBICON^10+6001		/SKIP ON, CLEAR KEYBOARD INPUT FLAG
	KBICLR=	KBICON^10+6002		/CLEAR THE AC
	KINOP1=	KBICON^10+6003		/NOP
	KBIRS=	KBICON^10+6004		/OR AC WITH KEYBOARD INPUT DATA
	KBIIE=	KBICON^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	KBIRB=	KBICON^10+6006		/READ KEYBOARD INPUT DATA INTO AC
	KINOP2=	KBICON^10+6007		/NOP

	KBOCON=	05			/KEYBOARD OUTPUT DEVICE CODE

	KBOFL=	KBOCON^10+6000		/SET KEYBOARD OUTPUT FLAG
	KBOSF=	KBOCON^10+6001		/SKIP ON, CLEAR KEYBOARD OUTPUT FLAG
	KONOP1=	KBOCON^10+6002		/NOP
	KONOP2=	KBOCON^10+6003		/NOP
	KBOPC=	KBOCON^10+6004		/OUTPUT AC TO KEYBOARD
	KBOIE=	KBOCON^10+6005		/WRITE INTERRUPT ENABLE PER AC[11]
	KBOLS=	KBOCON^10+6006		/OUTPUT AC TO KEYBOARD, CLEAR AC
	KONOP3=	KBOCON^10+6007		/NOP
/	RX50/RX01/RX02 DEFINITIONS.

	RXCON=	75			/RX50 DEVICE CODE

	SEL=	RXCON^10+6000		/SELECT DISKETTE PAIR PER AC[0] AND AC[11]
	LCD=	RXCON^10+6001		/LOAD COMMAND REGISTER, CLEAR AC
	XDR=	RXCON^10+6002		/TRANSFER DATA
	STR=	RXCON^10+6003		/SKIP ON TRANSFER FLAG, CLEAR TRANSFER FLAG
	SER=	RXCON^10+6004		/SKIP ON ERROR FLAG, CLEAR ERROR FLAG
	SDN=	RXCON^10+6005		/SKIP ON DONE FLAG, CLEAR DONE FLAG
	INTR=	RXCON^10+6006		/WRITE INTERRUPT ENABLE PER AC[11]
	RXINIT=	RXCON^10+6007		/INITIALIZE CONTROLLER AND DRIVES

/	MRI DEFINITIONS.

	JMPIC=	JMP I	.		/CURRENT PAGE JMP I

/	OTHER DEFINITIONS.

	A=	0			/EVEN HALF OF COMMUNICATIONS CHIP
	APUCON=	14			/APU/XPU DEVICE CODE
	B=	1			/ODD HALF OF COMMUNICATIONS CHIP
	DTIME=	400			/DISK WAIT TIME-OUT FACTOR
	ROWADR=	3660			/ROWTABLE ADDRESS IN FIELD 1
	T0S3BUF=5350			/TRACK 0, SECTOR 3 BUFFER IN FIELD 1
	FIELD	7			/MOST OF THE CODE EXECUTES IN FIELD 7

	PAGE	37			/STARTUP PAGE

/	THE ROM  STARTS  UP  HERE  (JUMPED TO FROM THE END OF THE PAGE).  SINCE WE ARE
/	STARTING FROM POWERUP,  BOTH  CONTROL BITS ARE CLEARED.  THE ROM IS REFERENCED
/	WHEN MEMORY  IS  READ  VIA  BOTH  THE  INSTRUCTION  AND DATA FIELDS INITIALLY.
/	FURTHER, FORCE-ZERO MODE  IS  IN  EFFECT WHICH MUST BE CLEARED TO USE EXTENDED
/	MEMORY.

	ROMGO=	.			/ROM STARTS HERE

ROMGO,	CIF	00			/SET OUR OWN FIELD; START CLEARING FZ MODE
	JMP	.+1			/THIS JUST LOADS OUR FIELD, BUT CLEARS FZ MODE
	NL4000				/SETUP PATTERN FOR RAM DATA FIELD
	WSR				/ROM IS ONLY IF NOW, DF IS RAM

/	APPARENTLY THE RAM MAY NOT YET BE WORKING, SO VARIOUS TESTS ARE  DONE UNTIL IT
/	RESPONDS CORRECTLY.

MEMTST,	CLA STL				/CLEAN UP AND SET A STOP BIT
WATLUP,	ISZ I	ATABLE+0/(L4001)	/BUMP UP TEST LOCATION
	NOP				/IN CASE IT SKIPS
	RAL				/MOVE PATTERN OVER
	SMA				/DONE ENOUGH?
	JMP	WATLUP			/NO, KEEP GOING
	CLA				/CLEAN UP
	SPD				/FORCE INDIRECT REFERENCES TO CP MEMORY

/	TRY TO STORE ALL ZEROES INTO THE RAM TEST LOCATION.

	DCA I	ATABLE+0/(L4001)	/ATTEMPT TO STORE CLEAR PATTERN
	TAD I	ATABLE+0/(L4001)	/GET IT BACK
	SZA CLA				/SKIP IF ACTUALLY CLEAR
	JMP	MEMTST			/GO BACK IF IT FLUNKS

/	TRY TO STORE ALTERNATING ZEROES AND ONES INTO THE RAM TEST LOCATION.

	TAD	L2525/(2525)		/GET A DATA PATTERN
	DCA I	ATABLE+0/(L4001)	/ATTEMPT TO STORE IT
	TAD I	ATABLE+0/(L4001)	/GET IT BACK
	TAD	L5252/(5252)		/ADD ON NEGATED PATTERN
	IAC				/ADD ONE TO FINISH THE COMPARISON
	SZA CLA				/SKIP IF IT MATCHES
	JMP	MEMTST			/GO DO IT AGAIN IF IT FLUNKS

/	TRY TO STORE ALTERNATING ONES AND ZEROES INTO THE RAM TEST LOCATION.

	TAD	L5252/(5252)		/GET A DATA PATTERN
	DCA I	ATABLE+0/(L4001)	/ATTEMPT TO STORE IT
	TAD I	ATABLE+0/(L4001)	/GET IT BACK
	TAD	L2525/(2525)		/ADD ON NEGATED PATTERN
	IAC				/ADD ONE TO FINISH THE COMPARISON
	SZA CLA				/SKIP IF IT MATCHES
	JMP	MEMTST			/GO DO IT AGAIN IF IT FLUNKS
/	TRY TO STORE ALL ONES INTO THE RAM TEST LOCATION.

	NL7777				/SET DATA PATTERN
	DCA I	ATABLE+0/(L4001)	/ATTEMPT TO STORE IT
	NL0001 CLL			/SET NEGATED PATTERN FOR COMPARISON
	TAD I	ATABLE+0/(L4001)	/ADD ON TEST VALUE
	SZA CLA				/SKIP IF IT MATCHES
	JMP	MEMTST			/GO DO IT AGAIN IF IT FLUNKS

/	MOVE THE IMAGE OF THE LOADING PROGRAM TO PAGE ZERO OF RAM.

	TAD	LPROGM+0/(4001)		/GET A WORD
	DCA I	ATABLE+0/(L4001)	/PUT A WORD
	TAD	LPROGM+1/(CODEXC-1)	/GET A WORD
	DCA I	ATABLE+1/(XR6)		/PUT A WORD
	TAD	LPROGM+2/(-ROMGO+1)	/GET A WORD
	DCA I	ATABLE+2/(MOVCNT)	/PUT A WORD
	TAD	LPROGM+3/(NL7777 CLL)	/GET A WORD
	DCA I	ATABLE+3/(LOADIT+0)	/PUT A WORD
	TAD	LPROGM+4/(DCA	XR1)	/GET A WORD
	DCA I	ATABLE+4/(LOADIT+1)	/PUT A WORD
	TAD	LPROGM+5/(CDF	00)	/GET A WORD
	DCA I	ATABLE+5/(LOADLP+0)	/PUT A WORD
	TAD	LPROGM+6/(NL0001)	/GET A WORD
	DCA I	ATABLE+6/(LOADLP+1)	/PUT A WORD
	TAD	LPROGM+7/(WSR)		/GET A WORD
	DCA I	ATABLE+7/(LOADLP+2)	/PUT A WORD
	TAD	LPROGM+10/(TAD I XR1)	/GET A WORD
	DCA I	ATABLE+10/(LOADLP+3)	/PUT A WORD
	TAD	LPROGM+11/(MQL)		/GET A WORD
	DCA I	ATABLE+11/(LOADLP+4)	/PUT A WORD
	TAD	LPROGM+12/(TAD	L4001)	/GET A WORD
	DCA I	ATABLE+12/(LOADLP+5)	/PUT A WORD
	TAD	LPROGM+13/(WSR)		/GET A WORD
	DCA I	ATABLE+13/(LOADLP+6)	/PUT A WORD
	TAD	LPROGM+14/(CLA MQA)	/GET A WORD
	DCA I	ATABLE+14/(LOADLP+7)	/PUT A WORD
	TAD	LPROGM+15/(CDF	70)	/GET A WORD
	DCA I	ATABLE+15/(LOADLP+10)	/PUT A WORD
	TAD	LPROGM+16/(DCA I XR6)	/GET A WORD
	DCA I	ATABLE+16/(LOADLP+11)	/PUT A WORD
	TAD	LPROGM+17/(ISZ	MOVCNT)	/GET A WORD
	DCA I	ATABLE+17/(LOADLP+12)	/PUT A WORD
	TAD	LPROGM+20/(JMP	LOADLP)	/GET A WORD
	DCA I	ATABLE+20/(LOADLP+13)	/PUT A WORD
	TAD	LPROGM+21/(CIF	70)	/GET A WORD
	DCA I	ATABLE+21/(LOADLP+14)	/PUT A WORD
	TAD	LPROGM+22/(JMP I .+1)	/GET A WORD
	DCA I	ATABLE+22/(LOADLP+15)	/PUT A WORD
	TAD	LPROGM+23/(CODESTART)	/GET A WORD
	DCA I	ATABLE+23/(LOADLP+16)	/PUT A WORD
/	NOW STARTUP THE LOADER TO MOVE THE CODE TO RAM.

	NL0001				/SETUP FOR
	WSR				/RAM IF AND ROM DF
	JMP	LOADIT			/GO START IT UP

L2525,	2525				/DATA
L5252,	5252				/PATTERNS

	LPROGM=	.			/IMAGE OF LOADING PROGRAM HERE

	RELOC	11			/FOOL THE ASSEMBLER

XR1,					/AUTO-INDEX USED FOR MOVING THE ROM

	RELOC	15			/FOOL THE ASSEMBLER SOME MORE

	LOADER=	.			/LOADER EXECUTES FROM HERE

L4001,	4001				/ROM DISABLE CONSTANT
XR6,	CODEXC-1			/RAM STORE POINTER
MOVCNT,	-ROMGO+1			/MOVE COUNTER

/	THE LOADER  STARTS  HERE.   ALL IF REFERENCES ARE NOW IN RAM.  THE CODE IN THE
/	ROM WILL BE MOVED TO FIELD 7.

LOADIT,	NL7777 CLL			/SET (AUTO-INCREMENTED) POINTER
	DCA	XR1			/TO LOWEST ROM LOCATION
LOADLP,	CDF	00			/ROM CODE IS IN FIELD ZERO
	NL0001				/SETUP FOR
	WSR				/RAM IF AND ROM DF
	TAD I	XR1			/GET A ROM WORD
	MQL				/SAVE IT FOR NOW
	TAD	L4001/(4001)		/SETUP FOR
	WSR				/RAM IF AND RAM DF
	CLA MQA				/GET THE ROM VALUE
	CDF	70			/CODE LOADS INTO FIELD SEVEN
	DCA I	XR6			/STORE INTO RAM
	ISZ	MOVCNT			/DONE YET?
	JMP	LOADLP			/NO, KEEP GOING
	CIF	70			/GOTO NEW EXECUTION FIELD
	JMP I	.+1/(CODESTART)		/GO START IT UP
	CODESTART			/THROUGH HERE

	RELOC				/UN-FOOL THE ASSEMBLER
ATABLE,	LOADER+00			/TABLE OF LOADING ADDRESSES FOR MOVED LOADER
	LOADER+01			/
	LOADER+02			/
	LOADER+03			/
	LOADER+04			/
	LOADER+05			/
	LOADER+06			/
	LOADER+07			/
	LOADER+10			/
	LOADER+11			/
	LOADER+12			/
	LOADER+13			/
	LOADER+14			/
	LOADER+15			/
	LOADER+16			/
	LOADER+17			/
	LOADER+20			/
	LOADER+21			/
	LOADER+22			/
	LOADER+23			/LAST ADDRESS OF MOVED LOADER CODE

	ZBLOCK	7776-.			/EMPTY SPACE

/	WHEN THE  CODE  IS IN RAM, THESE LOCATIONS IN CP FIELD 0 ARE USED AS THE START
/	OF THE CP  INTERRUPT  HANDLER.  THE MAIN MEMORY INTERRUPTED PC IS STORED IN CP
/	00000 AND CONTROL IS  REGAINED  AT CP 07777.  INVARIABLY, THE INSTRUCTION USED
/	THERE IS JMP I .-1.  THE POINTER ADDRESS IS THEREFORE STORED HERE AT CP 07776.

ROMSP,	.-.				/USED LATER AS CP INTERRUPT POINTER

/	THE ROM PROGRAM GAINS CONTROL HERE.  ALSO USED LATER FOR CP INTERRUPTS.

ROMST,	JMP	ROMGO			/CONTINUE THERE
/	START OF  PAGE  ZERO WHILE RUNNING IN FIELD 7.  THESE LOCATIONS ARE NOT LOADED
/	BY THE ROM'S LOADING PROGRAM BUT ARE USED BY THE MOVED CODE AS TEMPORARIES.

	*0				/START AT THE BEGINNING

	NOPUNCH				/DON'T GENERATE BINARY

RIMADR,					/APT RIM-LOADER TEMPORARY
INTADR,					/CP-INTERRUPTS PC STORED HERE

/	THE FOLLOWING ARE DEFINITIONS FOR MAIN MEMORY INTERRUPTS IN FIELD 0.

INTADR,	.-.				/MAIN-MEMORY INTERRUPTS PC STORED HERE
INT1,	JMP I	INT2			/WHAT'S PUT HERE IN MAIN MEMORY FIELD 0
INT2,	INTHND				/POINTER TO MAIN MEMORY INTERRUPT HANDLER
TIMEOUT,.-.				/TIME-OUT COUNTER FOR LOOPBACK TEST
CLKTICK,.-.				/CLOCK TICK COUNTER FOR LOOPBACK TEST
CSTATUS,.-.				/COUNT PATTERN PROGRESS STATUS
PATTERN,.-.				/COUNT PATTERN TEMPORARY
TSTATUS,.-.				/LOOPBACK CP TEST STATUS

	*10				/GET TO AUTO-INDEX AREA

XR0,	.-.				/AUTO-INDEX REGISTER 0
XR1,	.-.				/AUTO-INDEX REGISTER 1
XR2,	.-.				/AUTO-INDEX REGISTER 2
XR3,	.-.				/AUTO-INDEX REGISTER 3
XR4,	.-.				/AUTO-INDEX REGISTER 4
XR5,	.-.				/AUTO-INDEX REGISTER 5
XR6,	.-.				/AUTO-INDEX REGISTER 6
XR7,	.-.				/AUTO-INDEX REGISTER 7

	*20				/GET PAST AUTO-INDEX AREA

CTMP1,	.-.				/OUTPUT COUNTING TEMPORARY FOR LOOPBACK TEST
CTMP2,	.-.				/INPUT COUNTING TEMPORARY FOR LOOPBACK TEST
CNTLO,	.-.				/LOW-ORDER COUNTER FOR LOOPBACK TESTING
CNTHI,	.-.				/HIGH-ORDER COUNTER FOR LOOPBACK TESTING
TEMP1,	.-.				/TEMPORARY
TEMP2,	.-.				/TEMPORARY
TEMP3,	.-.				/TEMPORARY

	ZBLOCK	1			/EMPTY SPACE

/	THESE SIX ARE PRINTED AS A GROUP.

TM0,	.-.				/TEMPORARY
COMTM1,	.-.				/COMMUNICATIONS PORT TESTING TEMPORARY
MTM1,	.-.				/TEMPORARY
MTM2,	.-.				/TEMPORARY
SP1SAVE,.-.				/FIRST STACK POINTER SAVED HERE
SP2SAVE,.-.				/SECOND STACK POINTER SAVED HERE
MTM5,	.-.				/TEMPORARY
MTM6,	.-.				/TEMPORARY
MTM7,	.-.				/TEMPORARY
TINC,	.-.				/TEMPORARY
T0,	.-.				/TEMPORARY
T1,	.-.				/TEMPORARY
T2,	.-.				/TESTING TEMPORARY
T3,	.-.				/TEMPORARY
T4,	.-.				/TEMPORARY
T5,	.-.				/TEMPORARY
T6,	.-.				/TEMPORARY
T7,	.-.				/TEMPORARY
T8,	.-.				/TEMPORARY
RXCMD,	.-.				/LATEST RX50 COMMAND
ESTATUS,.-.				/CUMULATIVE ERROR STATUS
LCHAR,	.-.				/LATEST COMMAND CHARACTER IN SETUP ROUTINE
ROW,	.-.				/ROW POSITION FOR CHARACTER ROUTINES
COLUMN,	.-.				/COLUMN POSITION FOR CHARACTER ROUTINES
CCNT,	.-.				/DELIMITER CHARACTER SEARCH COUNT
PSTATUS,.-.				/STATUS AT POWER-ON

	ENPUNCH				/RESTORE BINARY
/	START OF ROM-BASED CODE.

	*0				/START AT THE BEGINNING

	ROMADR=	.			/WHERE IT IS LOADED WHILE IN ROM

	RELOC	100			/FOOL THE ASSEMBLER

	CODEXC=	.			/WHERE IT RUNS IN FIELD 7

	3732				/THIS LOCATION IS PROBABLY A VERSION NUMBER

PCHRPRT,CHRPRT				/POINTER TO SCREEN CHARACTER OUTPUT ROUTINE
PPPTABL,PPTABLE				/POINTER TO PROGRAMMING TABLE POINTER
PROWLOA,ROWLOAD				/POINTER TO ROWTABLE AND REGISTER LOAD ROUTINE
Z7,	7				/CONSTANT 0007
Z10,	10				/CONSTANT 0010
Z12,	12				/CONSTANT 0012
Z17,	17				/CONSTANT 0017
Z20,	20				/CONSTANT 0020
Z102,	102				/CONSTANT 0102
Z200,	200				/CONSTANT 0200
Z237,	237				/CONSTANT 0237
Z0301,	0301				/CONSTANT 0301
Z377,	377				/CONSTANT 0377
Z400,	400				/CONSTANT 0400
Z2525,	2525				/CONSTANT 2525
Z3777,	3777				/CONSTANT 3777
JMPIM1,	ROMSP&177+JMPIC			/JMP I .-1 CONSTANT FOR RESTART ADDRESS
ZCDF,	CDF	00			/CONSTANT 6201
PWRIBUF,WRIBUFFER			/POINTER TO WRITE BUFFER
PAPTROU,APTROUTINE			/POINTER TO APT ROUTINE

	6777				/CONSTANT 6777 (UNUSED?)

Z7766,	7766				/CONSTANT 7766
Z7760,	7760				/CONSTANT 7760
Z7741,	7741				/CONSTANT 7741
Z7400,	7400				/CONSTANT 7400
DTIMOUT,-DTIME				/DISK WAIT TIMEOUT FACTOR
Z7775,	7775				/CONSTANT 7775
CPIADDR,/ROMSP				/POINTER ADDRESS FOR CP-INTERRUPTS
Z7776,	7776				/CONSTANT 7776
PROMST,	ROMST				/ROM (RE)START ADDRESS FOR INTERRUPTS, ETC.
LBLADR,	LBLOAD-1			/LOOPBACK TEST CODE ADDRESS (-1)
LBMCNT,	LBTEST-LBTEND			/LENGTH OF LOOPBACK TEST CODE TO BE MOVED
CPLADR,	CPLOAD-1			/CP-INTERRUPT CODE ADDRESS (-1)
CPMCNT,	CPLOAD-CPEND2			/LENGTH OF CP-INTERRUPT CODE TO BE MOVED
PCOMLOA,COMLOAD				/=> COMMUNICATIONS CHIP REGISTER LOAD ROUTINE
PCOMREA,COMREAD				/=> COMMUNICATIONS CHIP REGISTER READ ROUTINE
PCLR23,	CLR23				/POINTER TO FIELD 2, 3 CLEAR ROUTINE
PRXCOMD,RXCOMD				/POINTER TO RXCOMD ROUTINE
PSSTRIN,SSTRING				/POINTER TO SSTRING ROUTINE
/	THE FOLLOWING  LOCATION  IS UNREFERENCED;  PERHAPS THERE IS A CONVENTION ABOUT
/	WHERE TO RESTART THE ROM PROGRAM?

	PRGDONE				/POINTER TO PRGDONE ROUTINE (UNUSED?)

PMEMCOM,MEMCOMP				/POINTER TO MEMORY COMPARE ROUTINE
PKBDIN,	KBDIN				/POINTER TO KEYBOARD INPUT ROUTINE
PCALLSU,CALLSUB				/POINTER TO TEST (SUBROUTINE) LOCATION
Z205,	205				/CONSTANT 0205

	ZBLOCK	21			/EMPTY SPACE

/	********

	SUBR				/POINTER TO SUBR
SUB176,	.-.				/ENTRY HERE
	JMP I	.-2/[SUBR]		/GO THERE
	PAGE

/	THIS IS WHERE THE  CODE  STARTS  AFTER  THE  LOADER HAS MOVED IT FROM 00000 TO
/	70100.  AT THIS POINT  THE  ROM  IS  TOTALLY  DISABLED.   IF AUTOMATIC PRODUCT
/	TESTING IS IN PROGRESS, IT IS  POSSIBLE  THAT  A PREVIOUSLY LOADED MAIN MEMORY
/	TEST PROGRAM HAS EXITED VIA A PANEL REQUEST INSTRUCTION.  THIS ACTION CAUSES A
/	TOTAL RESTART TO THIS LOCATION.

	CODESTA=.			/THE CODE STARTS HERE

CODESTA,CLA CLL				/CLEAN UP
	PRS				/GET (POWER-ON) STATUS NOW
	DCA	PSTATUS			/SAVE FOR LATER
	PG0				/RESET THE HLTFLG FLIP-FLOP

/	THE PIE CHIPS HAVE TO BE PROGRAMMED BEFORE THEY CAN BE USED.  UP UNTIL NOW ALL
/	IOTS HAVE BEEN INTERNAL;  AN UNIMPLEMENTED EXTERNAL IOT (6777) WILL BE USED TO
/	LOAD IN THE DEVICE-SPECIFIC INFORMATION.

	TAD I	PPPTABLE/[PPTABLE]	/GET PROGRAMMING TABLE POINTER
	DCA	XR0			/STASH THE POINTER
PRGLUP,	TAD I	XR0			/GET THE LATEST
	SNA				/SKIP IF NOT AT END
	JMP	PRGDONE			/CONTINUE THERE IF DONE
	6777				/UN-IMPLEMENTED EXTERNAL IOT TO SETUP CHIPS
	CLA				/CLEAN UP
	JMP	PRGLUP			/KEEP GOING

/	COMES HERE WHEN I/O PORT INITIALIZING IS DONE.

PRGDONE,TAD	Z237/[237]		/GET PORT ENABLE VALUE
	MLC				/ENABLE ALL OUTPUT LINES
	JMS I	PROWLOAD/[ROWLOAD]	/CALL ROWTABLE AND REGISTER LOAD ROUTINE
	JMS I	PCLR23/[CLR23]		/CLEAR FIELDS 2, 3 (AND BITS IN 13705, 13707)
	CDF	70			/BACK TO OUR FIELD
	NL7776				/-2
	DCA	XR0			/SETUP COUNTER
VAGAIN,	DCA	XR1			/CLEAR TIME-OUT COUNTER
VWATLP,	VSF				/VIDEO RETRACE FLAG UP?
	SKP				/SKIP IF NOT
	JMP	VPAST			/JUMP IF SO
	ISZ	XR1			/WAITING TOO LONG?
	JMP	VWATLP			/NO, KEEP GOING
	JMP	PRGDONE			/YES, GO DO IT ALL OVER AGAIN

VPAST,	TAD	L72/(72)		/GET VALUE FOR REGISTER 3A
	LSCREG				/LOAD THE REGISTER
	VREAD				/GET THE STATUS THERE, CLEAR INTERNAL FLAGS
	CLA				/CLEAN UP
	ISZ	XR0			/DONE IT ENOUGH TIMES?
	JMP	VAGAIN			/NO, GO DO IT AGAIN
/	FOR SOME PURPOSE, WE NEED TO STORE 0100 INTO CP20301.

	NL0100 CLL			/GET VALUE
	CDF	20			/GOTO BUFFER FIELD
	DCA I	Z0301/[0301]		/STORE IN BUFFER
	CDF	70			/BACK TO OUR FIELD

/	IF  THE PRINTER PORT HAS THE APTEN LINE GROUNDED, WE GO IMMEDIATELY  INTO  THE
/	AUTOMATIC PRODUCT TEST DOWNLOAD MODE.  THIS COULD  BE  A SECONDARY CALL TO THE
/	DOWNLOAD  ROUTINE IF A PREVIOUSLY LOADED ROUTINE EXITED VIA  A  PANEL  REQUEST
/	INSTEAD OF HLT.

	APTSKP				/AUTOMATIC PRODUCT TEST REQUESTED?
	JMP	MEMTEST			/NO, JUST KEEP GOING
	JMS I	.+1;	DOWNLOAD	/YES, GO DOWNLOAD SOME STUFF.

L72,	72				/CONSTANT 0072

/	MEMORY TESTING.  ALTERNATING ONES AND  ZEROES  ARE  STORED  INTO ALL FIELDS IN
/	MAIN MEMORY AND FIELDS 2-6 IN CP MEMORY.  CHECK IF THE PATTERN WORKED AND THEN
/	REVERSE ALL PARAMETERS EACH PASS FOR SEVERAL ITERATIONS.

MEMTEST,CPD				/INDIRECT TO MAIN MEMORY FROM NOW ON
	CDF	70			/RESET TO OUR FIELD FIRST (WHY?)
	DCA	T2			/CLEAR FIELD COUNTER

/	EXECUTE CDF TO LATEST TEST FIELD.

MLODLP,	TAD	T2			/GET LATEST FIELD
	AND	Z7/[7]			/JUST FIELD BITS
	R3L				/MOVE UP
	TAD	ZCDF/[CDF]		/MAKE IT A CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF TEST FIELD INSTRUCTION
	DCA	T1			/CLEAR ADDRESS POINTER

/	STORE TEST PATTERN IN LATEST TEST FIELD.

FILLIT,	TAD	Z2525			/GET ALTERNATING TEST PATTERN
	DCA I	T1			/STASH INTO TEST MEMORY
	ISZ	T1			/BUMP TO NEXT
	JMP	FILLIT			/GO BACK FOR MORE

/	BUMP TO NEXT FIELD AND CHECK WHICH MEMORY BANK WE ARE TESTING.

	ISZ	T2			/BUMP TO NEXT FIELD
	TAD	T2			/GET LATEST FIELD
	AND	Z10/[10]		/JUST GROUP BIT
	SNA CLA				/SKIP IF FIRST GROUP DONE
	JMP	MLODLP			/GO BACK AGAIN
/	CP MEMORY IS BEING TESTED; CHECK IF WE JUST LOADED FIELD 6.

	TAD	T2			/GET LATEST FIELD
	IAC				/LOOK AT NEXT TENTATIVE FIELD
	AND	Z20/[20]		/CHECK IF AT LAST MEMBER (WHICH WOULD BE US!)
	SZA CLA				/SKIP IF NOT THERE YET	
	JMP	MEMLOADED		/JUMP IF AT END

/	CHECK IF WE ARE JUST FINISHED LOADING MAIN MEMORY.

	TAD	T2			/GET LATEST FIELD
	AND	Z7/[7]			/JUST FIELD BITS
	SZA CLA				/SKIP IF GROUP DONE
	JMP	MLODLP			/GO BACK AGAIN

/	SWITCH INDIRECTS BACK TO CP MEMORY. AVOID TESTS IN FIELDS 0 AND 1.

	SPD				/WILL BE CP INDIRECTS FROM NOW ON
	ISZ	T2			/BUMP LATEST FIELD
	ISZ	T2			/DO IT TWICE
	JMP	MLODLP			/KEEP GOING

/	COMES HERE WHEN ALL TESTABLE FIELDS ARE FILLED WITH THE TEST PATTERN.

MEMLOAD,DCA	T1			/CLEAR ADDRESS POINTER
	DCA	T2			/CLEAR FIELD COUNTER
	TAD	Z2525/[2525]		/GET TEST VALUE
	CMA				/INVERT FOR CHECKING LATER
	DCA	T0			/STASH IT
	CPD				/MAIN MEMORY INDIRECTS FROM NOW ON
	NL0001				/SETUP FOR SINGLE
	DCA	TINC			/FIELD INCREMENT
	NL7775				/SETUP FOR THREE
	DCA	XR1			/COMPLETE TEST PASSES
MTSTLP,	JMS I	PMEMCOMP/[MEMCOMP]	/CHECK LATEST FIELD FOR PROPER TEST VALUE
	JMP	MEMTEST			/MEMORY FAILED TO MATCH, GO BACK FOR MORE
	TAD	TINC			/GET INCREMENT
	TAD	T2			/UPDATE FIELD
	DCA	T2			/STORE BACK
	TAD	TINC			/GET INCREMENTAL FACTOR
	SPA CLA				/SKIP IF STILL ADDING
	JMP	CDWNTST			/JUMP IF NOT

/	FOUND OUT IF WE ARE FINISHED (JUST TESTED CP FIELD 6) WHILE COUNTING FORWARD.

	TAD	T2			/GET CURRENT FIELD
	IAC				/TENTATIVELY ADD ONE
	AND	Z20/[20]		/CHECK IF AT LAST FIELD
	SNA CLA				/SKIP IF SO
	JMP	CPMTST			/JUMP IF NOT
/	BACKUP TO FIELD 6 TO START NEXT TEST PASS.

	NL7777				/BACKUP
	TAD	T2			/ADD ON LATEST FIELD
BACKEND,DCA	T2			/STORE BACK
	JMP	PASSEND			/CONTINUE THERE

/	COUNTING FIELDS DOWN; CHECK IF WE JUST FINISHED A PASS.

CDWNTST,TAD	T2			/GET CURRENT FIELD
	SPA CLA				/SKIP IF STILL VALID
	JMP	BACKEND			/JUMP IF NOT

/	CHECK IF WE ARE ABOUT TO START TESTING CP MEMORY.

CPMTST,	TAD	T2			/GET CURRENT FIELD
	AND	Z10/[10]		/CHECK IF INTO CP GROUP
	SNA CLA				/SKIP IF SO
	JMP	MTSTLP			/KEEP GOING
	TAD	TINC			/GET INCREMENTAL FACTOR
	SPA CLA				/SKIP IF STILL POSITIVE
	JMP	NEGTST			/JUMP IF NOT

/	CHECK IF  FIRST  TIME  IN  CP  MEMORY;  SWITCH OVER TO CP INDIRECTS AND BYPASS
/	TESTING OF FIELD 0 AND FIELD 1.

	TAD	T2			/GET LATEST FIELD
	AND	Z7/[7]			/JUST FIELD BITS
	SNA CLA				/SKIP IF NOT AT ZERO
	NL002A				/ELSE START HERE
	TAD	T2			/ADD ON CURRENT FIELD
	DCA	T2			/STORE BACK
	SPD				/PANEL INDIRECTS FROM NOW ON
	JMP	MTSTLP			/CONTINUE THERE

/	IF COUNTING FIELDS DOWN, WE MUST AVOID FIELD 0 AND FIELD 1;  IF CP FIELD 2 WAS
/	JUST FINISHED, THEN SWITCH OVER TO MAIN FIELD 7.

NEGTST,	NL7777				/-1
	TAD	T2			/COMPARE TO LATEST FIELD
	AND	Z7/[7]			/JUST FIELD BITS
	SZA CLA				/SKIP IF WE ARE AT FIELD 1
	JMP	MTSTLP			/JUST KEEP GOING
	CPD				/MAIN MEMORY INDIRECTS FROM NOW ON
	TAD	Z7/[7]			/SETUP FOR FIELD 7
	DCA	T2			/STASH IN FIELD COUNTER
	JMP	MTSTLP			/CONTINUE THERE
/	COMES HERE AT THE END OF A TEST PASS OVER ALL TESTED FIELDS.

PASSEND,TAD	TINC			/GET INCREMENT FACTOR
	CIA				/INVERT IT
	DCA	TINC			/STORE BACK
	TAD	T0			/GET TEST PATTERN COMPARE VALUE
	CMA				/INVERT THE BITS
	DCA	T0			/STORE BACK
	TAD	TINC			/GET INCREMENT AGAIN
	SPA CLA				/SKIP IF POSITIVE
	NL7777				/ELSE SET -1
	DCA	T1			/STORE EITHER WAY
	ISZ	XR1			/DONE ENOUGH PASSES?
	JMP I	PMTSTLP/(MTSTLP)	/NO, KEEP GOING
	JMS I	PCLR23/[CLR23]		/CLEAR FIELDS 2, 3 (AND BITS IN 13705, 13707)
	CDF	70			/BACK TO OUR FIELD
	APTSKP				/AUTOMATIC PRODUCT TESTING?
	SKP				/SKIP IF NOT
	JMS I	PAPTROUTINE/[APTROUTINE]/CALL ROUTINE IF SO

/	MOVE CP 72600-72746 TO MAIN 00200-00346.  THIS IS THE MAIN MEMORY  ROUTINE AND
/	INTERRUPT HANDLER FOR THE PRINTER LOOPBACK TEST.

	TAD	LBLADR/[LBLOAD-1]	/SETUP THE
	DCA	XR0			/SOURCE POINTER
	TAD	LBMCNT/[LBTEST-LBTEND]	/SETUP THE
	DCA	XR1			/MOVE COUNTER
	TAD	LBADR/(LBTEST-1)	/SETUP THE
	DCA	XR2			/DESTINATION POINTER
LBMVLP,	TAD I	XR0			/GET A WORD
	CDF	00			/GOING TO FIELD 0
	CPD				/GOING TO MAIN MEMORY
	DCA I	XR2			/PUT A WORD
	SPD				/INDIRECTS BACK TO CP MEMORY AGAIN
	CDF	70			/BACK TO OUR FIELD
	ISZ	XR1			/DONE YET?
	JMP	LBMVLP			/NO, GO BACK
/	MOVE CP 73000-75600 TO CP 04000-06600.  THIS  IS  THE CP-INTERRUPT HANDLER FOR
/	THE PRINTER LOOPBACK TEST.

/	PROGRAMMING  NOTE:   THE LENGTH OF EXECUTABLE CODE REQUIRED TO BE RELOCATED IS
/	APPARENTLY MUCH  SMALLER  THAN  THE  ACTUAL  AMOUNT OF CODE MOVED.  THE LENGTH
/	SHOULD BE CPEND-CPINT  INSTEAD  OF  CPEND2-CPLOAD.   THIS LENGTH MAY INTERFERE
/	WITH AUTOMATIC PRODUCT TESTING  OR  CAUSE  SOME OTHER BUG.  IT IS NOT KNOWN AT
/	THIS TIME IF THE ORIGINAL PROGRAMMER'S INTENTION WAS TO OVERLAY ANY OTHER CODE
/	BEYOND THE INTERRUPT HANDLER, BUT THIS  SOURCE  CODE FOLLOWS THE ROM CONTENTS,
/	BUGS AND ALL :-).

	TAD	CPLADR/[CPLOAD-1]	/SETUP THE
	DCA	XR0			/SOURCE POINTER
	TAD	CPMCNT/[CPLOAD-CPEND2]	/SETUP THE
	DCA	XR1			/MOVE COUNTER
	NL3777/TAD (CPINT-1)		/SETUP THE
	DCA	XR2			/DESTINATION POINTER
CPMVLP,	TAD I	XR0			/GET A WORD
	CDF	00			/GOING TO FIELD 0
	DCA I	XR2			/PUT A WORD
	CDF	70			/BACK TO OUR FIELD
	ISZ	XR1			/DONE YET?
	JMP	CPMVLP			/NO, KEEP GOING

/	NOW WE HAVE TO MOVE JMP I .-1 TO CP 07777 AND 4000 TO CP 07776 TO COMPLETE THE
/	INTERRUPT HANDLER.

	NL4000/TAD (CPINT)		/GET INTERRUPT HANDLING ADDRESS
	CDF	00			/GOING TO FIELD 0
	DCA I	CPIADDRESS/[ROMSP]	/STORE IN POINTER LOCATION
	TAD	JMPIM1/[ROMSP&177+JMPIC]/GET JMP I .-1 INSTRUCTION
	DCA I	PROMST/[ROMST]		/STORE IN RESTART ADDRESS
	CIF CDF	00			/GOING TO FIELD 0
	CPD				/INDIRECTS TO MAIN MEMORY
	PEX				/LEAVING CP MEMORY
	JMP I	Z200/[200]		/GO START IT UP

LBADR,	LBTEST-1			/LOOPBACK TEST ADDRESS (-1)
PMTSTLP,MTSTLP				/POINTER TO LOOP BRANCH
/	COMES HERE  WHEN  THE  PRINTER  LOOPBACK  TEST IS DONE TO TEST THE KEYBOARD IN
/	LOOPBACK MODE.

LBDONE,	DCA	ESTATUS			/SAVE (POSSIBLE ERROR) RESULTS
	TAD	L16/(16)		/GET 9600 BAUD VALUE
	PRSB				/SET BAUD RATE
	CLA				/CLEAN UP
	DCA	CTMP1			/CLEAR OUTPUT TEST VALUE
	DCA	CTMP2			/CLEAR INPUT TEST VALUE
	DCA	CNTLO			/CLEAR LOW-ORDER COUNTER
	TAD	M52/(-52)		/SETUP THE
	DCA	CNTHI			/HIGH-ORDER COUNTER
	APTSKP				/AUTOMATIC PRODUCT TESTING?
	TAD	Z20/[20]		/NO, GET LOOPBACK MODE VALUE
	VIDCON				/LOAD NEW MODE EITHER WAY
	KBIRB				/READ KEYBOARD DATA TO SET UART
	CLA				/THROW IT AWAY
	KBOPC				/OUTPUT  TO UART NOW
LUPLUP,	KBISF				/KEYBOARD INPUT FLAG UP?
	SKP				/SKIP IF NOT
	JMP	LUPIN			/JUMP IF SO
	KBOSF				/KEYBOARD OUTPUT FLAG UP?
	SKP				/SKIP IF NOT
	JMP	LUPOUT			/JUMP IF SO
	ISZ	CNTLO			/DONE WAITING?
	JMP	LUPLUP			/NO, KEEP GOING
	ISZ	CNTHI			/ENOUGH TIMES?
	JMP	LUPLUP			/NO, KEEP GOING
	JMP	LUPTIMOUT		/YES, CONTINUE THERE

LUPIN,	KBISF				/SKIP ON, CLEARING THE INPUT FLAG
L16,	16				/9600 BAUD RATE VALUE; HERE IN CASE IT SKIPS
	KBIRB				/GET THE INPUT VALUE
	AND	Z377/[377]		/JUST 8-BIT CHARACTER
	CIA				/INVERT FOR TEST
	TAD	CTMP2			/COMPARE TO TEST VALUE
	SZA CLA				/SKIP IF IT MATCHES
	VIDCON				/CLEAR LOOPBACK IF NOT
	TAD	CTMP2			/GET INPUT PATTERN VALUE
	JMS I	PCOUNTUP/(COUNTUP)	/BUMP TO NEXT VALUE
	JMP	LUPDONE			/ALL VALUES USED
	DCA	CTMP2			/SAVE UPDATED VALUE
	JMP	LUPLUP			/KEEP GOING

LUPOUT,	KBOSF				/SKIP ON, THUS CLEARING OUTPUT FLAG
	NOP				/JUST IN CASE IT SKIPS
	TAD	CTMP1			/GET COUNT PATTERN VALUE
	JMS I	PCOUNTUP/(COUNTUP)	/BUMP TO NEXT VALUE
	JMP	LUPLUP			/ALL VALUES USED; KEEP GOING FOR INPUT'S SAKE
	DCA	CTMP1			/SAVE UPDATED VALUE
	TAD	CTMP1			/GET IT BACK
	KBOLS				/OUTPUT IT
	CLA				/CLEAN UP
	JMP	LUPLUP			/KEEP GOING
M52,	-52				/CONSTANT 7726
PCOUNTU,COUNTUP-LBTEST+LBLOAD		/POINTER TO COUNTUP ROUTINE
L375,	375				/CONSTANT 0375
PTSTBUF,TSTBUFFER-1			/POINTER TO TEST BUFFER
PKBTEND,KBTEND				/POINTER TO END OF KEYBOARD TEST

/	COMES HERE WHEN THE LOOPBACK TEST TIMES OUT.

LUPTIMO,NL0010 CLL			/INDICATE TIME-OUT ENDED THE TEST

/	COMES HERE WHEN THE COUNT PATTERN IS FINISHED TO (POSSIBLY) TEST THE KEYBOARD.

LUPDONE,TAD	ESTATUS			/GET TEST ERROR STATUS
	DCA	ESTATUS			/STORE (POSSIBLY) UPDATED VALUE
	VIDCON				/CLEAR VIDEO CONTROL
	APTSKP				/AUTOMATIC PRODUCT TESTING?
	SKP				/SKIP IF NOT
	JMP I	PKBTEND/(KBTEND)	/JUMP IF SO TO BYPASS TEST
	DCA	XR2			/CLEAR RECEIVED CHARACTER COUNT
	KBIRB				/READ BUFFER NOW TO RESET UART
	CLA				/CLEAN UP
	TAD	L375/[375]		/GET "JUMP TO POWER UP" VALUE
	KBOLS				/OUTPUT TO KEYBOARD
	KBOSF				/WAIT FOR IT
	JMP	.-1			/'TIL DONE
	KBOSF				/SKIP ON, THUS CLEARING THE FLAG
	40/NOP				/HERE IN CASE IT SKIPS (UNREFERENCED?)
	CLA				/CLEAN UP
	TAD	Z7766/[-12]		/SETUP THE
	DCA	CNTHI			/HIGH-ORDER COUNT
	DCA	CNTLO			/CLEAR LOW-ORDER COUNT
	TAD	PTSTBUFF/(TSTBUFFER-1)	/SETUP THE
	DCA	XR1			/BUFFER POINTER
KEYLUP,	KBISF				/FLAG UP?
	SKP				/SKIP IF NOT
	JMP	GOTKEY			/JUMP IF SO
	ISZ	CNTLO			/WAITING TOO LONG?
	JMP	KEYLUP			/NO, KEEP TRYING
	ISZ	CNTHI			/TOO MANY TIMES?
	JMP	KEYLUP			/NO, KEEP TRYING

/	NO (FURTHER) KEYBOARD INPUT.

	JMP	KBTIMOUT		/CONTINUE THERE
/	COMES HERE WHEN A KEYBOARD CHARACTER IS RECEIVED.

GOTKEY,	KBISF				/SKIP ON, THUS CLEARING THE FLAG
	NOP				/IN CASE IT SKIPS
	KBIRB				/GET THE CHARACTER
	AND	Z377/[377]		/JUST 8 BITS
	DCA I	XR1			/STORE INTO THE BUFFER
	ISZ	XR2			/BUMP CHARACTER COUNT
	JMP	KEYLUP			/KEEP GOING

/	COMES HERE WHEN KEYBOARD INPUT TIMES OUT.

KBTIMOU,TAD	L7774/(-4)		/GET EXPECTED COUNT
	TAD	XR2			/COMPARE TO ACTUAL
	SNA				/SKIP IF OTHER THAN EXPECTED
	TAD I	PTSTBEND/(TSTBEND)	/ELSE LOOK AT LAST CHARACTER RECEIVED
	SZA CLA				/SKIP IF LAST CHARACTER WAS A 
	TAD	Z20/[20]		/ELSE ADD ON KEYBOARD ERROR VALUE
	TAD	ESTATUS			/GET CUMULATIVE STATUS
	DCA	ESTATUS			/STORE BACK
KBTEND,	JMP I	.+1/(COMTEST)		/CONTINUE THERE
	COMTEST				/THROUGH HERE

PTSTBEN,TSTBEND-1			/POINTER TO END OF TEST KEYBOARD BUFFER
L7774,	7774				/CONSTANT 7774
L342,	342				/CONSTANT 0342
L320,	320				/CONSTANT 0320
A7740,	7740				/CONSTANT 7740
PAPTSTR,APTSTRT				/STARTING ADDRESS FOR DOWNLOAD
/	DIRECT DOWN-LOAD ROUTINE.  CALLED VIA JMS I .+1;DOWNLOAD IF APTEN IS SET.  THE
/	FORMAT IS STANDARD PAPER-TAPE RIM FORMAT WITHOUT A LEADER.  LOADING IS TO MAIN
/	MEMORY FIELD 7.  THE  ROUTINE  IS  ALSO  CALLABLE  AFTER  A  PREVIOUSLY LOADED
/	PROGRAM EXITS VIA A PANEL REQUEST INSTEAD OF A HLT INSTRUCTION.  THIS CAUSES A
/	TOTAL RESTART OF ALL CODE INITIALLY MOVED FROM THE ROM TO CP FIELD 7.  IN THIS
/	SITUATION,  CODE  LOADED  INTO MAIN MEMORY 76000-77777 WILL  BE  MOVED  TO  CP
/	76000-7777  TO  BECOME  THE  NEXT  CP-INTERRUPT HANDLER, ETC.   EXIT  VIA  HLT
/	INSTRUCTION RETURNS TO A DESIGNATED ENTRY POINT TO LOAD MORE CODE.

DOWNLOA,.-.				/DOWN-LOAD ROUTINE
	ISZ	DOWNLOAD		/BUMP PAST CALL POINTER
	CDF	70			/ENSURE OUR FIELD
	TAD	Z400/[400]		/SET POWER-ON MASK
	AND	PSTATUS			/GET POWER-ON BIT
	SNA CLA				/SKIP IF SET
	JMP	DWNAGN			/JUMP IF NOT
	DCA	CMSW			/INDICATE MOVABLE CODE NOT LOADED YET

/	THE CODE IS REJOINED HERE WHEN DOWN-LOADED CODE EXITS WITH A HLT INSTRUCTION.

DWNENTR,CDF	70			/GOTO MAIN MEMORY LOADING FIELD
	TAD	PBAUD			/GET BAUD RATE
	PRSB				/SETUP 9600 BAUD RATE
	CLA				/CLEAN UP
	PRISKP				/SKIP ON, THUS CLEARING INPUT FLAG
PBAUD,	16				/RATE VALUE FOR 9600 BAUD; ALSO SKIP PROTECT
	TAD	L342/(342)		/GET CHARACTER CODE
	PROLS				/OUTPUT IT
	PRIRB				/READ KEYBOARD BUFFER NOW FOR CHARACTERS LATER
	CPD				/MAIN MEMORY INDIRECTS FROM NOW ON
RIMLUP,	PRISKP				/FLAG UP
	JMP	RIMLUP			/NO, WAIT FOR IT
	PRISKP				/YES, MAKE SURE IT CLEARS
	NOP				/IN CASE IT SKIPS AGAIN
	PRIRB				/READ IN THE CHARACTER
	CLL RTL;RTL			/MOVE UP
	SPA				/SKIP IF NOT AT TRAILER
	JMP	RIMEND			/JUMP IF DONE
	RTL				/MOVE UP TO HIGH-ORDER
	PRISKP				/WAIT FOR
	JMP	.-1			/NEXT CHARACTER
	PRISKP				/MAKE SURE IT CLEARS
	NOP				/IN CASE IT SKIPS AGAIN
	PRIRS				/OR IN LATEST CHARACTER
	SNL				/SKIP IF ORIGIN SETTING
	DCA I	RIMADR			/STORE THE DATA
	DCA	RIMADR			/STORE AS NEW ORIGIN
	JMP	RIMLUP			/KEEP GOING
/	COMES HERE AT THE END OF THE RIM LOADING.

RIMEND,	CLA				/CLEAN UP
	TAD	L320/(320)		/GET THIS VALUE
	DCA I	A7740/(7740)		/SOMEONE NEEDS THIS THERE
	SPD				/CP MEMORY INDIRECTS
	DCA	XR0			/CLEAR INDEX (WHY?)
	CDF	00			/GOING TO FIELD 0
	TAD	PCPIHND/(CPIHND)	/GET INTERRUPT HANDLER ADDRESS
	DCA I	CPIADDR/[ROMSP]		/STORE IN INTERRUPT POINTER
	TAD	JMPIPM/(ROMSP&177+JMPIC)/GET JMP I .-1
	DCA I	PROMST/[ROMST]		/STORE IN RESTART ADDRESS
	NL7777				/BACKUP
	TAD	PCPIHND/(CPIHND)	/NOW HAVE AUTO-INCREMENT LOADING ADDRESS
	DCA	XR0			/STASH THE POINTER
	TAD	XR0			/GET IT AGAIN
	DCA	XR1			/STASH FOR MOVING ALSO
	CDF	70			/GOTO OUR FIELD
RCPLUP,	TAD I	XR0			/GET A WORD
	SNA				/END OF LIST?
	JMP	RIMST			/JUMP IF SO
	CDF	00			/GOTO FIELD 0
	DCA I	XR1			/PUT A WORD
	CDF	70			/BACK TO OUR FIELD
	JMP	RCPLUP			/KEEP GOING

RIMST,	CIF CDF 70			/GOING TO FIELD 7
	PEX				/LEAVING PANEL MEMORY
	JMP I	PAPTSTRT/(APTSTRT)	/GO THERE

/	COMES  HERE  IF  A PREVIOUSLY LOADED ROUTINE EXITED VIA A PANEL REQUEST  WHICH
/	CAUSES A TOTAL RESTART OF THE FORMERLY ROM-BASED CODE MOVED TO FIELD 7.   CODE
/	LOADED INTO MAIN MEMORY 76000-77777 SHOULD BE MOVED TO CP 76000-77777.

DWNAGN,	TAD	CMSW			/GET LOAD SWITCH
	SZA CLA				/SKIP IF NOT LOADED YET
	JMP I	DOWNLOAD		/RETURN TO CALLER
	NL7777				/INDICATE CODE MOVED
	DCA	CMSW			/FOR NEXT TIME
	TAD	PAPTSTRT/(APTSTRT)	/GET STARTING ADDRESS
	DCA	RIMADR			/STASH THE POINTER
MCLUP,	CPD				/MAIN MEMORY INDIRECTS
	TAD I	RIMADR			/GET A WORD
	SPD				/CP MEMORY INDIRECTS
	DCA I	RIMADR			/PUT A WORD
	ISZ	RIMADR			/BUMP TO NEXT
	JMP	MCLUP			/KEEP GOING
	JMP I	DOWNLOAD		/RETURN TO CALLER
CMSW,	.-.				/CODE MOVED SWITCH
JMPIPM,	ROMSP&177+JMPIC			/JMP I .-1 CONSTANT FOR RESTART ADDRESS
PCPIHND,CPIHND				/CP-INTERRUPT HANDLING ADDRESS

/	VALIDATION PATTERN FOR TRACK ZERO, SECTOR 4 DATA.

T0S4DAT,-1
	-"H!200
	-"L!200
	-"T!200
	-"F!200
	-"L!200
	-"G!200
	-2
	0				/THIS ENDS THE LIST

/	DATA PATTERN USED TO TEST RX50 SILO BUFFER.

TPATTRN,000
	252
	125
	063
	017
	377

	ZBLOCK	1			/EMPTY SPACE

DINDEX,	.-.				/TEST DATA INDEX
DCNT,	.-.				/TEST DATA COUNTER
DPTR,	.-.				/TEST DATA POINTER
M5,	-5				/CONSTANT 7773
M1000,	-1000				/CONSTANT 7000
PTPATTR,TPATTRN				/POINTER TO SILO TEST DATA
PRDTWAI,RDTWAIT				/POINTER TO RDTWAIT ROUTINE
/	COMES HERE AFTER DEALING WITH THE COMMUNICATIONS PORT.

COMDONE,JMS I	PRDTWAIT/(RDTWAIT)	/TIME OUT RD51 (IF PRESENT)
	LCD				/SEND A FILL BUFFER COMMAND
	CAF				/CLEAN UP; SELF-TEST SHOULD RAISE THE FLAG
	NL7777				/SETUP AN
	DCA	XR0			/INDEX REGISTER (EXTRANEOUS?)
	TAD	DTIMOUT/[-DTIME]	/SETUP THE
	DCA	T6			/TIME-OUT COUNTER
	DCA	T7			/CLEAR INNER TIME-OUT COUNTER
DONWAIT,SDN				/DONE FLAG UP?
	JMP	NOTDONE			/NO, GO THERE TO WAIT
	SER				/YES, ANY ERRORS?
	JMP	DONEOK			/NO, CONTINUE THERE
	JMP	RXERROR			/GO THERE BECAUSE OF ERRORS

NOTDONE,ISZ	T7			/WAITED ENOUGH?
	JMP	DONWAIT			/NO, KEEP GOING
	ISZ	T6			/WAITING TOO LONG?
	JMP	DONWAIT			/NO, KEEP GOING
	JMP	RXERROR			/GO THERE BECAUSE IT TIMED OUT

DONEOK,	APTSKP				/AUTOMATIC PRODUCT TESTING?
	SKP				/SKIP IF NOT
	JMS I	PAPTROUTINE/[APTROUTINE]/CALL ROUTINE IF SO
	CLA CLL				/CLEAN UP
	DCA	DINDEX			/CLEAR DATA INDEX
	DCA	DCNT			/CLEAR DATA COUNTER
	NL0100 CLL			/GET FILL BUFFER COMMAND (8-BIT) VALUE
	LCD				/LOAD THE COMMAND
	JMS	RXWAIT			/CALL WAIT ROUTINE
	JMP	CMNDOK			/TRANSFER FLAG UP
	JMP	RXERROR			/DONE FLAG UP, ERROR
	JMP	RXERROR			/ERROR OR TIME-OUT

CMNDOK,	XDR				/FINISH THE COMMAND
FILLUP,	JMS	RXWAIT			/CALL WAIT ROUTINE
	JMP	TRNSUP			/TRANSFER FLAG UP
	JMP	DONEUP			/DONE FLAG CAME UP, SO FINISH THERE
	JMP	RXERROR			/ERROR OR TIME-OUT

TRNSUP,	TAD	DINDEX			/GET DATA INDEX
	TAD	PTPATTRN/(TPATTRN)	/POINT TO PROPER ELEMENT IN LIST
	DCA	DPTR			/STASH THE POINTER
	TAD I	DPTR			/GET THE DATA VALUE
	XDR				/SEND TO SILO
	CLA				/CLEAN UP
	ISZ	DCNT			/BUMP DATA COUNTER
	ISZ	DINDEX			/BUMP DATA INDEX
	TAD	DINDEX			/GET DATA INDEX
	TAD	M5/(-5)			/COMPARE TO LARGEST VALUE
	SMA SZA CLA			/SKIP IF NOT PAST
	DCA	DINDEX			/ELSE RESET DATA INDEX
	JMP	FILLUP			/KEEP GOING
/	DONE FLAG IS UP; CHECK IF PROPER BYTE COUNT.

DONEUP,	TAD	DCNT			/GET DATA COUNTER
	TAD	M1000/(-1000)		/COMPARE TO EXPECTED VALUE
	SZA CLA				/SKIP IF IT MATCHES
	JMP	RXERROR			/ELSE COMPLAIN
	CLA CLL				/CLEAN UP
	DCA	DINDEX			/CLEAR DATA INDEX
	DCA	DCNT			/CLEAR DATA COUNTER
	TAD	Z102/[102]		/GET EMPTY BUFFER COMMAND (8-BIT) VALUE
	LCD				/LOAD THE COMMAND
	JMS	RXWAIT			/CALL WAIT ROUTINE
	JMP	CMDOK			/TRANSFER FLAG CAME UP
	JMP	RXERROR			/DONE FLAG CAME UP, COMPLAIN
	JMP	RXERROR			/ERROR OR TIME-OUT

CMDOK,	CLA				/CLEAN UP
	XDR				/FINISH THE COMMAND
EMPTLUP,JMS	RXWAIT			/CALL WAIT ROUTINE
	SKP				/TRANSFER FLAG CAME UP
	JMP	DONUP			/DONE FLAG CAME UP

/	OOPS! FORGOT THE "JMP RXERROR" IF IT GETS AN ERROR OR TIMES OUT.

	TAD	DINDEX			/GET DATA INDEX
	TAD	PTPATTRN/(TPATTRN)	/POINT TO PROPER ELEMENT IN LIST
	DCA	DPTR			/STASH THE POINTER
	TAD I	DPTR			/GET THE DATA
	DCA	DPTR			/SAVE IT
	XDR				/GET THE BYTE
	CIA				/INVERT FOR TESTING
	TAD	DPTR			/COMPARE TO TEST VALUE
	SZA CLA				/SKIP IF IT MATCHES
	JMP	RXERROR			/ELSE COMPLAIN
	ISZ	DCNT			/BUMP DATA COUNTER
	ISZ	DINDEX			/BUMP DATA INDEX
	TAD	DINDEX			/GET DATA INDEX
	TAD	M5/(-5)			/COMPARE TO LARGEST VALUE
	SMA SZA CLA			/SKIP IF NOT TOO FAR
	DCA	DINDEX			/ELSE RESET DATA INDEX
	JMP	EMPTLUP			/KEEP GOING

/	DONE FLAG IS UP; CHECK IF PROPER BYTE COUNT.

DONUP,	TAD	DCNT			/GET DATA COUNTER
	TAD	M1000/(-1000)		/COMPARE TO EXPECTED VALUE
	SZA CLA				/SKIP IF IT MATCHES
	JMP	RXERROR			/ELSE COMPLAIN
	JMP I	.+1/(RXOK)		/CONTINUE THERE
	RXOK				/THROUGH HERE
/	RX50 WAIT ROUTINE.  TAKES  IMMEDIATE  RETURN  IF  TRANSFER FLAG RAISES.  TAKES
/	SKIP RETURN IF DONE FLAG RAISES.   TAKES DOUBLE-SKIP RETURN IF AN ERROR OCCURS
/	OR THE HARDWARE TIMES OUT.

RXWAIT,	.-.
	TAD	DTIMOUT/[-DTIME]	/SETUP THE
	DCA	T6			/TIME-OUT COUNTER
	DCA	T7			/CLEAR INNER TIME-OUT COUNTER
RXWATLP,STR				/TRANSFER FLAG UP?
	SKP				/SKIP IF NOT
	JMP I	RXWAIT			/YES, TAKE IMMEDIATE RETURN
	SDN				/DONE FLAG UP?
	JMP	RXWATING		/NO, KEEP TRYING
	SER				/YES, WERE THERE ERRORS?
	JMP	RXSKIP			/NO, TAKE SKIP RETURN
	JMP	RXSKP2			/YES, TAKE DOUBLE SKIP RETURN

RXWATIN,ISZ	T7			/WAITING TOO LONG?
	JMP	RXWATLP			/NO, KEEP TRYING
	ISZ	T6			/WAITED TOO LONG?
	JMP	RXWATLP			/NO, KEEP TRYING
RXSKP2,	ISZ	RXWAIT			/YES, TAKE DOUBLE-SKIP RETURN
RXSKIP,	ISZ	RXWAIT			/SET SKIP RETURN FOR DONE FLAG UP CONDITION
	JMP I	RXWAIT			/RETURN AS NECESSARY

M100,	-100				/CONSTANT 7700

TIMOUT,	.-.				/GENERAL TIME-OUT ROUTINE
	DCA	T6			/CLEAR INNER COUNTER
	TAD	M100/(-100)		/SETUP THE
	DCA	T7			/OUTER COUNTER
TIMLUP,	ISZ	T6			/WAITING LONG ENOUGH?
	JMP	TIMLUP			/NO, KEEP GOING
	ISZ	T7			/WAITED TOO LONG?
	JMP	TIMLUP			/NO, KEEP GOING
	JMP I	TIMOUT			/YES, RETURN TO CALLER

L40,	40				/CONSTANT 0040

RXERROR,TAD	L40/(40)		/GET RX50 ERROR VALUE
	TAD	ESTATUS			/UPDATE CUMULATIVE ERROR STATUS
	DCA	ESTATUS			/STORE BACK
RXOK,	NL0010 CLL			/SET CRT VALUE
	VIDCON				/LOAD ECHRMOD
	CLA				/CLEAN UP
	JMS I	PENDUP/(ENDUP)		/FINISH UP SCREEN DISPLAY (POSSIBLY ERRORS)
	JMS I	PRDSETUP/(RDSETUP)	/GET RD STARTUP CODE READ IN (IF PRESENT)
	JMS I	PRXRDY/(RXRDY)		/WAIT UNTIL DRIVE ZERO IS READY
	JMP	.-1			/WAIT FOR IT TO BE READY INDEFINITELY
	JMS I	PCLR23/[CLR23]		/CLEAR FIELDS 2, 3 (AND BITS IN 13705, 13707)
RTRK1,	NL7777				/SETUP THE
	DCA	XR0			/STORAGE POINTER
	CDF	00			/STORING IN FIELD 0
	TAD	Z102/[102]		/GET EMPTY SILO (8-BIT) COMMAND
	DCA	RXCMD			/STASH IT
/	CLA				/CALL WITH AC CLEAR (1-1)
	JMS	FREAD			/CALL FLOPPY READ ROUTINE
	-1-1				/ONE SECTOR
	1				/ON TRACK 1
	JMP	RTRK1			/ERROR, TRY AGAIN
	JMS I	PVALID8/(VALID8)	/VALIDATE THE PREFERENCE SETTINGS
	JMP	FLPBAD			/FLOPPY IS BAD, GO COMPLAIN
SLSHAGN,JMS	RXLOAD			/LOAD IN VARIOUS SLUSHWARE ITEMS
	JMP	SLSHBAD			/COULDN'T DO IT
	JMS I	PCLR23/[CLR23]		/CLEAR FIELDS 2, 3 (AND BITS IN 13705, 13707)
	CLA				/CLEAN UP
	CIF CDF	00			/GOING TO FIELD 0
	JMP I	Z200/[200]		/GO START IT UP

PVALID8,VALID8				/POINTER TO VALIDATION ROUTINE
PFBLINK,FBLINK				/POINTER TO FBLINK ROUTINE
PRXRDY,	RXRDY				/POINTER TO RX50 READY CHECK ROUTINE
PRDSETU,RDSETUP				/POINTER TO RD51 SETUP ROUTINE

/	COMES HERE  TO  DISPLAY  A BLINKING BIG FLOPPY PATTERN IF THE CURRENT DISKETTE
/	HAS AN INVALID BOOT BLOCK IN TRACK 1, SECTOR 1.

FLPBAD,	JMS I	PFBLINK/(FBLINK)	/GO DISPLAY THE PATTERN ONCE
	JMP	RTRK1			/TRY AGAIN

/	COMES HERE TO  DISPLAY  THE BIG FLOPPY PATTERN IF THE SLUSHWARE STUFF CAN'T BE
/	COMPLETELY READ IN.

SLSHBAD,JMS I	PFBLINK/(FBLINK)	/GO DISPLAY THE PATTERN ONCE
	JMP	SLSHAGN			/TRY AGAIN

PRXWAIT,RXWAIT				/POINTER TO RX50 WAIT ROUTINE
PENDUP,	ENDUP				/POINTER TO ENDUP ROUTINE
RXLOAD,	.-.				/MULTIPLE RX50 LOADING ROUTINE
	NL7777				/SETUP THE
	DCA	XR0			/STORAGE POINTER
	TAD	Z102/[102]		/SETUP THE
	DCA	RXCMD			/EMPTY BUFFER COMMAND (8-BIT)
	JMS I	PT0S3RD/(T0S3RD)	/READ AND VALIDATE TRACK 0, SECTOR 3
	JMP I	RXLOAD			/COULDN'T DO IT, TAKE FAILURE RETURN
	JMS I	PDOCG/(DOCG)		/READ AND LOAD CHARACTER GENERATOR RAM DATA
	NL002A				/SETUP 12-BIT EMPTY SILO COMMAND VALUE
	DCA	RXCMD			/STASH THE COMMAND
	NL7777				/SETUP THE
	DCA	XR0			/DATA POINTER
	CDF	00			/SETUP THE DATA FIELD
/	CLA				/CALL WITH AC CLEAR (1-1)
	JMS	FREAD			/CALL FLOPPY READ ROUTINE
	-12-1				/READ 10 SECTORS (1-10)
	116				/TRACK 78
	JMP I	RXLOAD			/COULDN'T DO IT, TAKE FAILURE RETURN
	CDF	00			/SETUP THE DATA FIELD
/	CLA				/CALL WITH AC CLEAR (1-1)
	JMS	FREAD			/CALL FLOPPY READ ROUTINE
	-6-1				/READ 6 SECTORS (1-6)
	117				/TRACK 79
	JMP I	RXLOAD			/COULDN'T DO IT, TAKE FAILURE RETURN
	CDF	10			/SETUP THE DATA FIELD
	NL0006				/SETUP FOR SECTOR 7 FIRST
	JMS	FREAD			/CALL FLOPPY READ ROUTINE
	-12-1				/READ 4 SECTORS (7-10)
	117				/TRACK 79
	JMP I	RXLOAD			/COULDN'T DO IT, TAKE FAILURE RETURN
	CDF	00			/BACK TO PRIMARY CODE FIELD
	DCA	XR0			/CLEAR THE POINTER
	JMS I	PSLCHECK/(SLCHECK)	/GO VALIDATE THE DATA
	JMP I	RXLOAD			/BAD DATA, TAKE FAILURE RETURN
	ISZ	RXLOAD			/GOOD DATA, BUMP RETURN ADDRESS
	JMP I	RXLOAD			/TAKE SKIP RETURN TO CALLER

PSLCHEC,SLCHECK				/POINTER TO SLUSHWARE VALIDATION ROUTINE
PT0S3RD,T0S3RD				/POINTER TO TRACK 0, SECTOR 3 READ ROUTINE
PDOCG,	DOCG				/POINTER TO DOCG ROUTINE
/	RX50 READ ROUTINE.  CALL WITH AC CONTAINING RELATIVE OFFSET  ON  THE  TRACK OF
/	FIRST  SECTOR TO TRANSFER.  THIS IS ONE LESS THAN THE  ACTUAL  SECTOR  NUMBER.
/	THE FIRST IN-LINE ARGUMENT IS THE LIMIT ON THE SECTOR COUNT, I.E.,  THE  TWO'S
/	COMPLEMENT  OF  THE  SECTOR  VALUE  ONE HIGHER THAN DESIRED AS THE LAST SECTOR
/	TRANSFERRED.  THE DATA IS TRANSFERRED INTO THE  SAME FIELD AS THE CURRENT DATA
/	FIELD.  XR0 SHOULD BE SET TO THE DATA STORAGE ADDRESS -1.  RXCMD SHOULD BE SET
/	TO A SILO EMPTY COMMAND, EITHER 8-BIT OR 12-BIT AS REQUIRED.  THE COMMAND WILL
/	BE ISSUED CORRECTLY EITHER WAY.  CONTROL IS RETURNED TO JUST  PAST  THE SECOND
/	ARGUMENT IF THERE IS AN ERROR.  AN EXTRA SKIP RETURN IS  PERFORMED IF THE READ
/	WAS OK.

FREAD,	.-.				/FLOPPY READ ROUTINE
	DCA	TINC			/SAVE PASSED VALUE (SECTOR OFFSET ON TRACK)
	RDF				/GET CALLING FIELD
	TAD	ZCDF/[CDF]		/FORM CDF CALLING FIELD
	DCA	TRNCDF			/STORE IN-LINE
	CDF	70			/BACK TO OUR FIELD
	TAD I	FREAD			/GET FIRST ARGUMENT (COUNT LIMIT)
	DCA	T0			/STASH IT
	ISZ	FREAD			/BUMP TO NEXT
	TAD I	FREAD			/GET SECOND ARGUMENT (TRACK)
	DCA	T1			/STASH IT
	ISZ	FREAD			/BUMP PAST ARGUMENT
FNXTSCT,CDF	70			/BACK TO OUR FIELD
	ISZ	TINC			/BUMP SECTOR OFFSET TO LATEST SECTOR
	TAD	TINC			/GET THE LATEST OFFSET
	TAD	T0			/COMPARE TO COUNT LIMIT
	SPA CLA				/SKIP IF FINISHED
	JMP	FNEXT			/ELSE KEEP GOING
	ISZ	FREAD			/BUMP RETURN ADDRESS
	JMP I	FREAD			/TAKE SUCCESSFUL RETURN

FNEXT,	NL0006				/GET READ FUNCTION VALUE
	JMS I	PRXCOMD/[RXCOMD]	/CALL READ COMMAND ROUTINE
	SKP				/SKIP IF COMMAND FINISHED
	JMP I	FREAD			/ELSE TAKE FAILURE RETURN
	SER				/ANY ERRORS?
	JMP	FRDOK			/JUMP IF NOT
FERR,	JMS I	PSSTRING/[SSTRING]	/STORE PATTERN FOR BIG FLOPPY
	BIGFLPY				/SCREEN DATA POINTER
	JMP I	FREAD			/TAKE FAILURE RETURN

FRDOK,	TAD	RXCMD			/GET SILO EMPTY COMMAND
	LCD				/LOAD THE COMMAND
	NL0100 CLL			/SET THE 8-BIT MASK
	AND	RXCMD			/ISOLATE THE BIT
	SNA CLA				/SKIP IF SET
	JMP	TRNCDF			/JUMP IF NOT
	JMS I	PRXWAIT/(RXWAIT)	/CALL FLAG WAIT ROUTINE
	JMP	COMFINISH		/TRANSFER FLAG UP AS EXPECTED
	JMP	FERR			/DONE FLAG CAME UP, ERROR
	JMP	FERR			/TIME-OUT, ERROR
COMFINI,XDR				/FINISH THE COMMAND
TRNCDF,	HLT+.-.				/WILL BE CDF XX INSTRUCTION TO BUFFER FIELD
	CLA				/CLEAN UP
FRDLUP,	STR				/TRANSFER FLAG UP?
	JMP	TRYDONE			/NO, TRY DONE FLAG
	XDR				/YES, GET THE LATEST
	DCA I	XR0			/STORE IT
TRYDONE,SDN				/DONE FLAG UP?
	JMP	FRDLUP			/NO, TRY TRANSFER
	SER				/YES, ANY ERRORS?
	JMP	FNXTSCT			/NO, GO DO NEXT SECTOR
	JMP	FERR			/YES, GO COMPLAIN

	ZBLOCK	4			/EMPTY SPACE
	PAGE

/	AUTO-INDEXED POINTER TO PIE CHIP PROGRAMMING TABLE (TABLE FOLLOWS).

PPTABLE,PTABLE-1			/POINTER TO PROGRAMMING TABLE.

/	PROGRAMMING  NOTE:   BY PLACING THIS POINTER HERE,  AN  EXTRANEOUS  PAGE  ZERO
/	REFERENCE TO THE POINTER IS REQUIRED, INSTEAD OF MERELY A POINTER TO THE TABLE
/	ON PAGE ZERO ITSELF.

/	PIE CHIP PROGRAMMING TABLE.

	PTABLE=	.			/PROGRAMMING TABLE HERE

/	FIRST CHIP.

	KEY^10+1004			/DEVICE 03
	TTY^10+1004			/DEVICE 04
	CLKCON^10+3000			/DEVICE 13
	PRICON^10+3002			/DEVICE 32
	PROCON^10+3007			/DEVICE 33

/	SECOND CHIP.

	PORTIN^10+1002			/DEVICE 30
	PORTOUT^10+1003			/DEVICE 31
	PORTCON^10+3004			/DEVICE 36
	RXCON^10+0004			/DEVICE 75
	APUCON^10+1004			/DEVICE 14

/	THIRD CHIP (CP INTERRUPTS ONLY).

	TTYCON^10+1000			/DEVICE 07
	VIDINT^10+3000			/DEVICE 06
	KBOCON^10+7003			/DEVICE 05
	KBICON^10+7002			/DEVICE 11
	VIDDEV^10+4004			/DEVICE 12

	0				/THIS ENDS THE LIST
/	MEMORY COMPARE ROUTINE.

/	THIS  ROUTINE  CHECKS IF THE CURRENT TEST FIELD MATCHES THE  TEST  PATTERN  IN
/	EVERY WORD.  ALL MATCHING WORDS ARE INVERTED FOR THE NEXT TEST.  THE IMMEDIATE
/	RETURN IS TAKEN ON A MATCH FAILURE; SKIP RETURN IS TAKEN IF ALL WORDS MATCH.

MEMCOMP,.-.				/MEMORY COMPARE ROUTINE
	TAD	T2			/GET LATEST FIELD
	AND	Z7/[7]			/JUST FIELD BITS
	R3L				/MOVE UP
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
MCHKLP,	TAD I	T1			/GET A WORD
	TAD	T0			/COMPARE TO TEST VALUE
	IAC				/SHOULD BE ZERO
	SZA CLA				/SKIP IF IT MATCHES
	JMP I	MEMCOMPARE		/TAKE IMMEDIATE RETURN IF IT FAILS
	TAD	T0			/GET INVERTED TEST VALUE
	DCA I	T1			/STORE BACK
	TAD	T1			/GET ADDRESS
	TAD	TINC			/BUMP UP
	DCA	T1			/STORE BACK
	ISZ	XR0			/DONE ALL IN THIS FIELD
	JMP	MCHKLP			/NO, GO BACK FOR MORE
	ISZ	MEMCOMPARE		/YES, BUMP RETURN ADDRESS
	JMP I	MEMCOMPARE		/TAKE SKIP RETURN TO CALLER

PROWTAB,ROWTABLE-1			/POINTER TO HIGH-ORDER ROW TABLE
PREGLIS,REGLIST-1			/POINTER TO REGISTER AND CONTENTS LIST
PROWADR,ROWADR-1			/POINTER TO ROWTABLE ADDRESS

ROWLOAD,.-.  				/ROUTINE TO LOAD ROWTABLE AND VIDEO REGISTERS
	CLA CLL				/CLEAN UP
	VIDCON				/CLEAR SCREEN CONTROL REGISTER
	CDF	70			/ENSURE OUR FIELD
	TAD	PROWADR/(ROWADR-1)	/GET ROWTABLE TABLE POINTER
	DCA	XR0			/STASH THE POINTER
	TAD	PROWTABLE/(ROWTABLE-1)	/GET HIGH-ORDER ROW ADDRESS TABLE VALUE
	DCA	XR1			/STASH THE POINTER
ROWLUP,	TAD I	XR1			/GET A LIST ELEMENT
	SPA				/SKIP IF NOT AT END OF LIST
	JMP	FHERE			/JUMP IF AT END OF LIST
	MQL				/STASH IT FOR NOW
	CDF	10			/GOTO TABLE FIELD
	TAD	Z205/[205]		/GET LOW-ORDER BITS VALUE
	DCA I	XR0			/STASH IN TABLE
	CLA MQA				/GET HIGH-ORDER AND ATTRIBUTES
	DCA I	XR0			/STASH IN TABLE
	CDF	70			/BACK TO OUR FIELD
	JMP	ROWLUP			/KEEP GOING
FHERE,	CLA CLL				/CLEAN UP
	TAD	PREGLIST/(REGLIST-1)	/POINT TO
	DCA	XR0			/REGISTER LIST
REGLUP,	CDF	70			/BACK TO OUR FIELD
	TAD I	XR0			/GET A LIST ITEM
	SPA				/SKIP IF NOT END OF LIST
	JMP	REGDONE			/JUMP IF DONE
	LSCREG				/LOAD REGISTER SELECT
	CLA				/CLEAN UP
	TAD I	XR0			/GET THE VALUE
	VLOAD				/LOAD THE REGISTER WITH DESIRED VALUE
	CLA CLL				/CLEAN UP
	JMP	REGLUP			/KEEP GOING

REGDONE,CLA CLL				/CLEAN UP
	JMP I	ROWLOAD			/RETURN

/	ROUTINE TO CLEAR CP FIELD 2  AND  3;   ALSO CLEARS HIGH-ORDER HALF OF CP 13705
/	AND 13707 TO MAKE THOSE LINES HAVE NORMAL ATTRIBUTES.

CLR23,	.-.				/CLEAR FIELD 2, FIELD 3 ROUTINE
	CLA				/CLEAN UP
	DCA	T2			/CLEAR EVEN/ODD FIELD FLAG
ZERNXT,	NL7777				/SETUP FOR STORING
	DCA	XR0			/INTO LOCATION 0000 OF THE LATEST FIELD
	JMS	CDFSETUP		/SETUP PROPER FIELD
	TAD	Z7760/[-20]		/SETUP THE
	DCA	T3			/BUFFER COUNT
BUFLUP,	TAD	Z7400/[-400]		/SETUP FOR TWO PAGES WORTH
	DCA	T4			/IN EACH BUFFER
ZERLUP,	DCA I	XR0			/CLEAR A WORD
	ISZ	T4			/DONE YET?
	JMP	ZERLUP			/NO, GO BACK
	ISZ	T3			/DONE ENOUGH BUFFERS?
	JMP	BUFLUP			/NO, GO BACK
	TAD	T2			/GET FLAG
	SZA CLA				/SKIP IF ZERO
	JMP	CLRFINISH		/ELSE FINISH THERE
	NL7777				/SET THE FLAG
	DCA	T2			/FOR NEXT FIELD
	JMP	ZERNXT			/GO DO IT AGAIN

CDFSETU,.-.				/CDF SETTING ROUTINE
	TAD	T2			/GET THE FLAG
	SZA CLA				/SKIP IF EVEN FIELD
	JMP	SETODD			/JUMP IF ODD
	CDF	20			/SETUP FOR FIELD 2
	JMP I	CDFSETUP		/RETURN

SETODD,	CDF	30			/SETUP FOR FIELD 3
	JMP I	CDFSETUP		/RETURN

CLRFINI,JMS I	PCLR2/(CLR2)		/CLEAR ATTRIBUTE BITS OF 13705 AND 13707
	JMP I	CLR23			/RETURN
PCLR2,	CLR2				/POINTER TO CLR2 ROUTINE
PTIMOUT,TIMOUT				/POINTER TO TIME-OUT ROUTINE

FBLINK,	.-.				/BIG FLOPPY DISPLAY ROUTINE
	NL0010 CLL			/SET EXTENDED CHARACTER MODE
	VIDCON				/LOAD NEW CONTROL VALUE
	CLA				/CLEAN UP
	TAD	BL40/(" &177)		/GET SPACE CODE
	JMS I	PSSTRING/[SSTRING]	/CLEAR ALL ITEMS OF
	BIGFLPY				/THE BIG FLOPPY PATTERN
	JMS I	PTIMOUT/(TIMOUT)	/GO WAIT FOR AWHILE	
	JMS I	PSSTRING/[SSTRING]	/GO DISPLAY ALL ITEMS OF
	BIGFLPY				/THE BIG FLOPPY PATTERN
	JMS I	PTIMOUT/(TIMOUT)	/GO WAIT FOR AWHILE
	JMP I	FBLINK			/RETURN

BL40,	" &177				/CONSTANT 0040

	ZBLOCK	7			/EMPTY SPACE
	PAGE

/	ROUTINE TO  VALIDATE  THE  CONTENTS  OF  TRACK  ONE,  SECTOR ONE AS A BOOTABLE
/	FLOPPY.  THE FIRST FEW BYTES OF THIS SECTOR  HAVE  TO  BE  A  VALID PREFERENCE
/	SETTING BLOCK IN ORDER TO ALLOW FURTHER BOOTING.  NON-SKIP  RETURN IS TAKEN IF
/	THE BYTES ARE BAD, SKIP RETURN IF THEY ARE GOOD.

VALID8,	.-.				/TRACK ONE VALIDATION ROUTINE
	CDF	70			/RESET TO OUR FIELD (WHY?)
	NL7777				/SETUP POINTER TO 0000
	DCA	XR0			/STASH THE POINTER
	CDF	00			/GOTO THE DATA FIELD
	TAD I	XR0			/GET THE FIRST BYTE
	TAD I	XR0			/ADD TO THE SECOND BYTE
	CDF	70			/BACK TO OUR FIELD

/	THE  SUM SHOULD BE ZERO MEANING THE TWO WORDS ARE THE TWO'S COMPLEMENT OF EACH
/	OTHER (OR ARE BOTH ZERO).

	SZA CLA				/SKIP IF OK
	JMP I	VALID8			/TAKE BAD RETURN IF NOT
	CDF	00			/GOTO THE DATA FIELD

/	THE NEXT BYTE IS TREATED AS A POINTER FOR LATER.

	TAD I	XR0			/GET THE NEXT BYTE
	CLL RAL				/*2
	TAD	XR0			/ADD 2
	DCA	XR1			/STASH THE POINTER FOR LATER

/	THE NEXT BYTE HAS TO BE 001.

	NL7777				/GET -1
	TAD I	XR0			/ADD ON NEXT BYTE
	CDF 	70			/BACK TO OUR FIELD
	SZA CLA				/SKIP IF IT MATCHES
	JMP I	VALID8			/ELSE TAKE BAD RETURN
/	THE  REST  OF  THE TESTED BYTES ARE POINTED TO THE THIRD BYTE.  THE FOUR BYTES
/	SHOULD SUM  TO  377.   THE POINTER WAS INCREMENTED BY TWO INITIALLY, SO WE MAY
/	HAVE TO SUBTRACT TWO TO LOCATE THE PROPER FOUR BYTE SEQUENCE.

VALAGN,	DCA	XR2			/SET TO 0000 (OR 7776)
	NL7777				/BACKUP
	TAD	XR1			/ADD ON POINTER
	TAD	XR2			/ADD 0000 OR 7776
	DCA	XR0			/STASH THE POINTER
	CDF	00			/GOTO THE DATA FIELD
	TAD I	XR0			/\
	TAD I	XR0			/ \GET THE NEXT
	TAD I	XR0			/ /FOUR BYTES
	TAD I	XR0			//
	CDF	70			/BACK TO OUR FIELD
	IAC				/ADD ONE
	AND	Z377/[377]		/JUST LOW-ORDER BITS
	SZA CLA				/SKIP IF ALL TOGETHER IT'S ZERO
	JMP	VALALT			/JUMP IF NOT

/	HAVING LOCATED THE CORRECT FOUR BYTE SEQUENCE, CONFIRM THAT THE FIRST TWO HAVE
/	BIT[8] SET.

	NL7777				/BACKUP
	TAD	XR1			/ADD ON POINTER
	TAD	XR2			/ADD ON 0000 OR 7776
	DCA	XR0			/STASH THE POINTER
	CDF	00			/GOTO THE DATA FIELD
	NL0010 CLL			/SET THE BIT MASK
	AND I	XR0			/GET THE FIRST ONE'S BIT
	AND I	XR0			/AND THE SECOND ONE'S BIT
	CDF	70			/BACK TO OUR FIELD
	SZA CLA				/SKIP IF OFF
	ISZ	VALID8			/BUMP TO GOOD RETURN
	JMP I	VALID8			/RETURN EITHER WAY

VALALT,	TAD	XR2			/GET THE OFFSET
	SZA CLA				/SKIP IF ZERO
	JMP I	VALID8			/RETURN IF 7776 WAS ALSO UNSUCCESSFUL
	NL7776				/SET -2 VALUE
	JMP	VALAGN			/TRY IT AGAIN
/	THIS IS THE LIST OF VALUES USED WITH LSCREG AND VLOAD IN PAIRS.

REGLIST,26				/REGISTER 16
	000				/DUMMY VALUE (DO A RESET)
	00				/REGISTER 0
	144-1				/100 CHARACTERS PER HORIZONTAL PERIOD
	01				/REGISTER 1
	120-1				/80 CHARACTERS PER DATA ROW
	02				/REGISTER 2
	016				/14 IS HORIZONTAL DELAY
	03				/REGISTER 3
	007				/7 IS HORIZONTAL SYNC WIDTH
	04				/REGISTER 4
	003				/3 IS VERTICAL SYNC WIDTH
	05				/REGISTER 5
	025				/21 IS VERTICAL DELAY
	06				/REGISTER 6
	022				/PINS 00, CURSOR SKEW 2, BLANK SKEW 2
	07				/REGISTER 7
	30-1				/24 VISIBLE DATA ROWS PER FRAME
	10				/REGISTER 8
	051				/SCAN LINES/FRAME 1, SCAN LINES/DATA ROW 9
	11				/REGISTER 9
	011				/9 SCAN LINES PER FRAME
	12				/REGISTER A
	160				/DMA BURST DELAY 7, DMA BURST COUNT 0
	13				/REGISTER B
	010				/OPERATION MODE 4 ****
	0014				/REGISTER C
	ROWADR&377			/LOW-ORDER 8-BITS OF 13660
	0015				/REGISTER D
	ROWADR%400+0220			/CONTIGUOUS ROW TABLE AT 13660
	16				/REGISTER E
	000				/LOW-ORDER AUXILIARY ADDRESS REGISTER
	17				/REGISTER F
	000				/HIGH-ORDER AUXILIARY ADDRESS REGISTER
	20				/REGISTER 10
	077 				/SEQUENTIAL BREAK REGISTER DISABLE VALUE
	21				/REGISTER 11
	000 				/PAGE BLANK, SMOOTH SCROLL CAN START AT 000
	22				/REGISTER 12
	030				/DATA ROW END PAST LINE 23
	27				/REGISTER 17
	000				/NO SMOOTH SCROLL OFFSET
	30				/REGISTER 18
	000				/CURSOR APPEARS VERTICAL AT 000
	31				/REGISTER 19
	000				/CURSOR APPEARS HORIZONTALLY AT 000
	32				/REGISTER 1A
	100				/ENABLE VERTICAL RETRACE INTERRUPTS
	25				/REGISTER 15
	000				/ISSUE START COMMAND
	4000				/THIS ENDS THE LIST
/	THIS TABLE IS USED  TO LOAD THE HIGH-ORDER BYTES OF THE CONTIGUOUS ROW ADDRESS
/	TABLE.  THE FORMAT IS  TWO ATTRIBUTE BITS AND SIX ADDRESS BITS.  THE LOW-ORDER
/	ADDRESS BYTE IS ALWAYS 205.   THE  ATTRIBUTE  BITS  ARE:   00=NORMAL DATA ROW,
/	01=SINGLE  HEIGHT,  DOUBLE  WIDTH;  10=TOP OF  DOUBLE  HEIGHT,  DOUBLE  WIDTH;
/	11=BOTTOM OF DOUBLE HEIGHT, DOUBLE WIDTH.

ROWTABL,0141				/LINE 00 DATA STARTS AT 20605 (DOUBLE WIDTH)
	0042				/LINE 01 DATA STARTS AT 21205
	0043				/LINE 02 DATA STARTS AT 21605
	0044				/LINE 03 DATA STARTS AT 22205
	0045				/LINE 04 DATA STARTS AT 22605
	0046				/LINE 05 DATA STARTS AT 23205
	0047				/LINE 06 DATA STARTS AT 23605
	0050				/LINE 07 DATA STARTS AT 24205
	0051				/LINE 08 DATA STARTS AT 24605
	0052				/LINE 09 DATA STARTS AT 25205
	0053				/LINE 10 DATA STARTS AT 25605
	0054				/LINE 11 DATA STARTS AT 26205
	0055				/LINE 12 DATA STARTS AT 26605
	0056				/LINE 13 DATA STARTS AT 27205
	0057				/LINE 14 DATA STARTS AT 27605
	0072				/LINE 15 DATA STARTS AT 35205
	0061				/LINE 16 DATA STARTS AT 30605
	0062				/LINE 17 DATA STARTS AT 31205
	0063				/LINE 18 DATA STARTS AT 31605
	0064				/LINE 19 DATA STARTS AT 32205
	0065				/LINE 20 DATA STARTS AT 32605
	0066				/LINE 21 DATA STARTS AT 33205
	0067				/LINE 22 DATA STARTS AT 33605
	0070				/LINE 23 DATA STARTS AT 34205
	7777				/THIS ENDS THE LIST
	PAGE

/	STORE  DISPLAY  STRING  ROUTINE.    CALL WITH CLEAR AC TO  DISPLAY  VALUES  IN
/	ARGUMENT LIST OR WITH 0040 IN AC TO BLANK THE FIELD.    IN-LINE  ARGUMENT IS A
/	POINTER TO THE ARGUMENT LIST.  LIST FORMAT IS 0000 IF ITEMS  ARE  FOR FIELD 2,
/	OR  4000  IF  ITEMS ARE FOR FIELD 3.  RELATIVE STORAGE ADDRESS FOR  SUBSEQUENT
/	ITEMS  FOLLOWS  THE  0000  OR  4000.  ALL OTHER ITEMS ARE SEQUENTIAL VALUES TO
/	STORE INTO  THE  BUFFER  STARTING  AT  THE  GIVEN  ADDRESS.  ALL ADDRESSES ARE
/	RELATIVE TO THE ABSOLUTE  VALUE  0205,  NOT  THE  ACTUAL  ROW ADDRESS WHICH IS
/	ALWAYS SOME NUMBER OF WHOLE  PAGES  DIFFERENT.    ADDRESSES  NEAR THE END OF A
/	FIELD WILL NOT BE CORRECTED TO  THE  NEXT  FIELD.  THE ARGUMENT LIST ENDS WITH
/	7777.  CONTROL RETURNS PAST THE IN-LINE POINTER ARGUMENT.

SSTRING,.-.				/STORE STRING FOR DISPLAY ROUTINE
	CDF	70			/ENSURE OUR FIELD
	DCA	SPACSW			/SAVE PASSED VALUE
	NL7777				/BACKUP FOR AUTO-INDEX
	TAD I	SSTRING			/GET ARGUMENT ADDRESS
	ISZ	SSTRING			/BUMP PAST ARGUMENT
	DCA	XR7			/STASH THE POINTER
SSLUP,	TAD I	XR7			/GET A WORD
	MQL				/STASH IT FOR NOW
	CLA MQA				/GET IT BACK
	IAC				/ADD ONE FOR TEST
	SNA CLA				/SKIP IF NOT AT END OF LIST (7777)
	JMP I	SSTRING			/RETURN IF AT END
	CLA MQA				/GET THE VALUE AGAIN
	AND	Z3777/[3777]		/IGNORE HIGH-ORDER BIT FOR NOW
	SNA CLA				/SKIP IF SOMETHING SET
	JMP	SSADR			/JUMP IF NOT
	TAD	SPACSW			/GET PASSED ARGUMENT
	SNA				/SKIP IF IT WAS SET (A SPACE CHARACTER)
	CLA MQA				/USE PASSED VALUE
CDFINST,HLT+.-.				/WILL BE CDF XX INSTRUCTION
	DCA I	T5			/STORE IN BUFFER
	ISZ	T5			/BUMP TO NEXT
	NOP				/JUST IN CASE IT SKIPS
	CDF	70			/BACK TO OUR FIELD
	JMP	SSLUP			/KEEP GOING

 SSADR,	TAD I	XR7			/GET NEXT WORD AFTER FLAG WORD
	DCA	T5			/STASH AS ADDRESS
	CLA MQA				/GET THE WORD
	SPA CLA				/SKIP IF IT FLAG WORD IS ZERO
	TAD	Z10/[10]		/MAKE IT CDF 30
	TAD	CDF20/(CDF 20)		/GET CDF 20
	DCA	CDFINST			/STORE CDF 20 OR CDF 30 IN-LINE
	TAD	T5			/GET ADDRESS WORD
	TAD	Z205/[205]		/ADD OFFSET
	DCA	T5			/STORE BACK
	JMP	SSLUP			/KEEP GOING

CDF20,	CDF	20			/CONSTANT 6221
SPACSW,	.-.				/PASSED SPACE PARAMETER
/	DATA PATTERN THAT LOOKS LIKE A BIG FLOPPY (USED FOR ERROR DISPLAY).

BIGFLPY,0000				/FIELD 2
	1445				/ADDRESS
	0015
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0014
	0000				/FIELD 2
	2045				/ADDRESS
	0031
	0000				/FIELD 2
	2070				/ADDRESS
	0015
	0022
	0022
	0022
	0022
	0022
	0014
	0031
	0000				/FIELD 2
	2445				/ADDRESS
	0031
	0000				/FIELD 2
	2470				/ADDRESS
	0031
	0000				/FIELD 2
	2476				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	3045				/ADDRESS
	0031
	0000				/FIELD 2
	3070				/ADDRESS
	0031
	0000				/FIELD 2
	3076				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	3445				/ADDRESS
	0031
	0000				/FIELD 2
	3462				/ADDRESS
	4025
	0000				/FIELD 2
	3470				/ADDRESS
	0016
	0022
	0022
	0022
	0022
	0022
	0013
	0031
	0000				/FIELD 2
	4045				/ADDRESS
	0031
	0000				/FIELD 2
	4060				/ADDRESS
	4026
	4031
	0000				/FIELD 2
	4063				/ADDRESS
	4031
	4026
	0000				/FIELD 2
	4072				/ADDRESS
	0015
	0022
	0022
	0022
	0014
	0031
	0000				/FIELD 2
	4445				/ADDRESS
	0031
	0050
	" +200
	" +200
	" +200
	" +200
	" +200
	0051
	0000				/FIELD 2
	4460				/ADDRESS
	4027
	0000				/FIELD 2
	4464				/ADDRESS
	4027
	0000				/FIELD 2
	4472				/ADDRESS
	0031
	0000				/FIELD 2
	4476				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	5045				/ADDRESS
	0031
	0000				/FIELD 2
	5061				/ADDRESS
	4030
	4027
	4030
	0000				/FIELD 2
	5072				/ADDRESS
	0031
	0000				/FIELD 2
	5076				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	5445				/ADDRESS
	0031
	0000				/FIELD 2
	5460				/ADDRESS
	0007
	0000				/FIELD 2
	5472				/ADDRESS
	0031
	0000				/FIELD 2
	5476				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	6045				/ADDRESS
	0031
	0000				/FIELD 2
	6072				/ADDRESS
	0031
	0000				/FIELD 2
	6076				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	6445				/ADDRESS
	0031
	0000				/FIELD 2
	6472				/ADDRESS
	0031
	0000				/FIELD 2
	6476				/ADDRESS
	0031
	0031
	0000				/FIELD 2
	7045				/ADDRESS
	0031
	0000				/FIELD 2
	7070				/ADDRESS
	0015
	0014
	0016
	0022
	0022
	0022
	0013
	0031
	0000				/FIELD 2
	7445				/ADDRESS
	0016
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0022
	0013
	0016
	0022
	0022
	0022
	0022
	0022
	0013
	7777				/END OF LIST
/	ERROR NUMBER DISPLAY LIST.

EDISPLI,0000				/FIELD 2
	5422				/ADDRESS
	.-.				/HIGH-ORDER ERROR DIGIT
	.-.				/LOW-ORDER ERROR DIGIT
	0000				/FIELD 2
	6022				/ADDRESS
J00,	0040+.-.			/HIGH-ORDER ERROR DIGIT
J01,	0040+.-.			/LOW-ORDER ERROR DIGIT
	7777				/END OF LIST

/	NON-ERROR (DECMATE II LOGO) DISPLAY LIST.

DMLOGO,	0000				/FIELD 2
	5415				/ADDRESS
	" +200
	"D+200
	"E+200
	"C+200
	"M+240
	"A+240
	"T+240
	"E+240
	" +200
	"I+200
	"I+200
	" +200
	0000				/FIELD 2
	6015				/ADDRESS
	" +200
	"D+200
	"E+200
	"C+200
	"M+240
	"A+240
	"T+240
	"E+240
	" +200
	"I+200
	"I+200
	" +200
	7777				/END OF LIST

L23,	23				/CONSTANT 0023
L247,	247				/CONSTANT 0247
L202,	202				/CONSTANT 0202
L460,	"0+200				/CONSTANT 0460
ENDUP,	.-.				/FINISH UP ROUTINE
	CLA CLL				/CLEAN UP
	JMS I	PSET2/(SET2)		/SET ATTRIBUTE BITS IN 13705, 13707
	TAD	ESTATUS			/GET ERROR STATUS
	SNA CLA				/SKIP IF ANY PROBLEMS
	JMP	NOERRORS		/JUMP IF NONE
	DCA	XR0			/CLEAR QUOTIENT
	TAD	ESTATUS			/GET ERROR STATUS
	APTSKP				/AUTOMATIC PRODUCT TEST?
	SKP				/SKIP IF NOT
	JMP I	PAPT2/(APTRO2)		/ELSE GO THERE
SUBLUP,	TAD	Z7766/[7766]		/SUBTRACT 10
	SPA				/GONE TOO FAR?
	JMP	ADDFIX			/YES, GO THERE TO FIX UP
	ISZ	XR0			/NO, BUMP QUOTIENT
	JMP	SUBLUP			/KEEP GOING

ADDFIX,	TAD	Z12/[12]		/RESTORE VALUE
	TAD	L460/("0+200)		/MAKE IT ASCII WITH ATTRIBUTES SET
	DCA I	LOW1/(EDISPLIST+3)	/STORE IN BUFFER
	TAD I	LOW1/(EDISPLIST+3)	/GET IT BACK
	DCA I	LOW2/(EDISPLIST+7)	/STORE THERE ALSO
	TAD	XR0			/GET QUOTIENT
	TAD	L460/("0+200)		/MAKE IT ASCII WITH ATTRIBUTES SET
	DCA I	HIGH1/(EDISPLIST+2)	/STORE IN BUFFER
	TAD I	HIGH1/(EDISPLIST+2)	/GET IT BACK
	DCA I	HIGH2/(EDISPLIST+6)	/STORE THERE ALSO
	TAD	L23/(23)		/GET KEYBOARD CODE TO LIGHT LEDS
	KBOLS				/SEND IT TO KEYBOARD
	DCA	XR2			/CLEAR WAIT COUNTER
	ISZ	XR2			/WAITING LONG ENOUGH?
	JMP	.-1			/NO, KEEP GOING
	TAD	L202/(202)		/GET KEYBOARD CODE FOR LED PATTERN
	KBOLS				/SEND IT TO KEYBOARD
	CLA				/CLEAN UP
	JMS I	PSSTRING/[SSTRING]	/CALL STRING STORE FOR DISPLAY ROUTINE
	EDISPLIST			/ERROR DIGITS DISPLAY LIST POINTER
	KBISF				/KEYBOARD FLAG UP?
	JMP	.-1			/NO, WAIT FOR IT
	KBIRB				/YES, READ IN THE CHARACTER
	CLA				/THROW IT AWAY
	JMP I	ENDUP			/RETURN

/	COMES HERE IF NO ERRORS FOUND EARLIER.

NOERROR,APTSKP				/AUTOMATIC PRODUCT TESTING?
	JMP	NOTAPT			/JUMP IF NOT
	JMS I	PAPTROUTINE/[APTROUTINE]/CALL ROUTINE IF SO
	JMP I	.+1/(PRGDONE)		/GO THERE
	PRGDONE				/THROUGH HERE
NOTAPT,	TAD	L247/(247)		/GET KEYBOARD CODE FOR THE BEEPER
	KBOLS				/SEND IT
	CLA				/CLEAN UP
	JMS I	PSSTRING/[SSTRING]	/DISPLAY THE
	DMLOGO				/DECMATE II LOGO
	JMP I	ENDUP			/RETURN

PSET2,	SET2				/POINTER TO 2-WORD ATTRIBUTE BITS SET ROUTINE
LOW1,	EDISPLIST+3			/POINTER TO LOW-ORDER DIGIT STORAGE (1)
LOW2,	EDISPLIST+7			/POINTER TO LOW-ORDER DIGIT STORAGE (2)
HIGH1,	EDISPLIST+2			/POINTER TO HIGH-ORDER DIGIT STORAGE (1)
HIGH2,	EDISPLIST+6			/POINTER TO HIGH-ORDER DIGIT STORAGE (2)
PAPT2,	APTRO2				/POINTER TO APTROUTINE ERROR HANDLING ENTRY

/	CP-INTERRUPT HANDLER FOR DOWN-LOADED CODE.  THE  DOWNLOADED  CODE  EXITS VIA A
/	HLT INSTRUCTION OR PANEL REQUEST.  HLT ENDS  THE EXECUTION AND RETURNS CONTROL
/	TO OUR CODE; PANEL REQUEST CAUSES A TOTAL RESTART OF ALL MOVED ROM CODE.

CPIHND,	DCA	XR7			/SAVE AC
	GCF				/GET CURRENT FIELDS, ETC. STATUS
	DCA	XR6			/STASH IT
	PRS				/GET PANEL STATUS
	DCA	XR0			/STASH IT
	SPD				/CP INDIRECTS FROM NOW ON
	TAD	XR0			/GET STATUS BACK
	SMA				/SKIP IF BOOTSTRAP (CPREQ) SET
	JMP	HALTEST			/JUMP IF NOT
	CLA				/CLEAN UP
	VSF				/SKIP ON, CLEAR VIDEO INTERRUPT FLAG
	NOP				/IN CASE IT SKIPS
	TTYSF				/SKIP ON, CLEAR TTY: TRAP FLAG
	NOP				/IN CASE IT SKIPS
	KBISF				/SKIP ON, CLEAR KEYBOARD INPUT FLAG
	NOP				/IN CASE IT SKIPS
	KBOSF				/SKIP ON, CLEAR KEYBOARD OUTPUT FLAG
	NOP				/IN CASE IT SKIPS
	TAD	XR6			/GET FIELDS BACK
	RTF				/RESTORE THEM
	TAD	XR7			/RESTORE AC
	PEX				/LEAVING PANEL MEMORY
	JMP I	INTADR			/RETURN TO INTERRUPTED MAIN MEMORY  PROGRAM

HALTEST,CIF CDF	70			/STAYING IN OUR FIELD
	AND	L200/(200)		/JUST HLTFLG BIT
	SNA CLA				/SKIP IF SET
	JMP I	L200/(CODESTART)	/JUMP IF NOT (PANEL REQUEST)
	PG0				/RESET RUN FLIP-FLOP
	JMP I	.+1/(DWNENTRY)		/GO THERE
	DWNENTRY			/THROUGH HERE

L200,	200/CODESTART			/CONSTANT 0200

	0000				/THIS ENDS THE LIST OF INSTRUCTIONS TO MOVE

	ZBLOCK	2			/EMPTY SPACE
	PAGE

/	INTERRUPT-DRIVEN LOOPBACK TEST ROUTINE.  MOVED TO MAIN MEMORY FIELD 0.

	LBLOAD=	.			/WHERE WE ARE NOW

	RELOC	0200			/WHERE THIS EXECUTES IN MAIN MEMORY FIELD 0

LBTEST,	CAF				/CLEAN UP
	PRIRB				/READ PRINTER INPUT NOW
	HLT				/STOP NOW
HLTPC,	NL0004				/THIS SHOULD BE SKIPPED BECAUSE OF CP ROUTINES
	VFL				/SET VIDEO INTERRUPT FLAG
VIDPC,	NL0004				/THIS SHOULD BE SKIPPED BECAUSE OF CP ROUTINES
	KRS				/DO A TRAPPED KEYBOARD INSTRUCTION
TTYPC,	NL0004				/THIS SHOULD BE SKIPPED BECAUSE OF CP ROUTINES
	KBOFL				/SET KEYBOARD OUTPUT FLAG
KBOIPC,	NL0004				/THIS SHOULD BE SKIPPED BECAUSE OF CP ROUTINES
	KBIFL				/SET KEYBOARD INPUT FLAG
KBIPC,	NL0004				/THIS SHOULD BE SKIPPED BECAUSE OF CP ROUTINES
	DCA	TSTATUS			/SAVE AC TEST STATUS
	TAD	LB20/(20)		/GET LOOPBACK ENABLE VALUE
	VIDCON				/MAKE THE INTERFACES LOOP BACK
	CLA				/CLEAN UP
	NL0001				/SET INTERRUPT ENABLE BIT
	CLIE				/ENABLE CLOCK INTERRUPTS
	DCA	CSTATUS			/SET INITIAL COUNT STATUS
	TAD	L17/(17)		/GET BAUD RATE VALUE FOR 19200 BAUD
	PRSB				/SET BAUD RATE
	CLA CLL				/CLEAN UP
	DCA	CTMP1			/CLEAR INITIAL OUTPUT CHARACTER
	TAD	JMPI2/(JMP I INT2)	/GET INTERRUPT INSTRUCTION
	DCA	INT1			/STORE IN INTERRUPT STARTUP
	TAD	PINTHND/(INTHND)	/GET INTERRUPT ADDRESS
	DCA	INT2			/STORE IN INTERRUPT POINTER
	DCA	TIMEOUT			/CLEAR TIME-OUT COUNTER
	DCA	CLKTICK			/CLEAR CLOCK-TICK COUNTER
	TAD	CTMP1			/GET OUTPUT CHARACTER
	PROPC				/OUTPUT TO PRINTER PORT
	DCA	CTMP2			/SAVE AS INITIAL INPUT TEST VALUE ALSO
	ION				/TURN ON INTERRUPTS
	ISZ	TIMEOUT			/DONE WAITING YET?
	JMP	.-1			/NO, KEEP WAITING
	JMP	TIMCHK			/WE'RE DONE, FINISH IT THERE

PINTHND,INTHND				/POINTER TO INTERRUPT HANDLER
JMPI2,	JMP I	INT2			/INTERRUPT STARTUP INSTRUCTION
L377,	377				/CONSTANT 0377
LB20,	20				/LOOPBACK ENABLE VALUE
/	INTERRUPTS COME HERE.

INTHND,	CLSK				/CLOCK FLAG UP?
	SKP				/SKIP IF NOT
	JMP	DOCLK			/JUMP IF SO
	PROSKP				/PRINTER OUTPUT FLAG UP?
	SKP				/SKIP IF NOT
	JMP	PROINT			/JUMP IF SO
	PRISKP				/PRINTER INPUT FLAG UP?
	JMP	INTXIT			/JUMP IF NOT
	PRISKP				/SKIP ON, CLEARING THE FLAG
	NOP				/HERE IN CASE IT SKIPS
	PRIRB				/GET THE CHARACTER
	CIA				/INVERT FOR TESTING
	TAD	CTMP2			/COMPARE TO TEST VALUE
	AND	L377/(377)		/JUST DATA BITS
	SZA CLA				/SKIP IF IT MATCHES
	PRIIE				/PREVENT FURTHER PRINTER INPUT INTERRUPTS
	TAD	CTMP2			/GET LATEST COUNT PATTERN VALUE
	JMS	COUNTUP			/GET NEXT IN THE PATTERN
	JMP	COUNTDONE		/AT END OF COUNT PATTERN
	DCA	CTMP2			/STORE UPDATED VALUE
	DCA	TIMEOUT			/RESET TIME-OUT COUNTER
INTXIT,	ION				/RE-ENABLE INTERRUPTS
	JMP I	INTADR			/BACK TO INTERRUPTED CODE

DOCLK,	CLSK				/MAKE SURE CLOCK FLAG CLEARS
	NOP				/IN CASE IT SKIPS
	ISZ	CLKTICK			/COUNT THIS TICK
L17,	17				/19200 BAUD RATE VALUE; HERE IN CASE IT SKIPS
	JMP	INTXIT			/CONTINUE THERE

PROINT,	PROSKP				/SKIP ON, CLEARING PRINTER OUTPUT FLAG
	NOP				/JUST IN CASE IT SKIPS
	TAD	CTMP1			/GET COUNT PATTERN VALUE
	JMS	COUNTUP			/GET NEXT IN THE PATTERN
	SKP				/AT END OF COUNT PATTERN
	JMP	NEXTOUT			/JUMP IF NOT AT END
	PROIE				/PREVENT FURTHER PRINTER OUTPUT INTERRUPTS
	JMP	INTXIT			/CONTINUE THERE

NEXTOUT,DCA	CTMP1			/SAVE NEW VALUE
	TAD	CTMP1			/GET IT BACK
	PROLS				/OUTPUT IT
	JMP	INTXIT			/CONTINUE THERE

/	COMES HERE WHEN ALL CHARACTER VALUES USED.

COUNTDO,DCA	CSTATUS			/CLEAR COUNT STATUS
/	COMES HERE WHEN NULL JOB TIMES OUT.

TIMCHK,	NL7776				/SETUP VALUE
	TAD	CLKTICK			/COMPARE TO CLOCK TICK COUNT
	SPA CLA				/SKIP IF >=2
	NL002A				/SET STATUS BIT IF NOT
	TAD	CSTATUS			/GET COUNT STATUS EITHER WAY
	DCA	CSTATUS			/STORE BACK
	CAF				/CLEAR ALL FLAGS NOW
	TAD	CSTATUS			/GET COUNT STATUS
	TAD	TSTATUS			/GET CP TEST STATUS
	PRQ3				/DO A PANEL REQUEST TO EXIT
	JMP	.			/WILL HANG HERE IF IT FAILS!

COUNTUP,.-.				/PATTERN COUNT ROUTINE
	DCA	PATTERN			/SAVE PASSED VALUE
	TAD	PATTERN			/GET IT BACK
	IAC				/ADD ONE
	AND	L377/(377)		/JUST GOOD BITS
	SNA				/SKIP IF NOT AT END
	JMP I	COUNTUP			/TAKE IMMEDIATE RETURN IF AT END
	DCA	PATTERN			/SAVE UPDATED VALUE
	ISZ	COUNTUP			/BUMP RETURN ADDRESS
	TAD	PATTERN			/GET NEW PATTERN VALUE
	JMP I	COUNTUP			/TAKE SKIP RETURN TO CALLER

	LBTEND=	.			/END OF CODE TO BE MOVED

	RELOC	LBTEND-LBTEST+LBLOAD	/RE-ESTABLISH ORIGIN

/	SUBROUTINE  TO  SET HIGH-ORDER BITS IN CP 13705 AND 13707.  BIT[4] IS  SET  IN
/	13705;   BITS[4-5] ARE SET IN 13707.  THIS MAKES THE LINES INTO DOUBLE-HEIGHT,
/	DOUBLE WIDTH UPPER AND LOWER HALVES RESPECTIVELY.  THIS ROUTINE DEPENDS ON THE
/	PREVIOUS CONTENTS OF THE BITS BEING ZERO.

SET2,	.-.				/SET HIGH BITS IN 2 WORDS ROUTINE
	CDF	10			/GOTO BUFFER FIELD
	TAD I	L3705/(3705)		/GET CURRENT CONTENTS OF 13705
	TAD	Z200/[200]		/ADD ON A HIGH-ORDER BIT
	DCA I	L3705/(3705)		/STORE BACK
	TAD I	L3707/(3707)		/GET CURRENT CONTENTS OF 13707
	TAD	L300/(300)		/ADD ON HIGH-ORDER BITS
	DCA I	L3707/(3707)		/STORE BACK
	CDF	70			/BACK TO OUR FIELD
	JMP I	SET2			/RETURN

L3705,	3705				/CONSTANT 3705
L3707,	3707				/CONSTANT 3707
L300,	300				/CONSTANT 0300
L77,	77				/CONSTANT 0077
/	SUBROUTINE TO CLEAR THE ATTRIBUTE BITS OF CP  13705 AND 13707.  THIS MAKES THE
/	CORRESPONDING LINES NORMAL WIDTH AND HEIGHT.

CLR2,	.-.				/CLEAR BITS IN TWO WORDS ROUTINE.
	CDF	10			/GOTO BUFFER FIELD
	TAD I	L3705/(3705)		/GET CURRENT CONTENTS OF 13705
	AND	L77/(77)		/JUST KEEP LOW-ORDER HALF
	DCA I	L3705/(3705)		/STORE BACK
	TAD I	L3707/(3707)		/GET CURRENT CONTENTS OF 13707
	AND	L77/(77)		/JUST KEEP LOW-ORDER HALF
	DCA I	L3707/(3707)		/STORE BACK
	CDF	70			/BACK TO OUR FIELD
	JMP I	CLR2			/RETURN

	ZBLOCK	1			/EMPTY SPACE
	PAGE

/	CP-INTERRUPT HANDLER FOR MAIN MEMORY LOOPBACK TEST.

	CPLOAD=	.			/CP-INTERRUPT HANDLER LOADS HERE

	RELOC	4000			/WHERE THIS EXECUTES IN FIELD 0

	CPINT=	.			/CP-INTERRUPT HANDLER CODE EXECUTES HERE

CPINT,	DCA	XR7			/SAVE AC
	PRS				/GET STATUS
	DCA	XR0			/SAVE IT
	SPD				/WANT OUR OWN INDIRECTS
	CIF CDF	00			/SET OUR OWN FIELD
	TAD	XR0			/GET STATUS
	RAL				/MOVE UP
	SZL				/SKIP IF BOOTSTRAP NOT SET
	JMP	TESTCP			/JUMP IF IT IS
	SPA				/SKIP IF PANEL REQUEST NOT SET
	JMP	PRQEXIT			/JUMP IF IT IS SET
	R3L				/MOVE UP
	SPA CLA				/SKIP IF HALT TRAP NOT SET
	JMP	TESTHLT			/JUMP IF IT IS SET
	CDF CIF	70			/BACK TO OUR FIELD
	JMP I	PLBDONE/(LBDONE)	/RETURN TO CALLER

PLBDONE,LBDONE				/POINTER TO CALLER OF TEST

/	AT THIS POINT, THE SO-CALLED "BOOTSTRAP" CONDITION IS SET,  WHICH  MEANS  THAT
/	ONE OF THE CPREQ'S FROM THE THIRD PIE CHIP HAS OCCURRED.

TESTCP,	CLA				/CLEAN UP
	VSF				/VIDEO INTERRUPT?
	JMP	TSTTRAP			/NO, TRY OTHERS
	CLA				/CLEAN UP
	VIE				/PREVENT FURTHER VIDEO INTERRUPTS
	TAD	PVIDPC/(VIDPC)		/GET EXPECTED INTERRUPTED ADDRESS
	CIA				/INVERT FOR COMPARISON
	TAD	INTADR			/COMPARE TO ACTUAL INTERRUPT PC
	SNA CLA				/SKIP IF OTHER THAN EXPECTED
	JMP	BUMPIT			/JUMP IF OK

/	INTERRUPT PC WRONG.

	JMP	JUSTEXIT		/CONTINUE THERE
TSTTRAP,TTYSF				/DEVICE 03, 04 TRAP FLAG SET?
	JMP	TSTKYIN			/JUMP IF NOT
	TTYIE				/PREVENT FURTHER TTY: TRAP INTERRUPTS
	TAD	PTTYPC/(TTYPC)		/GET EXPECTED INTERRUPTED ADDRESS
	CIA				/INVERT FOR COMPARISON
	TAD	INTADR			/COMPARE TO ACTUAL INTERRUPT PC
	SNA CLA				/SKIP IF OTHER THAN EXPECTED
	JMP	BUMPIT			/JUMP IF OK

/	INTERRUPT PC WRONG.

	JMP	JUSTEXIT		/CONTINUE THERE

TSTKYIN,KBISF				/KEYBOARD INPUT FLAG SET?
	JMP	TSTKYOUT		/NO, TRY OUTPUT
	KBIIE				/PREVENT FURTHER KEYBOARD INPUT INTERRUPTS
	TAD	PKBIPC/(KBIPC)		/GET EXPECTED INTERRUPTED ADDRESS
	CIA				/INVERT FOR COMPARISON
	TAD	INTADR			/COMPARE TO ACTUAL INTERRUPT PC
	SNA CLA				/SKIP IF OTHER THAN EXPECTED
	JMP	BUMPIT			/JUMP IF OK

/	INTERRUPT PC WRONG.

	JMP	JUSTEXIT		/CONTINUE THERE

TSTKYOU,KBOSF				/KEYBOARD OUTPUT FLAG SET?
	JMP	JUSTEXIT		/NO, FORGET IT
	KBOIE				/PREVENT FURTHER KEYBOARD OUTPUT INTERRUPTS
	TAD	PKBOIPC/(KBOIPC)	/GET EXPECTED INTERRUPTED ADDRESS
	CIA				/INVERT FOR COMPARISON
	TAD	INTADR			/COMPARE TO ACTUAL INTERRUPT PC
	SNA CLA				/SKIP IF OTHER THAN EXPECTED

/	COMES HERE TO BUMP THE PC PAST THE NL0004 INSTRUCTIONS IF THE PROPER INTERRUPT
/	ADDRESS WAS PRESENT AT THE POINT OF INTERRUPT.

BUMPIT,	ISZ	INTADR			/BUMP INTERRUPTED ADDRESS

/	SKIPS PREVIOUS TO EXIT NORMALLY; THIS COULD POSSIBLY BE CONSIDERED AN ERROR.

JUSTEXI,PEX				/EXITING FROM PANEL MEMORY
	JMP I	INTADR			/BACK TO INTERRUPTED MAIN MEMORY PROGRAM
/	COMES HERE IF THE HALT FLAG WAS SET

TESTHLT,CLA				/CLEAN UP
	PG0				/RESET THE HALT FLAG
	TAD	PHLTPC/(HLTPC)		/GET EXPECTED INTERRUPTED ADDRESS
	CIA				/INVERT FOR COMPARISON
	TAD	INTADR			/COMPARE TO ACTUAL INTERRUPT PC
	SNA CLA				/SKIP IF OTHER THAN EXPECTED
	JMP	BUMPIT			/JUMP IF OK

/	INTERRUPT PC WRONG.

	JMP	JUSTEXIT		/CONTINUE THERE

/	COMES HERE IF MAIN MEMORY PROGRAM EXITED VIA PANEL REQUEST.

PRQEXIT,CLA				/CLEAN UP
	TAD	XR7			/RESTORE EXITING AC
	CIF CDF	70			/BACK TO OUR FIELD
	JMP I	PLBDONE/(LBDONE)	/RETURN TO CALLER

PVIDPC,	VIDPC				/EXPECTED PC FOR VIDEO INTERRUPT
PTTYPC,	TTYPC				/EXPECTED PC FOR TTY: TRAP INTERRUPT
PKBIPC,	KBIPC				/EXPECTED PC FOR KEYBOARD INPUT INTERRUPT
PKBOIPC,KBOIPC				/EXPECTED PC FOR KEYBOARD OUTPUT INTERRUPT
PHLTPC,	HLTPC				/EXPECTED PC FOR HALT INTERRUPT

	CPEND= .			/END OF CP-INTERRUPT HANDLER CODE THAT OUGHT
					/TO BE MOVED

	RELOC	CPEND-CPINT+CPLOAD	/RE-ESTABLISH ORIGIN
/	THIS  ROUTINE READS IN TRACK 0, SECTOR 3 INTO CP 15350-16347.  THE FIRST EIGHT
/	BYTES ARE  VALIDATED AGAINST A KNOWN PATTERN.  ALL ELEMENTS READ IN AS 377 ARE
/	REPLACED WITH 4000 IN THE RUNNING COPY.

T0S3RD,	.-.				/TRACK 0, SECTOR 3 READ ROUTINE
	TAD	PT0S3BUFF/(T0S3BUFFER-1)/SETUP THE
	DCA	XR0			/DATA STORAGE POINTER
	CDF	10			/SET THE DATA FIELD FOR THE TRANSFER
	NL002A				/SET SECTOR OFFSET (3-1)
	JMS I	PFREAD/(FREAD)		/CALL FLOPPY READ ROUTINE
	-3-1				/SECTOR THREE IS THE LAST ONE
	0				/TRACK 0000
	JMP I	T0S3RD			/ERROR, TAKE NON-SKIP RETURN
	TAD	PT0S3DATA/(T0S3DATA-1)	/SETUP THE VALIDATION LIST VALUE
	DCA	XR0			/STASH THE POINTER
	TAD	PT0S3BUFF/(T0S3BUFFER-1)/POINT TO THE
	DCA	XR1			/READ-IN DATA
LISTLUP,TAD I	XR0			/GET A TEST VALUE
	SNA				/END OF LIST?
	JMP	LISTOK			/JUMP IF SO
	CDF 	10			/GOTO DATA FIELD
	TAD I	XR1			/COMPARE TO READ-IN VALUE
	CDF	70			/BACK TO OUR FIELD
	SZA CLA				/SKIP IF IT MATCHES
	JMP I	T0S3RD			/TAKE FAILURE RETURN IF NOT
	JMP	LISTLUP			/KEEP GOING

LISTOK,	JMS I	PRUBCHK/(RUBCHK)	/REPLACE ALL 377 CODES WITH 4000
	ISZ	T0S3RD			/BUMP TO SUCCESSFUL RETURN
	JMP I	T0S3RD			/TAKE SKIP-RETURN TO CALLER

PFREAD,	FREAD				/POINTER TO FLOPPY READ ROUTINE
PT0S3DA,T0S3DATA-1			/POINTER TO TEST DATA FOR TRACK 0, SECTOR 3
PT0S3BU,T0S3BUFFER-1			/POINTER TO TRACK 0, SECTOR 3 LOADING ADDRESS
PRUBCHK,RUBCHK				/POINTER TO RUBCHK ROUTINE
/	COMES BACK HERE AFTER LOADING THE CHARACTER GENERATOR RAM TO EXIT.

CGDONE,	JMP I	DOCG			/RETURN TO ORIGINAL CALLER

PT0S7DA,T0S7DATA-1			/POINTER TO TEST DATA FOR TRACK 0, SECTOR 7
PUSEDAT,USEDATA				/POINTER TO USE DATA ROUTINE
PNODATA,NODATA				/POINTER TO NO DATA ROUTINE

/	THE CHARACTER GENERATOR RAM LOAD ROUTINE IS ENTERRED HERE.

DOCG,	.-.				/CHARACTER GENERATOR RAM LOAD ROUTINE
	NL7777				/SETUP THE
	DCA	XR0			/STORE POINTER
	CDF	00			/GOTO DATA FIELD
	NL0006				/SET OFFSET FOR SECTOR 7 (7-10)
	JMS I	PFREAD/(FREAD)		/CALL FLOPPY READ ROUTINE
	-12-1				/WANT SECTORS 7-10
	0				/ON TRACK 0
	JMP I	PNODATA/(NODATA)	/ERROR, TRY TO KEEP GOING

/	THE DATA READ IN OK, SO VALIDATE IT.

	TAD	PT0S7DATA/(T0S7DATA-1)	/SETUP THE
	DCA	XR0			/TEST DATA POINTER
	NL7777				/SETUP THE
	DCA	XR1			/DATA POINTER
TSTDLUP,TAD I	XR0			/GET A TEST WORD
	SNA				/SKIP IF NOT AT END OF LIST
	JMP I	PUSEDATA/(USEDATA)	/END OF LIST, GO USE GOOD DATA
	CDF	00			/GOTO DATA FIELD
	TAD I	XR1			/COMPARE DATA TO TEST WORD
	CDF	70			/BACK TO OUR FIELD
	SNA CLA				/SKIP IF NO MATCH
	JMP	TSTDLUP			/KEEP GOING IF IT MATCHES

/	THE DATA ISN'T VALID, SO IGNORE IT AS IF IT HAD BEEN AN I/O ERROR.

	JMP I	PNODATA/(NODATA)	/CONTINUE THERE
	PAGE

/	COMES HERE TO CLEAR THE DATA WHICH WAS EITHER INVALID OR COULDN'T GET READ IN.
/	BETTER TO CLEAR THE TABLE THAN LEAVE IT AT RANDOM.

NODATA,	DCA	CGPTR			/CLEAR THE DATA POINTER
CLRLUP,	CDF 	00			/GOTO DATA FIELD
	DCA I	CGPTR			/CLEAR A WORD
	ISZ	CGPTR			/DONE ALL YET?
	JMP	CLRLUP			/NO, GO BACK

/	COMES HERE TO  LOAD  THE  CHARACTER GENERATOR RAM FROM (HOPEFULLY) THE READ-IN
/	DATA (OR JUST ZEROES IF IT WASN'T READABLE).

USEDATA,CDF 	70			/GOTO OUR FIELD

/	WE HAVE TO CLEAR  THE  FIRST ROW OF DATA BECAUSE IT ISN'T A PART OF THE USEFUL
/	DATA (VERIFICATION HEADER AND OTHER JUNK).

	NL7777				/SETUP THE
	DCA	XR0			/DATA POINTER
	TAD	Z7760/[-20]		/SETUP THE
	DCA	XR1			/ROW COUNTER
	CDF	00			/GOTO THE DATA FIELD
CLRIT,	DCA I	XR0			/CLEAR A WORD
	ISZ	XR1			/DONE ENOUGH?
	JMP	CLRIT			/NO, GO BACK
	TAD	L110/(110)		/DISABLE SCREEN AND ENABLE CG RAM
	VIDCON				/LOAD VIDEO CONTROL
	NL7777				/SETUP THE
	DCA	XR0			/DATA POINTER
	DCA	CGPTR			/CLEAR CG RAM ADDRESS POINTER

CGLDLP,	TAD	PCGINDX/(CGINDX-1)	/SETUP THE
	DCA	XR2			/INDEX POINTER
	TAD	Z7760/[-20]		/SETUP THE
	DCA	XR1			/LINE COUNT
NXTLINE,CDF	70			/BACK TO OUR (ODD) FIELD
	TAD I	XR2			/GET AN INDEX
	TAD	CGPTR			/ADD ON CURRENT CHARACTER BASE
	CGLOAD				/LOAD CHARACTER GENERATOR ADDRESS
	CLA				/CLEAN UP
	CDF	00			/GOTO (EVEN) FIELD 0
	TAD I	XR0			/GET LATEST CELL DATA LINE
	CGLOAD				/LOAD CHARACTER GENERATOR VALUE
	CLA				/CLEAN UP
	ISZ	XR1			/DONE ALL LINES YET?
	JMP	NXTLINE			/NO, GO BACK
	TAD	Z20/[20]		/SETUP CHARACTER UPDATE
	TAD	CGPTR			/ADD TO CHARACTER ADDRESS
	DCA	CGPTR			/STORE BACK
	TAD	CGPTR			/GET THE POINTER
	SMA CLA				/SKIP IF DONE ALL 2048 LINES
	JMP	CGLDLP			/JUMP IF NOT DONE YET
	NL0010 CLL			/SETUP RAM ENABLE AND SCREEN ENABLE
	VIDCON				/LOAD NEW CONTROL VALUE
	CLA				/CLEAN UP
	JMP I	.+1/(CGDONE)		/GO THERE
	CGDONE				/THROUGH HERE

L110,	110				/CONSTANT 0110
PCGINDX,CGINDX-1			/POINTER TO CG INDEX TABLE

/	TABLE OF CG CELL LINE INDICES; (THE FOUR BITS ARE READ BACKWARDS).

CGINDX,	00				/LINE 00
	10				/LINE 01
	04				/LINE 02
	14				/LINE 03
	02				/LINE 04
	12				/LINE 05
	06				/LINE 06
	16				/LINE 07
	01				/LINE 08
	11				/LINE 09
	05				/LINE 10
	15				/LINE 11
	03				/LINE 12
	13				/LINE 13
	07				/LINE 14
	17				/LINE 15

CGPTR,	0000				/CHARACTER GENERATOR DATA POINTER

/	NOTE:  ALL  ROUTINES  AND  DATA BEYOND THIS POINT MARKED WITH ******** ARE NOT
/	ACCESSED BY THE NORMAL  USAGE  OF THE ROM EXCEPT POSSIBLY INDIRECTLY THROUGH A
/	DOWN-LOADED AUTOMATIC PRODUCT TEST ROUTINE.  ALL OF THE CODE IS SUBORDINATE TO
/	THE SUBROUTINE ENTERRED VIA JMS 0176,  WHICH  IS  ITSELF  NOT  CALLED  BY  ANY
/	EXISTING ROM ROUTINES.
/	********

GETPARM,.-.				/ROUTINE TO GET SELECTED PARAMETERS
	NL7777				/SETUP THE
	DCA	XR0			/DATA POINTER
	CDF	00			/GOTO DATA FIELD
	TAD I	XR0			/GET A WORD
	DCA	COMTM1			/STASH IT
	NL0003				/SETUP THE
	DCA	XR0			/DATA POINTER
	NL7777				/BACKUP FOR AUTO-INDEX
	TAD I	XR0			/GET ADDRESS POINTER
	DCA	XR1			/STASH IT
	TAD I	XR0			/GET FIELD VALUE
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
	TAD I	XR1			/GET ADDRESS
	DCA	TM0			/STASH IT
	TAD I	XR1			/GET FIELD
	DCA	MTM5			/STASH IT
	TAD I	XR1			/GET ADDRESS
	DCA	MTM1			/STASH IT
	TAD I	XR1			/GET FIELD
	DCA	MTM6			/STASH IT
	TAD I	XR1			/GET ADDRESS
	DCA	MTM2			/STASH IT
	TAD I	XR1			/GET FIELD
	DCA	MTM7			/STASH IT
	RSP1				/GET FIRST STACK POINTER
	DCA	SP1SAVE			/SAVE IT
	RSP2				/GET SECOND STACK POINTER
	DCA	SP2SAVE			/SAVE IT
	TAD	MTM5			/GET FIELD
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
	TAD I	TM0			/GET VALUE
	CDF	70			/BACK TO OUR FIELD
	DCA	TM0			/SAVE IT
	TAD	MTM6			/GET FIELD
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
	TAD I	MTM1			/GET VALUE
	CDF	70			/BACK TO OUR FIELD
	DCA	MTM1			/SAVE IT
	TAD	MTM7			/GET FIELD
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
	TAD I	MTM2			/GET VALUE
	CDF	70			/BACK TO OUR FIELD
	DCA	MTM2			/SAVE IT
	JMP I	GETPARM			/RETURN TO CALLER
/	********

/	COUNT FOR FIELDS PRIOR TO HIGHLIGHTED RATE FIELD.

CLIST,	-1				/50 BAUD
	-1				/75 BAUD
	-1				/110 BAUD
	-1				/134.5 BAUD
	-1				/150 BAUD
	-1				/300 BAUD
	-2				/600 BAUD
	-3				/1200 BAUD
	-4				/1800 BAUD
	-4				/2000 BAUD
	-4				/2400 BAUD
	-5				/3600 BAUD
	-5				/4800 BAUD
	-6				/7200 BAUD
	-6				/9600 BAUD
	-6				/19200 BAUD

/	********

CIDF,	CIF CDF	00			/CONSTANT 6203
AFREAD,	FREAD				/POINTER TO FLOPPY READ ROUTINE
PPRMPRT,PRMPRT				/POINTER TO SETUP PARAMETER PRINT ROUTINE
PLOC36,	LOC36				/POINTER TO 36 OR 37 LOCATOR ROUTINE
PT0S1DA,T0S1DAT-1 			/TRACK 0 SECTORS 1-2 VALIDATION DATA POINTER
/	********

/	CONTINUATION OF SUBROUTINE CALL FROM 0176.

SUBR,	DCA	SUBAC			/SAVE PASSED AC
	SEL				/SELECT FIRST RX50 PAIR
	SDN				/SKIP ON, CLEARING DONE FLAG
P24,	24				/POINTER TO 0024; THIS CAN BE SKIPPED
	SER				/SKIP ON, CLEARING ERROR FLAG
P26,	26				/POINTER TO 0026; THIS CAN BE SKIPPED
	STR				/SKIP ON, CLEARING TRANSFER FLAG
P25,	25				/POINTER TO 0025; THIS CAN BE SKIPPED
	RDF				/GET DATA FIELD
	TAD	CIDF/(CIF CDF 00)	/TURN INTO CIF CDF INSTRUCTION
	DCA	SUBCDF			/STORE IN-LINE
	DCA	CCNT			/CLEAR DELIMITER CHARACTER SEARCH COUNT
	CDF	70			/GOTO OUR FIELD
	TAD	Z102/[102]		/SETUP 8-BIT SILO EMPTY
	DCA	RXCMD			/STASH THE COMMAND
	JMS	VERHLT			/CALL HLT PANEL VERIFY, ETC. ROUTINE
	JMP	SUBCDF			/ERROR RETURN, WE EXIT

/	NOW VERIFY THAT SETUP DATA IS VALID.

	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/DATA STORAGE POINTER
/	CLA				/WANT SECTOR 1 FIRST (1-1)
	JMS I	AFREAD/(FREAD)		/CALL FLOPPY READ ROUTINE
	-2-1				/TWO SECTORS (1-2)
	0				/TRACK 00
	JMP	SUBCDF			/COULDN'T DO IT
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/READ-IN DATA POINTER
	TAD	PT0S1DAT/(T0S1DAT-1)	/SETUP THE
	DCA	XR1			/VALIDATION DATA POINTER
SETVLUP,TAD I	XR1			/GET A TEST WORD
	SNA				/END OF LIST
	JMP	SETOK			/YES, WE'RE DONE
	TAD I	XR0			/COMPARE TO READ-IN DATA
	SZA CLA				/SKIP IF IT MATCHES
	JMP	SUBCDF			/JUMP IF IT'S DIFFERENT
	JMP	SETVLUP			/KEEP GOING

SETOK,	JMS I	PROWLOAD/[ROWLOAD]	/CALL ROWTABLE AND REGISTER LOAD ROUTINE
	JMS I	PVIDCLR/(VIDCLR)	/CLEAR VIDEO DATA
	CDF	00			/GOTO DATA FIELD
	TAD I	P24/(0024)		/GET 00024
	DCA	TEMP1			/SAVE IT
	TAD I	P25/(0025)		/GET 00025
	DCA	TEMP2			/SAVE IT
	TAD I	P26/(0026)		/GET 00026
	DCA	TEMP3			/SAVE IT
NEXTPRM,CDF	70			/BACK TO OUR FIELD
	JMS I	PLOC36/(LOC36)		/LOCATE A (36 OR 37) DELIMITER
	JMS I	PPRMPRT/(PRMPRT)	/PRINT CURRENT PARAMETER VALUES
NEXTCHR,JMS I	PKBDIN/[KBDIN]		/GET A CHARACTER
METRENT,DCA	SUBAC			/SAVE LATEST CHARACTER
	TAD	PCOMTABLE/(COMTABLE-1)	/SETUP THE
	DCA	XR0			/TABLE POINTER
COMSRCH,TAD I	XR0			/GET A WORD
	SNA				/SKIP IF NOT AT END OF LIST
	JMP	NEXTCHR			/END OF LIST, IGNORE AND GET ANOTHER
	TAD	SUBAC			/COMPARE TO CHARACTER
	SNA CLA				/SKIP IF NOT A MATCH
	JMP	FINDIT			/JUMP IF IT MATCHES
	ISZ	XR0			/BUMP PAST DISPATCH ADDRESS
	JMP	COMSRCH			/TRY AGAIN

FINDIT,	TAD I	XR0			/GET DISPATCH ADDRESS
	DCA	DISPADR			/STASH IT
	TAD	SUBAC			/GET THE CHARACTER ITSELF AS AN ARGUMENT
	JMS I	DISPADR			/DISPATCH TO ROUTINE
	JMP	NEXTCHR			/NO-CHANGE RETURN, GO THERE
	JMP	NEXTPRM			/POSSIBLE-CHANGE RETURN, GO THERE
SUBCDF,	HLT+.-.				/DOUBLE-SKIP RETURN; WILL BE CIF CDF RETURN
	JMP I	SUB176			/RETURN TO CALLER

SUBAC,	.-.				/AC DATA SAVED HERE
DISPADR,.-.				/DISPATCH ADDRESS TEMPORARY
PCOMTAB,COMTABLE-1			/POINTER TO COMMAND DISPATCH TABLE
PVIDCLR,VIDCLR				/POINTER TO VIDEO CLEAR ROUTINE
/	********

VERHLT,	.-.				/READ AND VERIFY HALT PANEL DATA
	TAD	SUBAC			/GET PASSED ARGUMENT
	SNA CLA				/SKIP IF SET
	JMP	VERPOK			/JUMP IF NOT
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/DATA STORAGE POINTER
	NL0003				/SET OFFSET FOR SECTOR 4
	JMS I	AFREAD/(FREAD)		/CALL FLOPPY READ ROUTINE
	-4-1				/ONE SECTOR (4)
	0				/TRACK 0
	JMP	VERPOK			/COULDN'T DO IT; JUST IGNORE THE PROBLEM
	CDF	70			/BACK TO OUR FIELD
	TAD	PT0S4DAT/(T0S4DAT-1)	/SETUP THE VALIDATION LIST ADDRESS
	DCA	XR0			/STASH THE POINTER
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE POINTER TO
	DCA	XR1			/THE READ-IN HALT PANEL DATA
VERLUP,	TAD I	XR0			/GET A TEST WORD
	SNA				/SKIP IF NOT AT END OF LSIT
	JMP	VERMATCH		/JUMP IF IT MATCHES
	TAD I	XR1			/COMPARE TO READ-IN WORD
	SZA CLA				/SKIP IF IT MATCHES
	JMP	VERPOK			/IGNORE THE DATA IF NO MATCH
	JMP	VERLUP			/GO DO NEXT COMPARE

VERMATC,JMS I	PROWLOAD/[ROWLOAD]	/CALL ROWTABLE AND REGISTER LOAD ROUTINE
	JMS I	PVIDCLR/(VIDCLR)	/CLEAR VIDEO DATA
KAGN,	JMS I	PGETPARM/(GETPARM)	/GET THE PARAMETER VALUES
	JMS I	PPRINTP/(PRINTP)	/PRINT THE PARAMETERS IN OCTAL
	JMS I	PKBDIN/[KBDIN]		/GET A KEYBOARD CHARACTER
	TAD	M175/(-175)		/COMPARE TO DO KEY
	SNA				/SKIP IF DIFFERENT
	JMP I	VERHLT			/TAKE FAILURE RETURN
	TAD	L45/(45)		/COMPARE TO BREAK KEY
	SZA CLA				/SKIP IF IT MATCHES
	JMP	KAGN			/JUMP IF NOT
VERPOK,	ISZ	VERHLT			/BUMP TO SUCCESSFUL RETURN
	JMP I	VERHLT			/TAKE SKIP RETURN TO CALLER

M175,	-175				/CONSTANT 7603
L45,	45				/CONSTANT 0045
PGETPAR,GETPARM				/POINTER TO GETPARM ROUTINE
PPRINTP,PRINTP				/PARAMETER PRINTOUT POINTER
PT0S4DA,T0S4DAT-1			/POINTER TO TRACK 0, SECTOR 4 VALIDATION LIST

	ZBLOCK	7			/EMPTY SPACE
	PAGE

/	********

/	HANDLER FOR SELECT KEY IN SETUP ROUTINE.

SELCT,	.-.				/SELECT LATEST ITEM
	CLA				/CLEAN UP
	TAD	CCNT			/GET SEARCH POSITIION LIMIT
	TAD	M16/(-16)		/COMPARE TO LIMIT
	SMA CLA				/SKIP IF LESS THAN THIS MAXIMUM
	JMP	TRYPRATE		/JUMP IF NOT
	TAD	CCNT			/GET POSITION
	CLL RAR				/%2
	CMA				/INVERT IT
	DCA	SELSHFT			/SAVE AS COUNTER
	STL				/SET A STOP BIT JUST IN CASE
SHFTLUP,RAL				/MOVE UP
	ISZ	SELSHFT			/DONE ENOUGH?
	JMP	SHFTLUP			/NO, GO BACK
	MQL				/SAVE FOR NOW
	CLA MQA				/GET IT BACK
	CMA				/INVERT IT
	AND	TEMP1			/SAVE THE OTHER BITS
	DCA	TEMP1			/STORE BACK FOR NOW
	TAD	CCNT			/GET THE POSITION COUNT
	CLL RAR				/%2
	CLA				/CLEAN UP
	TAD	TEMP1			/GET THE OTHER BITS
	SZL				/SKIP IF BIT IS OFF
	MQA				/ELSE OR IN SELECTED VALUE
	DCA	TEMP1			/SAVE COMPOSITE VALUE
SELXIT,	ISZ	SELCT			/TAKE SKIP RETURN
	JMP I	SELCT			/RETURN TO COMMAND ROUTINE

TRYPRAT,TAD	CCNT			/GET POSITION
	TAD	M16/(-16)		/ADD ON UPPER LIMIT
	TAD	L7773/(-5)		/ADD ON EXTRA LIMIT
	SMA SZA				/SKIP IF IN THIS RANGE
	JMP	DOCOMRATE		/JUMP IF NOT
	TAD	L5/(5)			/SUBTRACT RELATIVE LIMIT
	TAD	PBTABLE/(BTABLE)	/ADD ON TABLE BASE
	DCA	TEMP2			/STASH THE POINTER
	TAD I	TEMP2			/GET THE PROPER BAUD RATE VALUE
	DCA	TEMP2			/STASH IT
	JMP	SELXIT			/FINISH THERE

DOCOMRA,DCA	TEMP3			/SAVE RELATIVE POSITION
	NL7777				/-1
	TAD	TEMP3			/NOW HAVE PROPER RELATIVE VALUE
	TAD	PBTABLE/(BTABLE)	/ADD ON TABLE ADDRESS
	DCA	TEMP3			/STASH THE POINTER
	TAD I	TEMP3			/GET THE PROPER BAUD RATE VALUE
	DCA	TEMP3			/STASH IT
	JMP	SELXIT			/CONTINUE THERE
/	********

SELSHFT,.-.				/SELECT ROUTINE COUNTER
M16,	-16				/CONSTANT 7762
L7773,	-5				/CONSTANT 7773
L5,	5				/CONSTANT 0005
PBTABLE,BTABLE				/POINTER TO BAUD RATE TABLE

/	BAUD RATE TABLE FOR SUPPORTED RATES.

BTABLE,	05				/300 BAUD
	06				/600 BAUD
	07				/1200 BAUD
	12				/2400 BAUD
	14				/4800 BAUD
	16				/9600 BAUD

/	********

KBDIN,	.-.				/COMMAND INPUT ROUTINE
	KBISF				/FLAG UP?
	JMP	.-1			/NO, WAIT FOR IT
	KBIRB				/YES, READ IT IN
	AND	Z377/[377]		/JUST EIGHT BITS
	JMP I	KBDIN			/RETURN

ARXWAIT,RXWAIT				/POINTER TO RX50 WAIT ROUTINE

RXRDY,	.-.				/DRIVE READY CHECK ROUTINE
	TAD	Z12/[12]		/GET READ STATUS VALUE
	LCD				/LOAD THE COMMAND
	JMS I	ARXWAIT/(RXWAIT)	/WAIT FOR IT
	JMP I	RXRDY			/TRANSFER FLAG CAME UP, FORGET IT
	SKP				/DONE FLAG CAME UP, THERE'S HOPE
	JMP I	RXRDY			/ERROR OR TIME-OUT
	XDR				/GET STATUS
	AND	Z200/[200]		/JUST DRIVE READY BIT
	SZA CLA				/SKIP IF NOT READY
	ISZ	RXRDY			/ELSE TAKE SKIP RETURN
	JMP I	RXRDY			/RETURN EITHER WAY
/	********

VIDCLR,	.-.				/VIDEO CLEAR (?) ROUTINE
	NL6000				/SET BOTH CONTROL BITS
	VIDCON				/LOAD CONTROL REGISTER
	CLA				/CLEAN UP
	DCA	XR0			/CLEAR INNER COUNTER
	NL7775				/SET THE
	DCA	XR1			/OUTER COUNTER
VIDWAIT,ISZ	XR0			/WAITING ENOUGH?
	JMP	VIDWAIT			/NO, KEEP GOING
	ISZ	XR1			/WAITED TOO LONG?
	JMP	VIDWAIT			/NO, KEEP GOING
	VIDCON				/RESET TO NORMAL VIDEO MODE
	JMP I	VIDCLR			/RETURN

/	SLUSHWARE TEST VALIDATION DATA.

SLTDAT,	-6201
	-0033
	-0077
	0				/THIS ENDS THE LIST

/	********

/	COMMAND DISPATCH TABLE FOR BUILT-IN COMMANDS.

COMTABL,-214;	BOOTIT			/REMOVE
	-215;	SELCT			/SELECT
	-175;	DOKEY			/DO
	-247;	MOVLEFT			/LEFT ARROW
	-250;	MOVRITE			/RIGHT ARROW
	-275;	RETURN			/RETURN
	-264;	METRONOME		/METRONOME
	0				/THIS ENDS THE LIST
/	********

/	VALIDATION DATA FOR TRACK 0, SECTORS 1-2.

T0S1DAT,-1
	-"S!200
	-"E!200
	-"T!200
	-"U!200
	-"P!200
	0				/THIS ENDS THE LIST

/	VALIDATION DATA FOR TRACK 0, SECTORS 7-10.

T0S7DAT,-1
	-"U!200
	-"C!200
	-"G!200
	-"R!200
	-"A!200
	-"M!200
	-2
	0				/THIS ENDS THE LIST

/	VALIDATION DATA FOR TRACK 0, SECTOR 3.

T0S3DAT,-1
	-"K!200
	-"B!200
	-"D!200
	-"B!200
	-"R!200
	-"D!200
	-2
	0				/THIS ENDS THE LIST
/	********

M7,	-7				/CONSTANT 7771

PRMPRT,	.-.				/SETUP PARAMETER OUTPUT ROUTINE
	CDF	70			/BACK TO OUR FIELD
	DCA	ROW			/CLEAR ROW
	DCA	COLUMN			/CLEAR COLUMN
	TAD	TEMP1			/GET FIRST PARAMETER VALUE
	DCA	PRMTM1			/SAVE IT
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/BUFFER POINTER
	TAD	M7/(-7)			/SETUP THE
	DCA	XR1			/BUFFER COUNT
HEDLUP,	TAD I	XR0			/GET A CHARACTER
	TAD	Z7776/[-2]		/COMPARE TO HEADER END CODE
	SZA CLA				/SKIP IF IT MATCHES
	JMP	HEDLUP			/ELSE KEEP GOING
NXTPRM,	TAD	XR1			/GET CURRENT COUNT
	SNA CLA				/SKIP IF STILL SOME LEFT
	JMP	PRTRATE			/JUMP IF NOT
	TAD	PRMTM1			/GET FIRST PARAMETER VALUE
	CLL RAR				/MOVE OVER
	DCA	PRMTM1			/STORE BACK
	SNL				/SKIP IF SET
	NL0001				/ELSE SET INCREMENT
	TAD	Z7741/[-37]		/NOW HAVE -36 IF CLEAR, -37 IF SET
	DCA	PRMTM2			/SAVE IT
PRMLUP,	TAD I	XR0			/GET A CHARACTER
	MQL				/LOAD IT FOR PRINTING LATER
	CLA MQA				/GET IT BACK
	TAD	PRMTM2			/COMPARE TO DESIRED DELIMITER
	SNA CLA				/SKIP IF OTHER
	JMP	ATDELIM			/JUMP IF IT MATCHES
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	PRMLUP			/KEEP GOING

ATDELIM,ISZ	XR1			/COUNT THIS ONE
	NOP				/IN CASE IT SKIPS
PRTIT,	JMS I	PCHRPRT/CHRPRT]		/PRINT THE CHARACTER
	TAD I	XR0			/GET THE NEXT CHARACTER
	MQL				/LOAD IT FOR PRINTING
	CLA MQA				/GET IT BACK
	TAD	Z7741/[-37]		/COMPARE TO DELIMITER
	SMA SZA CLA			/SKIP IF THAT OR LESS
	JMP	REVIT			/JUMP IF NOT
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	NXTPRM			/GO DO NEXT PARAMETER

REVIT,	TAD	Z400/[400]		/ADD ON REVERSE VIDEO BIT
	JMP	PRTIT			/CONTINUE THERE
PRTRATE,TAD	TEMP2			/GET SECOND PARAMETER
	JMS	NPRT			/OUTPUT IT
	TAD	TEMP3			/GET THIRD PARAMETER
	JMS	NPRT			/OUTPUT IT
OUTLUP,	TAD I	XR0			/GET A CHARACTER
	MQL				/LOAD FOR PRINTING
	CLA MQA				/GET IT BACK
	TAD	Z7775/[7775]		/COMPARE TO END CHARACTER
	SNA CLA				/SKIP IF NOT AT END
	JMP I	PRMPRT			/RETURN IF AT END
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	OUTLUP			/GO DO ANOTHER

/	UNREFERENCED  LOCATION.  PERHAPS ERRONEOUS NOTION THAT  CHRPRT  ROUTINE  MIGHT
/	SKIP OR OTHER OBSOLETE CONVENTION?

	JMP I	PRMPRT			/RETURN

PRMTM1,	.-.				/TEMPORARY
PRMTM2,	.-.				/TEMPORARY

/	********

/	PRINT NUMERICAL  PARAMETER  ROUTINE.    THE SELECTED PARAMETER IS A BAUD RATE.
/	THE (CLOSEST TO THE) SELECTED RATE IS HIGHLIGHTED.

NPRT,	.-.
	DCA	NTMP			/SAVE THE PASSED VALUE
	TAD	NTMP			/GET IT BACK
	AND	Z17/[17]		/JUST RATE BITS
	TAD	PCLIST/(CLIST)		/ADD ON TABLE BASE
	DCA	NTMP			/STASH THE POINTER
	TAD I	NTMP			/GET THE PROPER COUNT
	DCA	NTMP			/STASH IT
NPLUP,	TAD I	XR0			/GET A CHARACTER
	MQL				/LOAD IT FOR PRINTING
	CLA MQA				/GET IT BACK
	TAD	Z7741/[-37]		/COMPARE TO FIELD DELIMITER
	SNA				/SKIP IF NOT A MATCH
	JMP	FNDDELIM		/JUMP IF IT IS
	IAC				/COMPARE TO ALTERNATE DELIMITER VALUE
	SNA CLA				/SKIP IF NOT A MATCH THERE EITHER
	JMP	FNDDELIM		/JUMP IF IT IS A MATCH
NEXTREG,JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	NPLUP			/GO DO NEXT

MOREPRM,JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	CLA MQA				/GET THE CHARACTER
	TAD	Z7766/[7766]		/COMPARE TO MASTER DELIMITER
	SNA CLA				/SKIP IF NOT AT END
	JMP I	NPRT			/RETURN IF AT END
	TAD I	XR0			/GET NEXT CHARACTER
	MQL				/LOAD IT FOR PRINTING
	JMP	MOREPRM			/KEEP GOING
/	COMES HERE IF FIELD DELIMITER FOUND.

FNDDELI,ISZ	NTMP			/FOUND ENOUGH REGULAR FIELDS?
	JMP	NEXTREG			/NO, KEEP GOING
BOLDLP,	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	TAD I	XR0			/GET ANOTHER CHARACTER
	MQL				/LOAD IT FOR PRINTING
	CLA MQA				/GET IT BACK
	TAD	Z7741/[-37]		/COMPARE TO FIELD DELIMITER
	SPA SNA CLA			/SKIP IF HIGHER
	JMP	MOREPRM			/JUMP IF NOT
	TAD	Z400/[400]		/GET REVERSE VIDEO BIT
	JMP	BOLDLP			/GO DO NEXT

NTMP,	.-.				/TEMPORARY
PCLIST,	CLIST				/POINTER TO REGULAR FIELD COUNT LIST

/	SLUSHWARE CODE VALIDATION ROUTINE.

SLCHECK,.-.				/SLUSHWARE VALIDATION ROUTINE
	RDF				/GET DATA FIELD
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	SLUCDF			/STORE IN-LINE
	TAD	PSLTDAT/(SLTDAT-1)	/SETUP THE
	DCA	XR1			/VALIDATION POINTER
	CDF	70			/BACK TO OUR FIELD
SLNEXT,	TAD I	XR1			/GET A TEST WORD
	SNA				/SKIP IF NOT AT END OF LIST
	JMP	SLGOOD			/JUMP IF AT END
SLUCDF,	CDF	00+.-.			/WILL BE CDF XX INSTRUCTION
	TAD I	XR0			/COMPARE TO READ-IN DATA
	CDF	70			/BACK TO OUR FIELD
	SNA CLA				/SKIP IF NOT A MATCH
	JMP	SLNEXT			/JUMP IF IT MATCHES
	JMP I	SLCHECK			/TAKE FAILURE RETURN

SLGOOD,	ISZ	SLCHECK			/BUMP TO GOOD RETURN
	JMP I	SLCHECK			/TAKE SKIP RETURN TO CALLER

PSLTDAT,SLTDAT-1			/POINTER TO SLUSHWARE TEST DATA

	ZBLOCK	2			/EMPTY SPACE
	PAGE

/	********

HIGHROW,ROWADR+1			/POINTER TO ROWTABLE (HIGH-ORDER)
L2030,	2030				/CONSTANT 2030
L31,	31				/CONSTANT 0031
M31,	-31				/CONSTANT 7747

CHRPRT,	.-.				/CHARACTER PRINT ROUTINE
	DCA	ATTRVAL			/SAVE PASSED ATTRIBUTE VALUE
	CLA MQA				/GET THE CHARACTER
	TAD	Z7766/[-"J!300]		/COMPARE TO 
	SNA				/SKIP IF OTHER
	JMP	JUSTPOS			/JUMP IF IT MATCHES
	TAD	Z7775/[-"M+"J]		/COMPARE TO 
	SNA CLA				/SKIP IF NO MATCH
	JMP	JUSTPOS			/JUMP IF IT MATCHES
	TAD	ROW			/GET DESIRED ROW NUMBER
	CLL RAL				/*2
	TAD	HIGHROW/(ROWADR+1)	/POINT TO PROPER HIGH-ORDER ADDRESS
	DCA	CHARADR			/STASH THE POINTER
	CDF	10			/GOTO ROWTABLE FIELD
	TAD I	CHARADR			/GET THE HIGH-ORDER ROW ADDRESS
	CDF	70			/BACK TO OUR FIELD
	DCA	CHARADR			/STASH THE POINTER
	TAD	CHARADR			/GET HIGH-ORDER ROW ADDRESS
	CLL RAR				/MOVE OVER
	AND	L2030/(30)		/JUST FIELD BITS (CLOSE ENOUGH)
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	CHARCDF			/STORE IN-LINE
	TAD	CHARADR			/GET HIGH-ORDER ROW ADDRESS AGAIN
	AND	Z17/[17]		/JUST QUARTER-FIELD BITS
	CLL RTL;BSW			/*400
	TAD	COLUMN			/ADD ON DESIRED COLUMN
	TAD	Z205/[205]		/ADD ON LINE BASE
	DCA	CHARADR			/STASH THE POINTER
	CLA MQA				/GET THE CHARACTER
	TAD	M40/(-40)		/COMPARE TO 
	SMA SZA CLA			/SKIP IF  OR CONTROL CHARACTER
	CLA MQA				/ELSE GET THE CHARACTER
	SZA				/SKIP IF NOT DISPLAYABLE
	TAD	ATTRVAL			/ELSE ADD ON PASSED ATTRIBUTES
CHARCDF,HLT+.-.				/WILL BE CDF 20 (OR 30) INSTRUCTION
	DCA I	CHARADR			/STORE IN LINE BUFFER
	CDF	70			/BACK TO OUR FIELD
JUSTPOS,JMS	SCRPOS			/ADVANCE SCREEN POSITION
	JMP I	CHRPRT			/RETURN

ATTRVAL,.-.				/PASSED ATTRIBUTE BITS SAVED HERE
CHARADR,.-.				/ADDRESS TEMPORARY
M40,	-" !200				/CONSTANT 7740
/	********

SCRPOS,	.-.				/SCREEN POSITION ADVANCE ROUTINE
	CLA MQA				/GET THE CHARACTER
	TAD	Z7766/[-"J!300]		/COMPARE TO 
	SZA				/SKIP IF IT MATCHES
	JMP	SCRCHK			/JUMP IF NOT
	ISZ	ROW			/BUMP TO NEXT ROW
	JMP I	SCRPOS			/RETURN

SCRCHK,	TAD	Z7775/[-"M+"J]		/COMPARE TO 
	SZA CLA				/SKIP IF IT MATCHES
	JMP	SCREGULAR		/JUMP IF NOT
	DCA	COLUMN			/CLEAR COLUMN
	JMP I	SCRPOS			/RETURN

SCREGUL,ISZ	COLUMN			/BUMP TO NEXT COLUMN
	JMP I	SCRPOS			/RETURN

/	********

/	HANDLER FOR LEFT ARROW KEY IN SETUP ROUTINE.

MOVLEFT,.-.				/MOVE BACK ONE POSITION ROUTINE
	DCA	LCHAR			/SAVE OUR CHARACTER FOR OTHERS
	TAD	PCALLSUB/[CALLSUB+1-1]	/GET BUFFER POINTER
	DCA	XR0			/STASH THE POINTER
	CDF 	70			/GOTO OUR FIELD
	NL7777				/TRY TO BACKUP
	TAD	CCNT			/COMPARE TO CURRENT SELECT
	SPA				/SKIP IF IT CAN BACKUP
	CLA				/ELSE FORGET IT
	DCA	CCNT			/SAVE NEW POSITION
	JMS	LOC36			/LOCATE NEW DELIMITER
	JMP I	MOVLEFT			/RETURN

/	********

/	HANDLER FOR RIGHT ARROW KEY IN SETUP ROUTINE.

MOVRITE,.-.				/MOVE FORWARD ONE POSITION ROUTINE
	DCA	LCHAR			/SAVE OUR CHARACTER FOR OTHERS
	TAD	CCNT			/GET CURRENT POSITION
	TAD	M31/(-31)		/COMPARE TO UPPER LIMIT
	SPA CLA				/SKIP IF TOO FAR
	ISZ	CCNT			/ELSE BUMP TO NEXT
	JMS	LOC36			/LOCATE NEW DELIMITER
	JMP I	MOVRITE			/RETURN
/	********

/	THIS ROUTINE  LOCATES  DELIMITER  (36  OR  37)  CODES  IN  THE  BUFFER.   CCNT
/	DETERMINES HOW MANY.

LOC36,	.-.				/DELIMITER SEARCH ROUTINE
	DCA	ROW			/CLEAR ROW
	DCA	COLUMN			/CLEAR COLUMN
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/BUFFER POINTER
	DCA	XR1			/CLEAR CHARACTER COUNTER
SRCHLUP,TAD I	XR0			/GET A CHARACTER
	MQL				/STASH IT THERE
	CLA MQA				/GET IT BACK
	TAD	Z7741/[-37]		/COMPARE TO 37 CODE
	SNA				/SKIP IF OTHER
	JMP	IS37			/JUMP IF IT MATCHES
	IAC				/COMPARE TO 36 CODE
	SZA CLA				/SKIP IF IT MATCHES
	JMP	NOTOURS			/JUMP IF NOT
IS37,	TAD	XR1			/GET CHARACTER COUNT
	CIA				/INVERT FOR TEST
	TAD	CCNT			/COMPARE TO LIMIT
	SZA CLA				/SKIP IF SEARCHED ENOUGH
	JMP	ISOURS			/JUMP IF NOT
	ISZ	COLUMN			/BUMP TO NEXT COLUMN
	JMS	CUPDATE			/PLACE CURSOR THERE
	JMP I	LOC36			/RETURN

ISOURS,	ISZ	XR1			/BUMP CHARACTER COUNT
NOTOURS,JMS	SCRPOS			/ADVANCE SCREEN POSITION
	JMP	SRCHLUP			/KEEP GOING

/	********

CUPDATE,.-.				/CURSOR UPDATE ROUTINE
	TAD	L2030/(2030)		/GET VERTICAL CURSOR REGISTER VALUE
	LSCREG				/LOAD REGISTER SELECT
	CLA				/CLEAN UP
	TAD	ROW			/GET CURRENT ROW
	VLOAD				/LOAD CURSOR VERTICAL POSITION
	CLA				/CLEAN UP
	TAD	L31/(31)		/GET HORIZONTAL CURSOR REGISTER VALUE
	LSCREG				/LOAD REGISTER SELECT
	CLA				/CLEAN UP
	TAD	COLUMN			/GET CURRENT COLUMN
	VLOAD				/LOAD CURSOR HORIZONTAL POSITION
	CLA				/CLEAN UP
	JMP I	CUPDATE			/RETURN

	ZBLOCK	7			/EMPTY SPACE
	PAGE

/	********

PCUPDAT,CUPDATE				/POINTER TO CURSOR UPDATE ROUTINE

/	HANDLER FOR REMOVE KEY IN SETUP ROUTINE.

BOOTIT,	.-.				/REMOVE KEY ROUTINE
	CLA				/CLEAN UP
	JMS I	AVIDCLR/(VIDCLR)	/CLEAR VIDEO DATA
	CDF	70			/GOTO OUR FIELD
	DCA	ROW			/CLEAR ROW
	DCA	COLUMN			/CLEAR COLUMN
	JMS I	PCUPDATE/(CUPDATE)	/UPDATE CURSOR POSITION
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/DATA POINTER
	NL7775				/SETUP THE
	DCA	XR1			/DATA COUNTER
LOOKLP,	TAD I	XR0			/GET A WORD
	TAD	Z7776/[7776]		/COMPARE TO VALIDATION FIELD DELIMITER
	SZA CLA				/SKIP IF IT MATCHES
	JMP	LOOKLP			/ELSE KEEP GOING
	ISZ	XR1			/FOUND ENOUGH OF THEM?
	JMP	LOOKLP			/NO, KEEP GOING
PLUP,	TAD I	XR0			/GET A CHARACTER
	MQL				/LOAD FOR PRINTING ROUTINE
	CLA MQA				/GET IT BACK
	TAD	Z7775/[-3]		/COMPARE TO MESSAGE END CHARACTER
	SNA CLA				/SKIP IF NOT THERE YET
	JMP	PEND			/JUMP IF AT END
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	PLUP			/KEEP GOING

PEND,	JMS I	PKBDIN/[KBDIN]		/GET A KEYBOARD CHARACTER
	TAD	L7603/(-175)		/COMPARE TO VALUE FOR DO KEY
	SNA CLA				/SKIP IF IT DOESN'T MATCH
	JMP I	PRXOK/(RXOK)		/JUMP IF IT DOES
	DCA	CCNT			/CLEAR POSITION COUNT
	JMS I	AVIDCLR/(VIDCLR)	/CLEAR VIDEO DATA
	ISZ	BOOTIT			/TAKE SKIP RETURN
	JMP I	BOOTIT			/RETURN TO COMMAND ROUTINE

L7603,	-175				/CONSTANT 7603
PRXOK,	RXOK				/POINTER TO RXOK ROUTINE
C23,	23				/CONSTANT 0023
AVIDCLR,VIDCLR				/POINTER TO VIDEO CLEAR ROUTINE
/	********

/	HANDLER FOR DO KEY IN SETUP ROUTINE.

DOKEY,	.-.				/DO KEY ROUTINE
	DCA	LCHAR			/SAVE CHARACTER VALUE FOR OTHERS
	TAD	C23/(23)		/SETUP FOR THE
	DCA	ROW			/HIGHEST ROW
	DCA	COLUMN			/CLEAR COLUMN
	TAD	CM5/(-5)		/SETUP THE
	DCA	XR1			/ROW COUNT
P1LUP,	TAD	M120/(-120)		/SETUP THE
	DCA	XR2			/COLUMN COUNT
P2LUP,	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	ISZ	XR2			/DONE A LINE YET?
	JMP	P2LUP			/NO, KEEP GOING
	DCA	COLUMN			/YES, CLEAR COLUMN
	ISZ	ROW			/BUMP TO NEXT ROW
	ISZ	XR1			/DONE ENOUGH ROW?
	JMP	P1LUP			/NO, KEEP GOING
	TAD	PCALLSUB/[CALLSUB+1-1]	/SETUP THE
	DCA	XR0			/DATA POINTER
FNDIT,	TAD	Z7775/[-3]		/GET DELIMITER VALUE
	TAD I	XR0			/COMPARE TO LATEST
	SZA CLA				/SKIP IF IT MATCHES
	JMP	FNDIT			/ELSE KEEP GOING
	ISZ	XR0			/BUMP PAST DELIMITER
	TAD	C23/(23)		/SETUP FOR
	DCA	ROW			/HIGHEST ROW
	DCA	COLUMN			/CLEAR COLUMN
PNEXT,	TAD I	XR0			/GET A CHARACTER
	MQL				/LOAD FOR PRINTING
	CLA MQA				/GET IT BACK
	TAD	Z7775/[-3]		/COMPARE TO DELIMITER
	SNA CLA				/SKIP IF NOT THERE YET
	JMP	ATEND			/JUMP IF AT END OF BLURB
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	PNEXT			/KEEP GOING

ATEND,	JMS I	PKBDIN/[KBDIN]		/GET A KEYBOARD CHARACTER
	CIA				/INVERT IT
	TAD	LCHAR			/COMPARE TO OUR VALUE (DO KEY)
	SNA CLA				/SKIP IF OTHER
	JMP	DOIT			/JUMP IF IT MATCHES
BMPRET,	JMS I	AVIDCLR/(VIDCLR)	/CLEAR VIDEO DATA
NOCRET,	ISZ	DOKEY			/BUMP RETURN ADDRESS
	JMP I	DOKEY			/TAKE SKIP RETURN ON USER ABORT
DOIT,	TAD	PWRIBUFF/[WRIBUFFER+1-1]/SETUP THE
	DCA	XR0			/DATA POINTER
	NL002A				/SETUP 12-BIT EMPTY SILO COMMAND VALUE
	DCA	RXCMD			/STASH THE COMMAND
	CDF	30			/GOTO DATA FIELD
/	CLA				/SET AC T0 1-1 FOR FIRST SECTOR
	JMS I	LFREAD/(FREAD)		/CALL FLOPPY READ ROUTINE
	-1-1				/WANT ONE SECTOR
L116,	116				/TRACK 78
	JMP	NOCRET			/COULDN'T DO IT, FORGET IT
	TAD	PWRIBUFF/[WRIBUFFER+1-1]/GET BUFFER POINTER
	IAC				/MOVE TO NEXT POSITION
	DCA	XR0			/STASH THE POINTER
	CDF	30			/GOTO BUFFER FIELD
	JMS I	ASLCHECK/(SLCHECK)	/ENSURE SLUSHWARE IS VALID
	JMP	SLUBAD			/FORGET IT, BAD SLUSHWARE
	DCA	XR0			/SETUP POINTER TO 0001
	JMS I	PPARMOVE/(PARMOVE)	/MOVE IN THE NEW PARAMETERS
/	CLA				/SET 12-BIT FILL VALUE
	LCD				/LOAD THE COMMAND FOR FILLING
LODLUP,	JMS I	LRXWAIT/(RXWAIT)	/CALL RX50 WAIT ROUTINE
	JMP	LDTRANS			/TRANSFER FLAG CAME UP
	JMP	LDDONE			/DONE FLAG CAME UP
	JMP I	PFERR/(FERR)		/ERROR, GO COMPLAIN THERE

LDTRANS,CDF	30			/GOTO BUFFER FIELD
	TAD I	XR0			/GET A WORD
	XDR				/FILL IT
	JMP	LODLUP			/KEEP GOING

LDDONE,	TAD	L116/(116)		/SETUP TRACK 78
	DCA	T1			/STASH IT
	NL0001 CLL			/SETUP THE
	DCA	TINC			/SECTOR NUMBER
	NL0004				/SET WRITE FUNCTION
	CDF	70			/BACK TO OUR FIELD
	JMS I	PRXCOMD/[RXCOMD]	/GO DO THE WRITE COMMAND
	SKP				/SKIP IF IT WAS OK
	JMP	BMPRET			/JUMP IF NOT
	SER				/ANY ERRORS?
	SKP				/SKIP IF NOT
	JMP	BMPRET			/JUMP IF SO
SLUBAD,	ISZ	DOKEY			/TAKE THE
	ISZ	DOKEY			/DOUBLE-SKIP
	JMP I	DOKEY			/RETURN

ASLCHEC,SLCHECK				/POINTER TO SLUSHWARE VALIDATION ROUTINE
LFREAD,	FREAD				/POINTER TO FREAD ROUTINE
CM5,	-5				/CONSTANT 7773 
M120,	-120				/CONSTANT 7660
PPARMOV,PARMOVE				/POINTER TO PARAMETER MOVE ROUTINE
LRXWAIT,RXWAIT				/POINTER TO RX50 WAIT ROUTINE
PFERR,	FERR				/POINTER TO ERROR ROUTINE
	PAGE

/	********

/	HANDLER FOR METRONOME CHARACTER IN SETUP ROUTINE.

METRONO,.-.				/METRONOME KEY ROUTINE
	CLA				/CLEAN UP
	TAD	LCHAR			/GET PREVIOUS CHARACTER
	JMP I	.+1/(METRENTRY)		/GO THERE
	METRENTRY			/THROUGH HERE

LVIDCLR,VIDCLR				/POINTER TO VIDEO CLEAR ROUTINE

/	********

/	HANDLER FOR RETURN CHARACTER IN SETUP ROUTINE.

RETURN,	.-.				/RETURN KEY ROUTINE
	JMS I	LVIDCLR/(VIDCLR)	/CLEAR VIDEO OUT
	JMS	PARMOVE			/SETUP THE PARAMETERS
	ISZ	RETURN			/TAKE THE
	ISZ	RETURN			/DOUBLE-SKIP
	JMP I	RETURN			/RETURN

/	********

A14,	24				/POINTER TO 0024
A15,	25				/POINTER TO 0025
A16,	26				/POINTER TO 0026

PARMOVE,.-.				/PARAMETER MOVE ROUTINE
	CDF	00			/SETUP DATA FIELD
	TAD	TEMP2			/GET SECOND PARAMETER
	DCA I	A15/(0025)		/STORE IT
	TAD	TEMP1			/GET FIRST PARAMETER
	DCA I	A14/(0024)		/STORE IT
	TAD	TEMP3			/GET THIRD PARAMETER
	DCA I	A16/(0026)		/STORE IT
	CDF	70			/BACK TO OUR FIELD
	DCA	XR0			/SETUP SOURCE POINTER
	TAD	PWRIBUFF/[WRIBUFFER+1-1]/SETUP THE
	DCA	XR1			/DESTINATION POINTER
	ISZ	XR1			/BUMP PAST HEADER
	TAD	M377/(-377)		/SETUP THE
	DCA	MVCNT			/MOVE COUNTER
MVLUP,	CDF	00			/GOTO DATA FIELD
	TAD I	XR0			/GET A WORD
	CDF	30			/GOTO BUFFER FIELD
	DCA I	XR1			/PUT A WORD
	ISZ	MVCNT			/DONE ENOUGH?
	JMP	MVLUP			/NO, GO BACK
	TAD	PWRIBUFF/[WRIBUFFER+1-1]/SETUP THE
	DCA	XR0			/DISK DATA POINTER
	JMP I	PARMOVE			/RETURN
MVCNT,	.-.				/MOVE COUNTER
M377,	-377				/CONSTANT 7401
BAUD17,	17				/CONSTANT 0017

/	COMES HERE AFTER  TESTING THE KEYBOARD (OR JUST AFTER THE TEST WAS BYPASSED IF
/	APTEN IS IN EFFECT) TO SETUP THE COMMUNICATIONS CHIP.

COMTEST,TAD	BAUD17/(17)		/GET BAUD RATE VALUE FOR 19200 BAUD
	MSB				/SETUP COMMUNICATIONS CHIP RATE
	CLA				/CLEAN UP
	MPRESET				/RESET THE COMMUNICATIONS CHIP
	APTSKP				/AUTOMATIC PRODUCT TESTING?
	SKP				/SKIP IF NOT
	JMP	TESTCOM			/JUMP IF SO
COMEXIT,TAD	Z7/[7]			/GET 1200 BAUD RATE VALUE
	MSB				/SETUP COMM CHIP FOR 1200 BAUD
	CLA				/CLEAN UP
	JMS I	PREGINIT/(REGINIT)	/INITIALIZE THE REGISTERS
	JMP I	.+1/(COMDONE)		/GO BACK TO MAIN-LINE CODE
	COMDONE				/THROUGH HERE

PREGINI,REGINIT				/POINTER TO REGISTER INITIALIZATION ROUTINE

TESTCOM,JMS I	PREGINIT/(REGINIT)	/INITIALIZE THE REGISTERS
	DCA	TM0			/CLEAR OUTPUT TEST VALUE
	DCA	COMTM1			/CLEAR INPUT TEST VALUE
	DCA	T6			/CLEAR LOW-ORDER TIME-OUT COUNTER
	TAD	Z7741/[-37]		/SETUP THE
	DCA	T7			/HIGH-ORDER TIME-OUT COUNTER
	CDF	00			/SET EVEN FIELD TO ACCESS "A" SIDE
	OLS				/OUTPUT A NULL CHARACTER
	CDF	70			/BACK TO OUR FIELD
	ISZ	TM0			/BUMP OUTPUT VALUE
COMWAIT,ISF				/COMMUNICATIONS PORT FLAG UP?
	SKP				/SKIP IF NOT
	JMP	COMCHK			/JUMP IF SO
	ISZ	T6			/WAITING TOO LONG?
	JMP	COMWAIT			/NO, KEEP TRYING
	ISZ	T7			/WAITING TOO MANY TIMES?
	JMP	COMWAIT			/NO, KEEP TRYING
COMBAD,	TAD	L100/(100)		/GET COMMUNICATIONS PORT ERROR BIT
	TAD	ESTATUS			/UPDATE CUMULATIVE ERROR STATUS
	DCA	ESTATUS			/STORE BACK
	JMP	COMEXIT			/STOP TESTING
COMCHK,	JMS I	PCOMREAD/[COMREAD]	/READ CONTENTS OF
	B^10+2				/REGISTER 2B
	AND	Z17/[17]		/JUST LOW-ORDER BITS AFFECTING "A" HALF
	TAD	M6/(-6)			/RECEIVE CHARACTER AVAILABLE?
	SZA				/SKIP IF AS EXPECTED
	JMP	CCHKMORE		/JUMP IF NOT
	CDF	00			/NEED EVEN FIELD TO ACCESS "A" SIDE
	IRB				/GET THE CHARACTER
	CDF	70			/BACK TO OUR FIELD
	AND	Z377/[377]		/JUST DATA BITS
	CIA				/INVERT FOR COMPARISON
	TAD	COMTM1			/COMPARE TO EXPECTED VALUE
	SNA CLA				/SKIP IF DIFFERENT
	JMP	CREADOK			/JUMP IF IT MATCHES
	JMS I	PCOMLOAD/[COMLOAD]	/CALL REGISTER LOAD ROUTINE
	A^10+0				/REGISTER 0A
	030				/CHANNEL RESET
	JMP	COMBAD			/FORGET IT

CREADOK,ISZ	COMTM1			/BUMP INPUT TEST VALUE
	TAD	COMTM1			/GET THE VALUE
	AND	Z400/[400]		/JUST TOO-FAR BIT
	SZA CLA				/SKIP IF STILL GOING	
	JMP	COMEXIT			/JUMP IF FINISHED
CINTCLR,JMS I	PCOMLOAD/[COMLOAD]	/CALL REGISTER LOAD ROUTINE
	A^10+0				/0A
	070				/END OF INTERRUPT
	JMP	COMWAIT			/GO BACK FOR MORE

CCHKMOR,TAD	L2/(-4+6)		/TRANSMITTER BUFFER EMPTY?
	SZA CLA				/SKIP IF IT MATCHES
	JMP	COMBAD			/JUMP IF NOT
	TAD	TM0			/GET OUTPUT TEST VALUE
	AND	Z400/[400]		/JUST TOO-FAR BIT
	SNA CLA				/SKIP IF NOW TOO FAR
	JMP	OUTMORE			/JUMP IF NOT
	JMS I	PCOMLOAD/[COMLOAD]	/CALL REGISTER LOAD ROUTINE
	A^10+0				/0A
	050				/CLEAR TRANSMITTER INTERRUPT
	JMP	CINTCLR			/CONTINUE THERE

OUTMORE,TAD	TM0			/GET OUTPUT VALUE
	CDF	00			/SET EVEN FIELD TO ACCESS "A" HALF
	OLS				/OUTPUT THE CHARACTER
	CDF	70			/BACK TO OUR FIELD
	CLA				/CLEAN UP
	ISZ	TM0			/BUMP TEST VALUE
	JMP	CINTCLR			/CONTINUE THERE

L100,	100				/CONSTANT 0100
M6,	-6				/CONSTANT 7772
L2,	-4+6				/CONSTANT 0002

	ZBLOCK	3			/EMPTY SPACE
	PAGE

/	RD TEST  AND  SETUP  ROUTINE.  CHECKS IF RD51 HARDWRE IS PRESENT.  IF PRESENT,
/	WILL WAIT MAY SECONDS UNTIL THE SELF-TEST FINISHES AND RAISES THE DONE FLAG OR
/	IT TIMES  OUT.    THEN  THE  STARTUP  SECTOR  IS  READ  IN  AND  EXECUTED AS A
/	SUBROUTINE LOADED IN A DESIGNATED PLACE.

RDSETUP,.-.				/RD TEST AND SETUP ROUTINE
	NL7777				/SET TEST PATTERN
	RDTEST				/DO TEST IOT THAT SHOULD CLEAR THE AC
	SZA CLA				/SKIP IF RD51 HARDWARE ACTUALLY PRESENT
	JMP I	RDSETUP			/ELSE JUST RETURN
	TAD	M12/(-12)		/GET OUTER TIME-OUT CONSTANT
	DCA	T8			/STASH THE OUTER COUNTER
RDWLP1,	TAD	M30/(-30)		/GET MIDDLE TIME-OUT CONSTANT
	DCA	T7			/STASH THE MIDDLE COUNTER
RDWLP2,	RDSD				/DONE FLAG SET FROM SELF-TEST?
	SKP				/SKIP IF NOT
	JMP	RDFIN			/JUMP IF SO
	ISZ	T6			/WAIT AWHILE?
	JMP	RDWLP2			/KEEP WAITING
	ISZ	T7			/WAITED ENOUGH?
	JMP	RDWLP2			/KEEP GOING
	ISZ	T8			/WAITED TOO LONG?
	JMP	RDWLP1			/NO, KEEP GOING
	JMP I	RDSETUP			/YES, JUST RETURN

RDFIN,	RDSE				/ANY ERRORS?
	SKP				/SKIP IF NOT
	JMP I	RDSETUP			/JUST RETURN
	TAD	PCALLSUB/[CALLSUB+1-1]	/SETUP THE
	DCA	XR0			/STORAGE POINTER
	TAD	L32/(32)		/GET READ STARTUP SECTOR COMMAND
	RDSC				/SEND THE COMMAND
DTRLUP,	JMS	RDWAIT			/WAIT FOR FLAGS
	JMP I	RDSETUP			/ERROR OR TIME-OUT, FORGET IT
	SKP				/TRANSFER REQUEST UP
	JMP	SSDONE			/JUMP THERE IF DONE
	RDTD				/TRANSFER DATA
	DCA I	XR0			/STORE THE WORD IN THE SUBROUTINE BODY
	JMP	DTRLUP			/KEEP GOING

SSDONE,	TAD	PCALLSUB/[CALLSUB+1-1]	/SETUP THE POINTER
	DCA	XR0			/TO THE READ-IN DATA
	TAD	PTSTDATA/(TSTDATA-1)	/SETUP THE TEST DATA POINTER
	DCA	XR1			/STASH THE POINTER
TSTLUP,	TAD I	XR1			/GET AN INVERTED TEST VALUE
	SNA				/SKIP IF NOT AT END OF LIST
	JMS I	PCALLSUB/[CALLSUB]	/CALL THE READ-IN CODE
	TAD I	XR0			/COMPARE TO READ-IN VALUE
	SZA CLA				/SKIP IF IT MATCHES
	JMP I	RDSETUP			/RETURN IF NOT
	JMP	TSTLUP			/KEEP TESTING
M30,	-30				/MIDDLE TIME-OUT CONSTANT
L32,	32				/CONSTANT 0032
M12,	-12				/OUTER TIME-OUT CONSTANT

	6				/AN UNUSED CONSTANT 0006

PTSTDAT,TSTDATA-1			/POINTER TO TEST DATA TABLE (-1)

/	TEST CONTENTS OF CALLABLE  SUBROUTINE.    ALL VALUES ARE INVERTED.  THE ACTUAL
/	READ-IN CODE IS EXECUTABLE AS AND INSTRUCTIONS.

TSTDATA,-1
	-"R!200
	-"D!200
	-"5!200
	-"1!200
	-2
	0				/THIS ENDS THE LIST

/	RD51 WAIT ROUTINE.    TAKES IMMEDIATE RETURN ON ERROR OR TIME-OUT;  TAKES SKIP
/	RETURN ON TRANSFER REQUEST FLAG; TAKES DOUBLE-SKIP RETURN ON DONE FLAG.

RDWAIT,	.-.				/RD51 WAIT ROUTINE
	TAD	DTIMOUT/[-DTIME]	/SETUP THE
	DCA	T7			/TIME-OUT COUNTER
	DCA	T6			/CLEAR INNER TIME-OUT COUNTER
RDWATLP,RDSR				/DATA REQUEST FLAG UP?
	SKP				/SKIP IF NOT
	JMP	RDTRAN			/JUMP IF SO
	RDSD				/DONE FLAG UP?
	SKP				/SKIP IF NOT
	JMP	RDDONE			/JUMP IF SO
	ISZ	T6			/WAITED ENOUGH?
	JMP	RDWATLP			/NO, KEEP GOING
	ISZ	T7			/WAITING TOO LONG?
	JMP	RDWATLP			/NO, KEEP GOING
	JMP I	RDWAIT			/YES, TAKE IMMEDIATE RETURN

RDDONE,	RDSE				/ANY ERRORS?
	SKP				/SKIP IF NOT
	JMP I	RDWAIT			/TAKE IMMEDIATE RETURN IF SO
	ISZ	RDWAIT			/TAKE DOUBLE-SKIP RETURN ON DONE FLAG RAISE
RDTRAN,	ISZ	RDWAIT			/TAKE SKIP RETURN ON TRANSFER FLAG RAISE
	JMP I	RDWAIT			/RETURN EITHER WAY
/	MPSCC REGISTER READ ROUTINE.  CALLED WITH IN-LINE  ARGUMENT  OF EVEN/ODD FIELD
/	IN  BITS[6-8]  AND  SPECIFIED  REGISTER IN BITS[9-11].  THE  CONTENTS  OF  THE
/	SPECIFIED REGISTER ARE RETURNED IN THE AC.

COMREAD,.-.				/MPSCC CHIP REGISTER READ ROUTINE
	TAD I	COMREAD			/GET THE IN-LINE ARGUMENT
	ISZ	COMREAD			/BUMP PAST IT
	DCA	CTMP1			/SAVE IT
	TAD	CTMP1			/GET IT BACK
	AND	L70/(70)		/JUST FIELD BITS
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
	TAD	CTMP1			/GET ARGUMENT AGAIN
	AND	Z7/[7]			/JUST REGISTER BITS
	TAD	L4000/(4000)		/ADD ON READ ACCESS BIT
	MPSCC				/SETUP TO READ THE SPECIFIED REGISTER
	CLA				/CLEAN UP
	MPSCC				/READ THE REGISTER
	CDF	70			/BACK TO OUR FIELD
	JMP I	COMREAD			/RETURN

L4000,	4000				/CONSTANT 4000

/	MPSCC REGISTER LOAD ROUTINE.  CALLED  WITH IN-LINE ARGUMENTS OF EVEN/ODD FIELD
/	IN  BITS[6-8]  AND SPECIFIED REGISTER IN BITS[9-11]  OF  THE  FIRST  ARGUMENT,
/	FOLLOWED BY VALUE TO LOAD INTO THE SPECIFIED REGISTER IN THE SECOND ARGUMENT.

COMLOAD,.-.				/COMMUNICATIONS CHIP REGISTER LOAD ROUTINE
	CLA				/CLEAN UP
	TAD I	COMLOAD			/GET THE FIRST ARGUMENT
	ISZ	COMLOAD			/BUMP PAST IT
	DCA	CTMP1			/STASH IT
	TAD I	COMLOAD			/GET THE SECOND ARGUMENT
	ISZ	COMLOAD			/BUMP PAST IT
	DCA	CTMP2			/STASH IT
	TAD	CTMP1			/GET THE FIRST ARGUMENT
	AND	L70/(70)		/JUST FIELD BITS
	TAD	ZCDF/[CDF]		/FORM CDF INSTRUCTION
	DCA	.+1			/STORE IN-LINE
	HLT+.-.				/WILL BE CDF XX INSTRUCTION
	TAD	CTMP1			/GET THE FIRST ARGUMENT AGAIN
	AND	Z7/[7]			/JUST REGISTER BITS
	SZA				/DON'T NEED TO POINT IF ACCESSING REGISTER 0
	MPSCC				/POINT TO DESIRED REGISTER NEXT TIME
	CLA				/CLEAN UP
	TAD	CTMP2			/GET THE NEW REGISTER CONTENTS
	MPSCC				/LOAD THE NEW VALUE
	CLA				/CLEAN UP
	CDF	70			/BACK TO OUR FIELD
	JMP I	COMLOAD			/RETURN TO CALLER

L70,	70				/CONSTANT 0070

	ZBLOCK	11			/EMPTY SPACE
	PAGE

/	RX50 READ COMMAND  ROUTINE.  THE COMMAND (TYPICALLY 0006 FOR A READ) IS PASSED
/	IN THE AC.  THE SECTOR IS IN TINC, AND THE TRACK IN T1.  TAKE IMMEDIATE RETURN
/	IF THE COMMAND SUCCEEDS;  TAKE SKIP RETURN IF IT TIMES OUT.

RXCOMD,	.-.				/RX50 READ COMMAND ROUTINE
	LCD				/LOAD PASSED COMMAND
	TAD	TINC			/GET THE SECTOR
	STR				/TRANSFER FLAG UP?
	JMP	.-1			/NO, WAIT FOR IT
	XDR				/YES, SEND THE SECTOR
	CLA				/CLEAN UP
	TAD	T1			/GET THE TRACK
	STR				/TRANSFER FLAG UP?
	JMP	.-1			/NO, WAIT FOR IT
	XDR				/YES, SEND THE TRACK
	CLA				/CLEAN UP
	TAD	DTIMOUT/[-DTIME]	/SETUP THE
	DCA	T6			/TIME-OUT COUNTER
	DCA	T7			/CLEAR INNER TIME-OUT COUNTER
DNWAIT,	SDN				/DONE FLAG UP?
	SKP				/SKIP IF NOT
	JMP I	RXCOMD			/TAKE SUCCESSFUL RETURN IF SO
	ISZ	T7			/WAITING LONG ENOUGH?
	JMP	DNWAIT			/NO, KEEP WAITING
	ISZ	T6			/WAITING TOO LONG?
	JMP	DNWAIT			/NO, KEEP WAITING
	ISZ	RXCOMD			/BUMP TO FAILURE RETURN
	JMP I	RXCOMD			/TAKE SKIP RETURN TO CALLER
REGINIT,.-.				/REGISTER INITIALIZE ROUTINE
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	A^10+0				/0A
	030				/CHANNEL RESET
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	B^10+0				/0B
	030				/CHANNEL RESET
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	A^10+2				/2A
	020				/LOW-ORDER BITS ARE AFFECTED, NO DMA
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	B^10+2				/2B
	000				/INTERRUPT VECTOR IS ALL ZEROES
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	A^10+4				/4A
	104				/16X CLOCK RATE, 1 STOP BIT ASYNCHRONOUS
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	A^10+1				/1A
	022				/RECEIVE AND TRANSMIT INTERRUPT ENABLE
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	B^10+1				/1B
	004				/CONDITION AFFECTS VECTOR, NO B INTERRUPTS
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	A^10+3				/3A
	301				/8 BITS, ENABLE RECEIVER
	JMS I	PCOMLOAD/[COMLOAD]	/LOAD REGISTER
	A^10+5				/5A
	150				/8 BITS, ENABLE TRANSMITTER
	JMP I	REGINIT			/RETURN
/	********

PRINTP,	.-.				/SIX PARAMETERS PRINT ROUTINE
	CDF	70			/RESET TO OUR FIELD
	DCA	ROW			/CLEAR COLUMN
	DCA	COLUMN			/CLEAR COLUMN
	TAD	PCALLSUB/[CALLSUB]	/SETUP THE
	DCA	XR0			/DATA POINTER
	TAD	L7772/(-6)		/SETUP THE
	DCA	XR1			/PARAMETER COUNT
	TAD	PTM0/(TM0-1)		/SETUP THE
	DCA	PADR			/PARAMETER ADDRESS
HDLOOP,	TAD I	XR0			/GET A WORD
	TAD	Z7776/[7776]		/COMPARE TO MESSAGE END
	SZA CLA				/SKIP IF IT MATCHES
	JMP	HDLOOP			/ELSE GO BACK
PRLOOP,	TAD I	XR0			/GET A CHARACTER
	MQL				/LOAD IT FOR PRINTING
	CLA MQA				/GET IT BACK
	TAD	Z7741/[-37]		/COMPARE TO DELIMITER
	SNA				/SKIP IF OTHER
	JMP	ATDEL			/JUMP IF A MATCH
	IAC				/COMPARE TO ALTERNATE DELIMITER VALUE
	SNA				/SKIP IF OTHER
	JMP	ATDEL			/JUMP IF A MATCH
	TAD	L4/(4)			/COMPARE TO END OF DATA VALUE
	SNA CLA				/SKIP IF OTHER
	JMP I	PRINTP			/RETURN IF IT MATCHES
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	JMP	PRLOOP			/KEEP GOING

ATDEL,	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	TAD	XR1			/GET PARAMETER COUNT
	SNA CLA				/SKIP IF NOT DONE
	JMP	PRLOOP			/JUST PRINT THE FIELD
	ISZ	XR1			/COUNT THIS ONE
	NOP				/IN CASE IT SKIPS
	ISZ	PADR			/BUMP TO NEXT ADDRESS
	TAD	M4/(-4)			/SETUP THE
	DCA	XR2			/DIGIT COUNTER
	TAD I	PADR			/GET THE VALUE
	DCA	DIGTMP			/STASH IT
DIGLUP,	TAD	DIGTMP			/GET VALUE BACK
	R3L				/MOVE UP
	DCA	DIGTMP			/STORE IT BACK
	TAD	DIGTMP			/GET IT AGAIN
	AND	Z7/[7]			/JUST LATEST DIGIT
	TAD	L60/("0&177)		/MAKE IT ASCII
	MQL				/STASH IT
	JMS I	PCHRPRT/[CHRPRT]	/PRINT THE CHARACTER
	ISZ	XR2			/DONE ALL DIGITS YET?
	JMP	DIGLUP			/NO, KEEP GOING
	JMP	PRLOOP			/KEEP GOING
/	*********

L4,	4				/CONSTANT 0004
M4,	-4				/CONSTANT 7774
L7772,	-6				/CONSTANT 7772
L60,	"0&177				/ASCII NUMERIC CONSTANT 0060
PADR,	.-.				/PARAMETER ADDRESS TEMPORARY
DIGTMP,	.-.				/OUTPUT VALUE STORED HERE
PTM0,	TM0-1				/POINTER TO DATA BLOCK

/	RD51 TEST AND WAIT ROUTINE.  IF RD51 IS PRESENT, THEN WAIT AWHILE.

RDTWAIT,.-.				/RD51 TEST AND WAIT ROUTINE
	NL7777				/SET TEST PATTERN
	RDTEST				/AC WILL CLEAR IF RD51 IS PRESENT
	SZA CLA				/SKIP IF RD51 INSTALLED
	JMP I	RDTWAIT			/RETURN IF NOT
	TAD	M2260/(-2260)		/SETUP THE
	DCA	T6			/OUTER LOOP COUNTER
	DCA	T7			/CLEAR THE INNER LOOP COUNTER
WAITLUP,ISZ	T7			/WAIT FOR AWHILE
	JMP	WAITLUP			/KEEP WAITING
	ISZ	T6			/WAITED ENOUGH
	JMP	WAITLUP			/NO, KEEP GOING
	JMP I	RDTWAIT			/YES, RETURN TO CALLER

M2260,	-2260				/CONSTANT 5520

	ZBLOCK	4			/EMPTY SPACE
	PAGE

/	THIS ROUTINE  CHECKS  FOR  BYTES LOADED AS 0377 TO BE REPLACED WITH 4000.  THE
/	AFFECTED DATA CONSISTS OF THE FRESHLY READ-IN (IN BYTE MODE) CONTENTS OF TRACK
/	1, SECTOR 3 PAST THE VALIDATED HEADER BYTES, LOCATIONS 15360-15777 ONLY.

RUBCHK,	.-.				/377 CODE REPLACE ROUTINE
	TAD	RUBPTR/(T0S3BUFFER+10)	/SETUP THE LIST POINTER PAST THE HEADER
	DCA	VPTR			/STASH THE POINTER
VLUP,	CDF	10			/GOTO DATA FIELD
	TAD I	VPTR			/GET A WORD
	IAC				/ADD ONE
	AND	Z377/[377]		/LOW-ORDER BITS ONLY
	SZA CLA				/SKIP IF THEY WERE ALL SET
	JMP	VAROUND			/ELSE RETAIN THIS WORD
	NL4000				/GET REPLACEMENT VALUE
	DCA I	VPTR			/STORE OVER LIST ELEMENT
VAROUND,CDF	70			/BACK TO OUR FIELD
	ISZ	VPTR			/BUMP TO NEXT
	NL2000				/GET ADDRESS MASK
	AND	VPTR			/JUST QUADRANT BIT
	SNA CLA				/SKIP IF JUST FINISHED
	JMP	VLUP			/JUMP IF NOT
	JMP I	RUBCHK			/RETURN TO CALLER

RUBPTR,	T0S3BUFFER+10			/POINTER TO DATA PAST THE HEADER
VPTR,	.-.				/DATA POINTER
/	WHILE  THERE IS NO MORE ACTUAL  CODE,  THE  FOLLOWING  LINES  ARE  PRESENT  TO
/	CALCULATE  THE  MOVE  LENGTH  FOR THE CP-INTERRUPT  HANDLER  USED  DURING  THE
/	LOOPBACK TEST  IN  MAIN  MEMORY.    THIS CALCULATION IS PROBABLY INCORRECT AND
/	MOVES TOO MUCH  CODE.    THE  ONLY  POSSIBLE  PROBLEM  IS INTERACTION WITH APT
/	DOWNLOADED PROGRAM CONVENTIONS.

	ZBLOCK	.&7600+200-.		/EMPTY SPACE IN THE REST OF THE PAGE

/	THIS IS WHERE THE STARTUP SECTOR CODE IS READ IN AS A CALLED SUBROUTINE.

CALLSUB,.-.				/TEST SUBROUTINE LOCATION

	CPEND2=	.			/MOVED CP INTERRUPT HANDLER CODE ENDS HERE?

TSTBUFF,ZBLOCK	4			/KEYBOARD TEST BUFFER

	TSTBEND=.			/END OF KEYBOARD TEST BUFFER

	RELOC	6000			/EMPTY SPACE

	APTSTRT=.			/APT ROUTINE STARTS HERE

	RELOC	6400			/EMPTY SPACE

	WRIBUFF=.			/WRITE BUFFER FOR SETUP

	RELOC	6500			/EMPTY SPACE

	APTROUT=.			/APT ROUTINE LOADS HERE

	RELOC	.+20			/EMPTY SPACE

	APTRO2=	.			/SECONDARY APT ADDRESS HERE

	RELOC				/UN-FOOL THE ASSEMBLER

	ZBLOCK	ROMGO-.			/EMPTY SPACE

	$				/THAT'S ALL FOLK!