;   Diagnostic program for the
;   Versatec VAX DPC/DMA 18 bit controllers
;
	.TITLE DIAG DPC/DMA
	.SUBTITLE Diagnostic information
	.IDENT /Model 121-122 Diag Rev G/
	.PSECT	PRINTER_PLOTTER_DIAG,PAGE
;
;
;	LANGUAGE:  VAX-11 MACRO
;
;	OPERATING SYSTEM:  VAX/VMS
;
;	ORDER NUMBER:  12X-9XV
;
;	PART NUMBER:  000-025809-XXX REV. G  MAY, 1985
;
;	PRODUCT: VAX-11 DIAGNOSTIC,
;	PRODUCT: VAX/VMS DRIVER, SYMBIONT, AND OUTPUT PACKAGE
;
;	VERSATEC, INC., SANTA CLARA, CALIFORNIA 95051
;	A XEROX COMPANY
;
;	Copyright (C) 1985 by Xerox Corporation.  All rights reserved.
;
;	"NOTICE. THIS PROGRAM IS THE EXCLUSIVE PROPERTY OF VERSATEC,
;	INC. AND IS ISSUED IN STRICT CONFIDENCE UNDER A PREARRANGED
;	LICENSE AGREEMENT AND IS NOT TO BE DISCLOSED IN ANY MANNER TO
;	PERSONS OUTSIDE THE LICENSED ORGANIZATION AND SHALL NOT BE
;	REPRODUCED OR DISSEMINATED, IN WHOLE OR PART, TO ANYONE OUTSIDE
;	THE LICENSED ORGANIZATION WITHOUT THE PRIOR WRITTEN APPROVAL OF
;	VERSATEC, INC. UNLESS OTHERWISE PROVIDED FOR BY SUCH LICENSE
;	AGREEMENT.  THIS WORK IS PROTECTED AS AN UNPUBLISHED WORK UNDER
;	THE COPYRIGHT ACT OF 1976."
;
;
;****Versatec,Inc.***2805**Bowers*Ave.**Santa*Clara,Ca.*95051****
;*								*
;*	+History+						*
;*								*
;*	Date		Rev.	Init.	System: VAX		*
;*								*
;*	May 19, 1980	A	D.L.W.	Pn: 70035		*
;*								*
;*  Modified by:						*
;*								*
;*	April 6, 1981	B	D.L.W.				*
;*								*
;*	Jan. 15, 1982	C	D.L.W.				*
;*	Added code to prompt for UBA number			*
;*	Added code to support the VAX11/750.			*
;*	Removed VRC tests.					*
;*								*
;*	Jan. 10, 1983	D	D.L.W.				*
;*	Added code to support the new 122 controller		*
;*	Added code to support the new VAX11/730 processor	*
;*								*
;*	July, 1983	E	P.D.				*
;*	No changes to this module				*
;*								*
;*	July, 1984	F	B.L.				*
;*	No significant changes to this module			*
;*								*
;*	May, 1985	G	B.L.	PN: 000-025809-XXX	*
;*	No changes to this module				*
;*								*
;****************************************************************
 
;To use this diagnostic, enter the commands:
;	$ MACRO DIAG
;	$ LINK/SYSTEM=%X200 DIAG
;Then use a procedure for the specific model of VAX to put DIAG.EXE
;onto a diskette or cassette and load it and start execution at
;address 200.
 
;**********Revision letters go into four places:
;	1. In .ident pseudo op.
;	2. In update history above.
;	3. In the message with label "diag_info_mess".
;	4. On the lines of code changed or added.
;
	.PAGE
	.SUBTITLE Equates
;
;	VAX definitions
;
;
; Internal processor registers
;
PR$_KSP		=	0			;Kernal stack pointer
PR$_ESP		=	1			;Executive stack pointer
PR$_SSP		=	2			;Supervisor stack pointer
PR$_USP		=	3			;User stack pointer
PR$_ISP		=	4			;Interrupt stack pointer
PR$_SCBB	=	^X11			;System control base block
PR$_IPL		=	^X12			;Interrupt priority
PR$_ICCS	=	^X18			;Interval clock control
PR$_NICR	=	^X19			;Next interval count
PR$_TODR	=	^X1B			;Time of day
PR$_RXCS	=	^X20			;Console receive C/S
PR$_RXDB	=	^X21			;Console receive D/B
PR$_TXCS	=	^X22			;Console transmit C/S
PR$_TXDB	=	^X23			;Console transmit D/B
PR$_SBIFS	=	^X30			;SBI fault/status
PR$_SBIER	=	^X34			;SBI error
PR$_SID		=	^X3E			;System id
;
; VAX11/750 internal processor registers
;
PR$_MCSR	=	^X17			;Machine check status
PR$_MCESR	=	^X26			;Machine check summary
PR$_INUBA	=	^X37			;Unibus initialize
;
; VAX11/780 equates
;
UBA$L_CSR	=	0			;UBA configuration register
UBA$M_CSR_UBIC	=	^X10000			;UBA initialize complete bit
UBA$L_CR	=	4			;UBA control register
UBA$M_CR_INIT	=	1			;UBA init bit
UBA$M_CR_UBPF	=	2			;UBA power fail init bit
UBA$M_CR_CNFIE	=	4			;UBA configuration enable interrupt bit
UBA$M_CR_SUEFIE	=	8			;UBA error fieled interrupt bit
UBA$M_CR_USEFIE	=	^X10			;UBA error field interrupt bit
UBA$M_CR_BRIE	=	^X20			;UBA Br interrupt enable switch
UBA$M_CR_IFSIE	=	^X40			;UBA Interrupt field switch
UBA$M_CR_ALENA	=	^X78			;All of Unibus interrupt enable bits
UBA$L_SR	=	^X8			;UBA status register
UBA$M_SR_SSYNC	=	1			;Slave sync timeout bit
UBA$M_SR_CXTMO	=	^X40			;UBA command transmit timeout bit
SBIER_NEF	=	^X70C0			;Error reset bits
SBIFS_NEF	=	^X2000000		;Flag to clear errors
 
; Misc. VAX equates
;
MAX_UBAS_790	=	3			;Largest valid UBA number
MAX_UBAS_780	=	3			;Largest valid UBA number
MAX_UBAS_750	=	1			;Largest valid UBA number
MAX_UBAS_730	=	0			;Largest valid UBA number
NMB_CPUS	=	4			;Number of cpu's supported
V11780		=	1			;VAX11/780 processor
V11750		=	2			;VAX11/750 processor
V11730		=	3			;VAX11/730 processor
V11790		=	4			;VAX11/790 processor
CARRY		=	1			;Carry bit of PSW
DISABLE_CLOCK	=	^X80			;Disable interval clock
DISABL_INTR	=	^X1F			;Disable all interrupts
ENABLE_CLOCK	=	^X51			;Enable interval clock
INIT_IPL	=	^X10			;Initial priority level
INTR_DSABL	=	0			;Interrupt disable mask
INTR_ENABL	=	^X40			;Interrupt enable bit
MAP_LIMIT	=	496			;Number of map registers
UBA$M_MAP_VALID	=	^X80000000		;Valid map bit
UBA$L_MAP	=	^X800			;UBA mapping register offset
NON_730_EXIST_MEMORY	=	^X10000		;Non exisisting memory bit
NON_750_EXIST_MEMORY	=	^X10		;Non exisisting memory bit
NUMBER_VECTORS	=	128			;Number of vectors
;
;	printer/plotter definitions
;
CLEAR_BIT_121	=	4			;Remote clear bit (121)
DMABUSY_BIT_121	=	^X2000			;DMA busy bit (121)
DTC_ENABL_121	=	^X4000			;DTC interrupt enable bit (121)
EOT_BIT_121	=	^X8			;Remote EOT bit (121)
RESET_BIT_121	=	2			;Remote reset bit (121)
SPP_BIT_121	=	1			;SPP bit (121)
FORMFD_BIT_121	=	^X10			;Remote formfeed bit (121)
LNTERM_BIT_121	=	^X20			;Remote line terminate bit (121)
DMABUSY_BIT_122	=	1			;DMA busy bit (122)
LNTERM_BIT_122	=	2			;Remote line terminate bit (122)
CLEAR_BIT_122	=	4			;Remote clear bit (122)
RESET_BIT_122	=	6			;Remote reset bit (122)
FORMFD_BIT_122	=	8			;Remote formfeed bit (122)
EOT_BIT_122	=	^XA			;Remote EOT bit (122)
RESETALL_BIT_122=	^XC			;Remote reset ALL bit (122)
NULL_BIT_122	=	^XE			;Null bit (122)
SWAP_BIT_122	=	^X200			;Swap byte bit (122)
PLOT_BIT_122	=	^X400			;Print/plot mode bit (122)
PIO_BIT_122	=	^X1800			;PIO mode bits (122)
DMA_ADDR_122	=	^X800			;DMA address bit (122)
DMA_BCNT_122	=	^X1000			;DMA byte count bit (122)
SPP_BIT_122	=	^X2000			;SPP bit (122)
ALL_BITS_122	=	^X2E00			;All control bits except mode bits
ERROR_BIT	=	^X8000			;Error bit of csr (121/122)
PRINTER_ONLY	=	1			;Printer_only flag
PLOTTER_ONLY	=	2			;Plotter only flag
PRPLTR_ONLY	=	3			;Printer/plotter only flag
SPP_PLOTTER	=	4			;Printer/plotter & SPP flag
V_PRINTER_ONLY	=	0			;Printer_only bit flag
V_PLOTTER_ONLY	=	1			;Plotter only bit flag
V_PRPLTR_ONLY	=	2			;Printer/plotter only bit flag
V_SPP_PLOTTER	=	3			;Printer/plotter & SPP bit flag
REM_CLEARPR	=	1			;Remote clear print flag
REM_LNTRMPR	=	2			;Remote line terminate print
REM_FRMFDPR	=	3			;Remote formfeed print
REM_EOTPR	=	4			;Remote EOT print
REM_RESETPR	=	5			;Remote reset print
ENTER_SPPPR	=	6			;Enter SPP print
XIT_SPPPR	=	7			;Exit SPP print
PRINT_MODE	=	8			;Print mode select flag
REM_CLEARPL	=	9			;Remote clear plot
REM_LNTRMPL	=	10			;Remote line terminate plot
REM_FRMFDPL	=	11			;Remote formfeed plot
REM_EOTPL	=	12			;Remote EOT plot
REM_RESTPL	=	13			;Remote reset plot
ENTER_SPPPL	=	14			;Enter SPP plot
XIT_SPPPL	=	15			;Exit SPP plot
PLOT_MODE	=	16			;Plot data transfer
SPP_BIT_PLTR	=	26			;SPP plot select
SPP_BIT_PNTR	=	25			;SPP print select
;
;	misc. equates
;
ALL_REQUEST	=	5			;All tests request
BACK_SLASH	=	^X5C			;Back slash character
BIT_OFF_ADM	=	3			;Bit off abnormal flag
BIT_ON_ADM	=	2			;Bit on abnormal flag
BIT_5		=	^X10			;Bit 5 of long word
BLANK		=	^X20			;Blank character
CAN		=	^X018			;Cancel character
CONTROL_C	=	3			;Control c character
CONTROL_F	=	6			;Control f character
CONTROL_O	=	^X0F			;Control o character
CONTROL_R	=	^X12			;Control r character
CONTROL_U	=	^X15			;Control u character
CONTROL_Z	=	^X1A			;Control z character
CR		=	^X00D			;Carriage return
DELETE		=	^X07F			;Delete character
EOT		=	^X004			;EOT character
FF		=	^X00C			;Form feed character
LF		=	^X00A			;Line feed character
M_MANUAL_SELECT	=	1			;Auto/manual operation bit
M_DMA_SELECT	=	4			;DPC/DMA select flag bit
M_FORMFD_SELECT	=	8			;Form feed between tests flag
M_MESS_DISPLAY	=	2			;Message enable/disable flag
M_122_CONTROLLER=	1			;121/122 controller flag
V_MANUAL_SELECT	=	0			;Auto/manual operation bit
V_DMA_SELECT	=	2			;DPC/DMA select flag bit
V_FORMFD_SELECT	=	3			;Form feed between tests flag
V_MESS_DISPLAY	=	1			;Message enable/disable flag
V_122_CONTROLLER=	0			;121/122 controller flag
NORDYAF_PL	=	5			;Not ready after plot interrupt
NOINTR_PL	=	7			;No plot interrupt
NORDYAF_PR	=	4			;Not ready after print interrupt
NOINTR_PR	=	6			;No print interrupt
OFF_LINE	=	1			;Offline abnormal flag
READY_BIT	=	^X80			;Ready bit mask
RIGHT_ONE	=	-1			;Shift right one mask
	.PAGE
	.SUBTITLE Main process section
;*****************************************************
;*                                                   *
;*  The following block of code is the main process  *
;*  driver for the diagnostic. It performs the       *
;*  following functions: (in order shown)            *
;*                                                   *
;*   *  Cpu identification and setup		     *
;*   *  Controller initialization                    *
;*   *  Printer/plotter initialization               *
;*   *  Request next test		             *
;*   *  Input of test name                           *
;*   *  Verify test selection                        *
;*   *  Construction of test sequence	             *
;*   *  Test execution				     *
;*   *  Form feed between tests			     *
;*   *	Repeat tests if autmoatic		     *
;*                                                   *
;*****************************************************
	.ALIGN PAGE
START:
	MOVAL	START,SP			;Init stack pointer
	CLRB	TYPE_PRINTER			;Reset printer/plotter flags
	CLRB	DIAG_CONTROL			;Reset diagnostic control
	CLRB	TYPE_CONTROLLER			;Reset type controller
	JSB	IDENT_CPU			;Setup for correct processor
	CALLG	DIAG_INFO_MESS,CONSOL_OUT	;Announce diagnostic to user
	MTPR	#SCB,#PR$_SCBB			;Init system control block base
RE_START:
	MTPR	#INIT_IPL,#PR$_IPL		;Init priority level
	CLRB	TYPE_PRINTER			;Reset printer/plotter flags
	CLRB	DIAG_CONTROL			;Reset diagnostic control
	CLRB	TYPE_CONTROLLER			;Reset type controller
	MOVAL	START,SP			;Reset stack
	MTPR	#START,#PR$_KSP			;Init kernal stack pointer
	MTPR	#START,#PR$_ISP			;Init interrupt stack pointer
	JSB	CONTROLLER_INIT			;Configure controller
	JSB	PRINTER_PLOTTER_INIT		;Configure printer/plotter
REQT1:
	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupts
	BICB	#M_MESS_DISPLAY,DIAG_CONTROL	;Enable message display
	CALLG	OPIN1,RQEST			;Select next test
	JSB	NAME_CHECK			;Verify test selected
	BCS	REQT1				;Error get test again
	MOVL	FIRST_TEST,CURNT_TEST		;Set addr. of test to execute
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupts
LOOP1:
	MOVL	CURNT_TEST,R2			;Get address of test
	JSB	@(R2)				;Execute test
LOOP2:
	TSTB	TYPE_TEST			;Was it a controler test?
	BEQL	10$				;Yes don't form feed
5$:
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,10$	;Form feed between tests?
	JSB	PRINT_RFMD			;Issue a remote form feed
10$:
	CMPL	CURNT_TEST,LAST_TEST		;More tests to execute?
	BEQL	15$				;No check for manual or auto
	ADDL	#4,CURNT_TEST			;Update test pointer
	BRB	LOOP1				;Execute next test
15$:
	BBS	#V_MANUAL_SELECT,DIAG_CONTROL,20$	;Manual test mode?
	BRW	REQT1				;Get new test sequence
20$:
	MOVL	NEXT_TEST,CURNT_TEST		;Reset test sequence
	BRB	LOOP1				;Repeat tests
	.PAGE
	.SUBTITLE Controller tests
	.SUBTITLE Test 1  - Ready and error bit test
;********************************************************
;* Controller test #1					*
;*							*
;* This test determines if the ready and error bits	*
;* are operational. The folowing steps take place:	*
;*							*
;* 1. Message is sent to console requesting user to	*
;*    power down the printer/plotter.			*
;*							*
;* 2. If the ready bit is off and the error bit is	*
;*    on, the bits are operational in the off mode.	*
;*							*
;* 3. Message is sent to console requesting user to	*
;*    power up printer/plotter				*
;*							*
;* 4. If the ready bit is on and the error bit is	*
;*    off, the bits are operational in the power mode.	*
;********************************************************
CON1:
	CALLG	COM1,CONSOL_OUT			;Output test message
5$:	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupts
	CALLG	OPIN2,CONSOL_OUT		;Output message
	CALLG	OPIN7,RQEST			;Request printer/plotter shutdown
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupts
	MOVL	PRINT_CSR,R2			;Get print csr
	BITW	#READY_BIT,(R2)			;Ready?
	BEQL	10$				;No (ok)
	MOVB	#17,MODE			;
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	5$				;Loop on error
10$:
	BITW	#ERROR_BIT,(R2)			;Error bit set?
	BNEQ	15$				;If error bit set no error
	MOVB	#18,MODE			;
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	5$				;Loop on error
15$:
	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupts
	CALLG	OPIN3,CONSOL_OUT		;Output message
	CALLG	OPIN7,RQEST			;Turn on printer/plotter
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupt
20$:
	BITW	#READY_BIT,(R2)			;Printer/plotter ready?
	BNEQ	25$				;Yes ok!
	MOVB	#17,MODE			;
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	5$				;Loop on error
25$:
	BITW	#ERROR_BIT,(R2)			;Error bit set?
	BEQL	30$				;No ok!
	MOVB	#18,MODE			;
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	5$				;Loop on error
30$:
	RSB					;Return to main logic
	.SUBTITLE Test 2  - Out of paper test
;********************************************************
;* Controller test #2					*
;*							*
;* This routine the printer/plotter to detect out of	*
;* paper. The following takes place:			*
;*							*
;* 1. A message is sent to console requesting removal	*
;*    of the paper and pushing advance button.		*
;*    The error bit of the print statusword is checked	*
;*    to be set. If the bit is not set an error message	*
;*    is sent to the console and will loop on the	*
;*    error if manual mode.				*
;*							*
;* 3. A message is sent to the console requesting the	*
;*    replacement of the paper.				*
;*							*
;* 4. after carriage return is depressed on the		*
;*    console, the error bit is checked again. At this	*
;*    time the error bit should be off. if not an	*
;*    error will be displayed on the console.		*
;********************************************************
CON2:
	CALLG	COM2,CONSOL_OUT			;Output test message
	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupts
	MOVB	#18,MODE			;
	CALLG	OPIN5,CONSOL_OUT		;Remove paper maeesage
	CALLG	OPIN7,RQEST			;Wait for carriage return
	MOVL	PRINT_CSR,R2			;Get print csr
5$:
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupts
	BITW	#ERROR_BIT,(R2)			;Error bit set?
	BNEQ	10$				;Yes ok!
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error on console
	BRB	5$				;Loop on error
10$:
	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupts
	CALLG	OPIN6,CONSOL_OUT		;Replace paper message
	CALLG	OPIN7,RQEST			;Wait for carriage return
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupts
15$:
	BITW	#ERROR_BIT,(R2)			;Error bit set?
	BNEQ	20$				;Yes error
	RSB					;Return to main logic
20$:
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	15$				;Loop on error
	.SUBTITLE Test 3  - SPP bit test
;********************************************************
;* Controller test #3					*
;*							*
;* This test checks the SPP bit (0) that it can be	*
;* set and reset. The test will check both the print	*
;* and plot status registers. The following steps will	*
;* occur:						*
;*							*
;* 1. SPP bit is set to a binary 1.			*
;* 2. Bit 0 is checked to be a binary 1.		*
;* 3. If not set to a 1, error.				*
;* 4. Bit 0 is then cleared.				*
;* 5. Bit 0 is then chacked to be a binary 0.		*
;* 6. If nit 0 is a 1, error.				*
;********************************************************
CON3:
	BBS	#V_SPP_PLOTTER,TYPE_PRINTER,5$	;SPP available?
	RSB					;No return to main logic
5$:
	CALLG	COM3,CONSOL_OUT			;Output test message
	MOVL	PRINT_CSR,R2			;Get print csr
	MOVB	#SPP_BIT_PNTR,MODE		;Indicate SPP print
	MOVW	#SPP_BIT_122,R3			;Get SPP bit for 122 controller
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,10$
	MOVW	#SPP_BIT_121,R3			;Get SPP bit for 121 controller
10$:
	BISW	R3,(R2)				;Enable SPP print
	JSB	CHECK_READY			;Wait for ready
	BITW	R3,(R2)				;SPP bit still set?
	BNEQ	15$				;Yes
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	10$				;Loop on error
15$:
	BICW	R3,(R2)				;Clear SPP enable bit
	JSB	CHECK_READY			;Wait for ready
	BITW	R3,(R2)				;Is it still set?
	BEQL	20$				;No ok
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	10$				;Loop on error
20$:
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,35$	;If 122 controller exit
	MOVL	PLOT_CSR,R2			;Get plot csr
	MOVB	#SPP_BIT_PLTR,MODE		;Indicate SPP plot
25$:
	BISW	R3,(R2)				;Enable SPP plot
	JSB	CHECK_READY			;Wait for ready
	BITW	R3,(R2)				;Bit still set?
	BNEQ	30$				;Yes
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	25$				;Loop on error
30$:
	BICW	R3,(R2)				;Clear SPP plot bit
	JSB	CHECK_READY			;Wait for ready
	BITW	R3,(R2)				;Still set?
	BEQL	35$				;No return to main logic
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	25$				;Loop on error
35$:
	RSB					;Return to main logic
	.SUBTITLE Test 4  - DPC interrupt test
;********************************************************
;* Controller test #4					*
;*							*
;* This test verifies that DPC interrupts occur for	*
;* print and plot modes. The following steps are	*
;* performed:						*
;*							*
;* 1. Test determines what type printer/plotter is 	*
;*    is present. If plotter only, plot interrupts are	*
;*    checked. If printer only, print interrupts are	*
;*    checked. If printer/plotter both are checked.	*
;*							*
;* 2. Register R2 is ser to device address.		*
;*    Register R4 is set to the device vector address.	*
;*							*
;* 3. The PSW is set to priority 7 to inhibit		*
;*    interrupts, then the interrupt bit is set. The	*
;*    interrupt bit is then tested to be set. If not	*
;*    then error					*
;*							*
;* 4. The interrupt is then cleared and checked to	*
;*    be cleared. If not error.				*
;*							*
;* 5. The priority is then lowered and the interrupt	*
;*    bit is set. If no interrupt occurs, then error.	*
;*    If printer/plotter is not ready after interrupt	*
;*    then error.					*
;********************************************************
CON4:
	CALLG	COM4,CONSOL_OUT			;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,5$	;Form feed?
	JSB	PRINT_RFMD			;Issue remote form feed
5$:	CASEB	TYPE_CPU,#1,#NMB_CPUS		;Determine processor
10$:
		.WORD	100$-10$			;VAX11/780
		.WORD	200$-10$			;VAX11/750
		.WORD	200$-10$			;VAX11/730
;********************************************************
;* VAX11/780 processor					*
;********************************************************
100$:
	MOVZWL	INTR_VECTOR,R2			;Valid vector
	MOVAL	CON4_780_INTR_SERV+1,SCB(R2)	;Setup vector address
	MOVL	UBA_ADDR_SPACE,R6		;Address of unibus registers
	ADDW	BRRVR_USED,R6			;Index to correct priority
	BRW	400$				;Continue with test
;********************************************************
;* VAX11/750/730 processor				*
;********************************************************
200$:
	MOVAL	CON4_750_INTR_SERV+1,R4		;Address of service routine
	MOVAL	CON4_750_BAD_INTR+1,R5		;Address for error service
	JSB	VECTOR_750_SETUP		;Setup vectors
	BRW	400$				;Continue test
	RSB					;Return to main logic
400$:
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,410$	;Plotter only?
	MOVB	#19,MODE			;Interrupt bit print
	MOVL	PRINT_CSR,R2			;Print csr address
	MOVL	PRINT_VECTOR,R3			;Expected interrupt
	MOVZBL	#NORDYAF_PR,R4			;Not ready after interrupt
	MOVZBL	#NOINTR_PR,R5			;No interrupt for print
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,405$	;I not 122 skip
	JSB	SET_PRINT_122			;Set print mode
405$:
	JSB	CON4_SUB			;Test print interrupts
	BLBC	R0,410$				;Error?
	BRW	5$				;Yes loop on error
410$:
	BBC	#V_PRINTER_ONLY,TYPE_PRINTER,415$	;Printer only?
	JSB	RESTORE				;Restore map registers
	RSB					;Return to main logic
415$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,420$	;If not 122 skip
	MOVL	PRINT_CSR,R2			;Get 122 csr address
	MOVL	PRINT_VECTOR,R3			;Get correct vector address
	JSB	SET_PLOT_122			;Enable plot mode
	BRB	425$				;Go around 121 controller setup
420$:
	MOVL	PLOT_CSR,R2			;Plot csr address
	MOVL	PLOT_VECTOR,R3			;Expected interrupt
425$:
	MOVB	#22,MODE			;Interrupt plot bit
	MOVZBL	#NORDYAF_PL,R4			;Not ready after interrupt
	MOVZBL	#NOINTR_PL,R5			;No plot interrupt
	JSB	CON4_SUB			;Test plot interrupts
	BLBC	R0,430$				;Error?
	BRW	5$				;Yes, loop on error
430$:
	JSB	RESTORE				;Restore map registers
	RSB					;Return to main logic
CON4_SUB:
	MTPR	#DISABL_INTR,#PR$_IPL		;Raise interrupt priority
	BISW	#INTR_ENABL,(R2)		;Enable interrupt
	BITW	#INTR_ENABL,(R2)		;Interrupt bit still et?
	BNEQ	5$				;Yes
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	25$				;Set error status
5$:
	BICW	#INTR_ENABL,(R2)		;Clear interrupt bit
	BITW	#INTR_ENABL,(R2)		;Interrupt bit still set?
	BEQL	10$				;Noo
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	25$				;Set error status
10$:
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	CLRB	MODE				;Set mode to 0
	MTPR	INTERVAL_TIME,#PR$_NICR		;Setup clock
	MOVW	#2,WAIT_COUNT			;Only wait for two seconds
	CLRB	INTR_COMPLETE			;Set no no interrupt
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
	BISW	#INTR_ENABL,(R2)		;Enable interrupt
15$:
	TSTB	INTR_COMPLETE			;Did interrupt occur?
	BNEQ	20$				;Yes
	TSTW	WAIT_COUNT			;Clock timed out?
	BNEQ	15$				;No
	BICW	#INTR_ENABL,(R2)		;Clear interrupt bit
	MOVB	R2,ERROR_TYPE			;Indicate no interrupt
	JSB	ERROR_DISPLAY			;Output error to console
	BRB	25$				;Set error status
20$:
	CMPB	INTR_COMPLETE,#1		;Did error occur?
	BLEQ	30$				;No, return
25$:
	MOVZBL	#1,R0				;Put error status in R0
	RSB
30$:
	CLRL	R0				;Indicate normal status
	RSB					;Return to controller test 4
	.ALIGN	LONG
CON4_780_INTR_SERV:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	INCB	INTR_COMPLETE			;Indicate interrupt occured
	MOVL	(R6),R7				;Get indicated vector
	BRB	CON4_INTR_CONTINUE		;Skip VAX11/750 entry point
	.ALIGN	LONG
CON4_750_INTR_SERV:				;Entry point for VAX11/750 interrupt
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	INCB	INTR_COMPLETE			;Indicate interrupt occured
	MFPR	#PR$_IPL,R0			;Get current priority level
	CMPB	R0,PRIORITY			;Correct priority?
	BEQL	5$				;Yes
	SUBB3	#^X10,PRIORITY,PRIO_EXPT	;Store expected priority
	ADDB	#^A/0/,PRIO_EXPT		;Convert to acsii
	SUBB3	#^X10,R0,PRIO_FOUND		;Store found priority
	ADDB	#^A/0/,PRIO_FOUND		;Convert to ascii
	MOVAL	VECT_FOUND,R4			;Address to store conversion
	MOVL	R3,R0				;Vector address to convert
	MOVZBL	#12,R1				;Index for conversion
	JSB	OCTAL_ASCII			;Convert to ascii
	CALLG	INVAL_PRIO_MESS,CONSOL_OUT	;Inval, prio message
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	INCB	INTR_COMPLETE			;Indicate error
	REI					;Return from interrupt
5$:	CLRL	R7				;No indicated vector
	CLRL	R3				;No expected vector
CON4_INTR_CONTINUE:
	BITW	#READY_BIT,(R2)			;Printer/plotter ready?
	BNEQ	5$				;Yes
	BICW	#INTR_ENABL,(R2)		;Clear interrupt bit
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	MOVB	R4,ERROR_TYPE			;Set error type
	JSB	ERROR_DISPLAY			;Output error to console
	INCB	INTR_COMPLETE			;Indicate not ready
5$:
	BICW	#INTR_ENABL,(R2)		;Clear interrupt
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	CMPW	R7,R3				;Correct vector?
	BNEQ	CON4_INVAL_VECTOR		;No
	REI					;Return from interrupt
CON4_INVAL_VECTOR:
	MOVL	R7,R0				;Get vector received
	MOVAL	INVAL_VECT,R4			;Address of ascii conversion
	MOVZBL	#12,R1				;Correct index
	JSB	OCTAL_ASCII			;Convert bad vector to ascii
	CALLG	INVAL_VECT_MESS,CONSOL_OUT	;Output error to console
	INCB	INTR_COMPLETE			;Interrupt but error
	REI					;Return from interrupt
	.ALIGN	LONG
CON4_750_BAD_INTR:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	BICW	#INTR_ENABL,(R2)		;Clear interrupt
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	INCB	INTR_COMPLETE			;Indicate interrupt occured
	CLRL	R7				;No interrupt vector
	BRB	CON4_INVAL_VECTOR		;Bad interrupt
	.PAGE
	.SUBTITLE DMA controller tests
	.SUBTITLE Test 5  - DMA busy bit test
;********************************************************
;* Controller test #5					*
;*							*
;* This test checks the DMA busy/ready flag. (bit 13)	*
;* Checks are made for print and plot modes. The 	*
;* steps take place:					*
;*							*
;* 1. A test is made for plotter only. If plotter only	*
;*    go to step 7.					*
;*							*
;* 2. A buffer is setup with enough data ('a') for	*
;*    four print lines.					*
;*							*
;* 3. The buffer is sent the printer using DMA		*
;*    transfers. when DMA is started, bit 13 (DMA busy)	*
;*    is checked for a binary 1. If not set error.	*
;*							*
;* 4. Ready bit is then checked and if ready does not	*
;*    become ready after 15 seconds, then error. If	*
;*    ready bit is set bit 13 (DMA busy) is checked to	*
;*    be a binary 0. If not error.			*
;*							*
;* 5. A buffer is setup containing enough data ('b')	*
;*    for four print lines.				*
;*							*
;* 6. Steps 3-4 are repeated with the new data. A total	*
;*    of eight lines should be printed.			*
;*							*
;* 7. A buffer is setup for four scan lines of solid	*
;*    binary ones.					*
;*							*
;* 8. Steps 3-4 are then repeated for plot.		*
;*							*
;* 9. A buffer is setup for four scan lines of every	*
;*    other byte set to all ones.			*
;*							*
;* 10. Steps 3-4 are then repeated for plot.		*
;********************************************************
CON5:
	CALLG	COM5,CONSOL_OUT			;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,5$	;Form feed?
	JSB	PRINT_RFMD			;Output remote formfeed print
5$:
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,20$	;Plotter only?
	MOVL	PRINT_CSR,R2			;Print csr address
	MOVAL	PRINT_BUF,R7			;Buffer to transfer
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,10$	;If not 122 skip
	JSB	SET_PRINT_122			;Set print mode
	BRB	15$				;Don't need R5 set
10$:
	MOVL	DMA_PRINT_REG,R5		;DMA print byte count register
15$:
	MOVB	#23,MODE			;DMA busy bit print
	MOVB	#8,R9				;Set R3 to no DPC interrupt
	CLRL	R6				;Clear register
	MULW3	#4,PRINT_SIZE,R6		;Get byte count for four lines
	PUSHR	#^M<R2,R4,R5>			;Save registers
	MOVC5	#0,PRINT_BUF,#^A/A/,R6,PRINT_BUF	;Fill print buffer
	POPR	#^M<R2,R4,R5>			;Restore registers
	JSB	CON5_SUB			;Test DMA busy bit for print
	PUSHR	#^M<R2,R4,R5>			;Save registers
	MOVC5	#0,PRINT_BUF,#^A/B/,R6,PRINT_BUF	;Fill print buffer
	POPR	#^M<R2,R4,R5>			;Restore registers
	JSB	CON5_SUB			;Test DMA busy bit for print
	BBS	#V_PRINTER_ONLY,TYPE_PRINTER,35$	;Printer only?
20$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,25$	;If not 122 skip
	MOVL	PRINT_CSR,R2			;Get 122 CSR
	JSB	SET_PLOT_122			;Set plot mode
	BRB	30$				;Skip 121 setup
25$:
	MOVL	DMA_PLOT_REG,R5			;DMA plot byte count register
	MOVL	PLOT_CSR,R2			;Plot csr address
30$:
	MOVAL	PLOT_BUF,R7			;Buffer to transfer
	MOVB	#24,MODE			;Indicate DMA busy bit plot
	MOVZBL	#16,R9				;Output plot data
	CLRL	R6				;Clear register
	MULW3	#4,PLOT_SIZE,R6			;Determine byte count
	MOVW	R6,PLOT_GEN_FILL		;Store fill count
	MOVW	#^XFF00,PLOT_PATTERN		;Store pattern to use
	PUSHR	#^M<R2,R4,R5>			;Save registers
	MOVC5	#0,PLOT_BUF,#^XFF,R6,PLOT_BUF	;Fill plot buffer
	POPR	#^M<R2,R4,R5>			;Restore registers
	JSB	CON5_SUB			;Test plot DMA busy bit
	JSB	PLOT_GEN			;Fill plot buffer
	JSB	CON5_SUB			;Test plot DMA busy bit
35$:
	RSB					;Return to main logic
CON5_SUB:
5$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,10$	;If not 122 skip
	BISW	#DMA_ADDR_122,(R2)		;Indicate DMA address to follow
	MOVW	R7,2(R2)			;Load DMA address in 122
	BISW	#DMA_BCNT_122,(R2)		;Indicate DMA byte count
	MNEGW	R6,2(R2)			;Load negated byte count
	INCW	(R2)				;Start DMA operation
	BRB	15$				;Skip 121 DMA initialization
10$:
	MOVW	R7,@DMA_ADDR_REG		;16 bits of buffer address
	MOVW	R6,(R5)				;Start DMA
15$:
	BITW	DMABUSY_BIT,(R2)		;DMA busy bit set?
	BNEQ	20$				;Yes ok
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	CON5_SUB			;Loop on error
20$:
	JSB	CHECK_READY			;Wait for ready
	BLBS	R0,30$				;If set error
	BITW	DMABUSY_BIT,(R2)		;DMA busy bit still set?
	BEQL	25$				;No ok
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	CON5_SUB			;Loop on error
25$:
	RSB					;Return to CON5 main
30$:
	MOVB	MODE,R8				;Save mode
	MOVB	R9,MODE				;Set mode to type error
	MOVB	OFF_LINE,ERROR_TYPE		;Indicate offline
	JSB	ERROR_DISPLAY			;Output error to console
	MOVB	R8,MODE				;Restore mode
	BRW	CON5_SUB			;Loop on error
	.SUBTITLE Test 6  - DMA address register test
;********************************************************
;* Controller test #6					*
;*							*
;* This test checks the controllers DMA address		*
;* regester. The test will check up to the address of	*
;* 124k (18 bits). The following takes place:		*
;*							*
;* 1. The entire memory except for lower 4k is set	*
;*    to '?' for print or all 0 for plot		*
;*							*
;* 2. Starting at the second bank of 4k in 1k blocks	*
;*    the first word is set to an ascii '01', then	*
;*    each sucessive 1k block is increased by '1' until	*
;*    '04' where '01' is started over again. the	*
;*    first block is set to '01' then sent to the	*
;*    printer/plotter and terminated with a remote line	*
;*    terminate. The ascii value is the reset to '??'	*
;*    or 0.						*
;*							*
;* 3. Step 2 is repeated until all memory or 18 bits	*
;*    have been used.					*
;********************************************************
CON6:
	CALLG	COM6,CONSOL_OUT			;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,5$	;Form feed?
	JSB	PRINT_RFMD			;Issue remote form feed
5$:
	MOVB	#OFF_LINE,ERROR_TYPE		;Initialize error type
	MOVZBL	#^A/0/,R8			;Setup number counters
	MOVL	R8,R9				;
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,15$	;Plotter only?
	MOVB	#PRINT_MODE,MODE		;Print data transfer
	MOVZBL	#^A/?/,R11			;Memory restore pattern
	MOVC5	#0,PRINT_BUF,#^A/?/,#512,PRINT_BUF	;Fill print buffer ('?')
	MOVC5	#0,PLOT_BUF,#^A/?/,#512,PLOT_BUF	;Fill plot buffer ('?')
	MOVL	PRINT_CSR,R2			;Get print csr address
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,10$	;If 121 skip
	JSB	SET_PRINT_122			;Set print mode
	BRW	25$
10$:
	MOVL	DMA_PRINT_REG,R3		;Print DMA byte count register
	BRW	25$				;Go around plot setup
15$:
	MOVB	#PLOT_MODE,MODE			;Plot data transfer
	MOVC5	#0,PRINT_BUF,#0,#512,PRINT_BUF	;0 print buffer
	MOVC5	#0,PLOT_BUF,#0,#512,PLOT_BUF	;0 plot buffer
	CLRL	R11				;Plot pattern of zero
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,20$	;If 121 skip
	MOVL	PRINT_CSR,R2			;Get 122 CSR
	JSB	SET_PLOT_122			;Set plot mode
	BRB	25$				;Go around 121 setup
20$:
	MOVL	DMA_PLOT_REG,R3			;Plot DMA byte count register
	MOVL	PLOT_CSR,R2			;Get addr. of plot csr register
25$:
	MOVZWL	#MAP_LIMIT,R4			;Number of registers to fill
	ADDL3	#UBA$L_MAP,UBA_ADDR_SPACE,R5	;Address  of first register
	MOVL	R5,R10				;Save for later use
	ASHL	#-9,#PLOT_BUF,R0		;Get page frame number
	BISL	#UBA$M_MAP_VALID,R0		;Set valid bit
30$:
	MOVL	R0,(R5)+			;Initialize mapping registers
	SOBGTR	R4,30$				;Initialize all registers
	MOVZBL	#1,R4				;Start with bit #0
	MOVZBL	#1,R5				;Go bit in R5
	CLRL	R6				;Clear plot loop counter
	MOVB	R8,PRINT_BUF			;Set for first transfer
35$:
	BICL3	#^XFFFFFE00,R4,R7		;Get 18 bit address
	MOVB	R9,PRINT_BUF(R7)		;Store bit number in buffer
	MOVB	R8,PRINT_BUF+1(R7)
	ASHL	#-9,R4,R0			;Get map index
	ASHL	#-9,#PRINT_BUF,(R10) [R0]	;Set map register
	BISL	#UBA$M_MAP_VALID,(R10) [R0]	;Make map valid
40$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,45$	;If 121 skip
	BISW	#DMA_ADDR_122,(R2)		;Indicate DMA address load
	MOVW	R4,2(R2)			;Load 16 bit address
	BISW	#DMA_BCNT_122,(R2)		;Indicate DMA byte count
	MOVW	#-2,2(R2)			;Load byte count
	MOVB	R5,(R2)				;Set extension and go bits
	BRB	50$				;Go around 121 setup
45$:
	MOVW	R4,@DMA_ADDR_REG		;Lower 16 bits of address
	MOVW	R5,@DMA_EXT_REG			;Upper 2 bits of addressing
	MOVW	#2,(R3)				;Start DMA transfer of 2 bytes
50$:
	JSB	CHECK_READY			;Ready?
	BLBS	R0,55$				;If set error
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,51$	;If 121, skip
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,51$	;If plotter only,skip
	JSB	PRINT_LNTERM			;Terminate line
	BRW	55$				;Skip 121 plotter only
51$:	JSB	PLOT_LNTERM			;Terminate line
	BBC	#V_PLOTTER_ONLY,TYPE_PRINTER,55$	;Plotter only?
	ACBW	#^X10,#1,R6,40$			;For plot repeat 16 times
	CLRL	R6				;Reset counter
55$:
	MOVB	R11,PRINT_BUF(R7)		;Restore memory pattern
	MOVB	R11,PRINT_BUF+1(R7)		;
	ASHL	#-9,R4,R0
	ASHL	#-9,#PLOT_BUF,(R10) [R0]	;Restore mapping register
	BISL	#UBA$M_MAP_VALID,(R10) [R0]	;Make map valid
	INCB	R8				;Bump units digit
	CMPB	R8,#^A/9/			;Past ascii 9?
	BLEQ	60$				;No
	MOVB	#^A/0/,R8			;Set to zero
	INCB	R9				;Bump msb of bit value
60$:
	ROTL	#1,R4,R4			;Shift 16 bit address 1 bit left
	TSTW	R4				;Past 16 bits of addressing?
	BEQL	65$				;Yes
	BRW	35$				;No
65$:
	ADDW	#BIT_5,R5			;Bump bit 16 of address by 1
	CMPB	R5,#^X30			;Finished?
	BGEQ	70$				;Yes
	BRW	35$				;No
70$:
	JSB	RESTORE				;Restore map registers and vectors
	RSB					;Return to main logic
	.SUBTITLE Test 7  - DTC interrupt test
;********************************************************
;* Controller test #7					*
;*							*
;* This test verifies DTC interrupts. The test		*
;* checks both print and plot interrupts depending	*
;* on the printer/plotter model. The test performs the	*
;* following steps:					*
;*							*
;* 1. Test is made to determine if printer/plotter is	*
;*    plotter only. If so go to step 7.			*
;*							*
;* 2. A buffer is filled with enough data 'A' for	*
;*    four print lines.					*
;*							*
;* 3. DMA is set in motion and the DPC interrupt	*
;*    is enabled.					*
;*							*
;* 4. If no interrupt error.				*
;*							*
;* 5. A buffer is filled with enough data 'B' for	*
;*    four print lines.					*
;*							*
;* 6. Step 3 is then repeated.				*
;*							*
;* 7. A buffer is filled with enough data '-1' for	*
;*    FOUR scan lines.					*
;*							*
;* 8. Step 3 is then repeated.				*
;*							*
;* 9. A buffer is filled with every other byte on	*
;*    for four scan lines.				*
;*							*
;* 10. Step 3 is then repeated.				*
;********************************************************
CON7:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If not 121 return
	RSB					;Return to main logic
5$:
	CALLG	COM7,CONSOL_OUT			;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,10$	;Form feed?
	JSB	PRINT_RFMD			;Issue remote form feed
10$:
	CASEB	TYPE_CPU,#1,#NMB_CPUS		;Determine processor
15$:
		.WORD	100$-15$		;VAX11/780
		.WORD	200$-15$		;VAX11/750
		.WORD	200$-15$		;VAX11/730
;********************************************************
;* VAX11/780 processor					*
;********************************************************
100$:
	MOVZWL	INTR_VECTOR,R0			;Get vector index
	MOVAL	CON7_780_INTR_SERV+1,SCB(R0)	;Setup interrupt vector
	BRB	400$				;Continue test
;********************************************************
;* VAX11/750/730 processor					*
;********************************************************
200$:
	MOVAL	CON7_750_INTR_SERV+1,R4		;Address of service routine
	MOVAL	CON7_750_BAD_INTR+1,R5		;Address for error service
	JSB	VECTOR_750_SETUP		;Setup vectors
400$:
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,405$	;Plotter only?
	CLRL	R6				;Make sure clear
	MULW3	#4,PRINT_SIZE,R6		;Change to 4 lines
	MOVC5	#0,PRINT_BUF,#^A/A/,R6,PRINT_BUF	;Fill 4 print lines of 'a'
	MOVB	#PRINT_MODE,MODE		;Indicate print data transfer
	MOVZBL	#8,R10				;Error to be used
	MOVL	PRINT_VECTOR,R5			;Setup expected vector variable
	MOVL	DMA_PRINT_REG,R3		;DMA print byte count register
	MOVL	PRINT_CSR,R2			;Print csr address
	MOVAL	PRINT_BUF,R9			;Buffer to use
	JSB	CON7_SUB			;Test print interrupt
	BLBC	R0,403$				;Error?
	BRW	10$				;Yes, loop on error
403$:
	PUSHR	#^M<R2,R3,R5>
	MOVC5	#0,PRINT_BUF,#^A/B/,R6,PRINT_BUF	;Fill 4 print lines of 'b'
	POPR	#^M<R2,R3,R5>
	JSB	CON7_SUB
	BLBC	R0,404$				;Error?
	BRW	10$				;Yes, loop on error
404$:
	BBC	#V_PRINTER_ONLY,TYPE_PRINTER,405$	;Printer only?
	JSB	RESTORE				;Restore map registers
	RSB					;Return to main logic
405$:
	MOVB	#PLOT_MODE,MODE			;Indicate plot data transfer
	CLRL	R6				;Make sure zero
	MULW3	#4,PLOT_SIZE,R6			;Increase byte count for 4 scans
	MOVW	R6,PLOT_GEN_FILL		;Store fill count
	MOVW	#^XFF00,PLOT_PATTERN		;Store fill pattern
	MOVC5	#0,PLOT_BUF,#^XFF,R6,PLOT_BUF	;Fill plot buffer all ones
	MOVL	DMA_PLOT_REG,R3			;DMA plot byte count register
	MOVAL	PLOT_BUF,R9			;Buffer to work with
	MOVL	PLOT_CSR,R2			;Plot csr address
	MOVZBL	#9,R10				;Error code to use
	MOVL	PLOT_VECTOR,R5			;Expect plot interrupt
	JSB	CON7_SUB			;Test plot interrupt
	BLBC	R0,410$				;Error?
	BRW	10$				;Yes, loop on error
410$:
	JSB	PLOT_GEN			;Fill plot buffer
	JSB	CON7_SUB			;Test plot interrupt
	BLBC	R0,420$				;Error?
	BRW	10$				;Yes, loop on error
420$:
	JSB	RESTORE				;Restore map registers
	RSB					;Return to main logic
CON7_SUB:
	CLRB	INTR_COMPLETE			;Clear interrupt complete flag
	MOVL	UBA_ADDR_SPACE,R7		;Get UBA address
	ADDW	BRRVR_USED,R7			;Offset to brrvr used
	MTPR	INTERVAL_TIME,#PR$_NICR		;Set number of clicks for clock
	MOVW	TIME_COUNT,WAIT_COUNT		;Set wait period
	MOVW	R9,@DMA_ADDR_REG		;Lower 16 bits of buffer address
	MOVW	R6,(R3)				;Start DMA data transfer
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Start clock
	BISW	#DTC_ENABL_121,(R2)		;Enable DTC interrupt
5$:
	TSTB	INTR_COMPLETE			;Interrupt complete?
	BNEQ	10$				;Yes
	TSTW	WAIT_COUNT			;Timed out?
	BNEQ	5$				;No
	BICW	#DTC_ENABL_121,(R2)		;Clear interrupt enable
	MOVB	R10,ERROR_TYPE			;Error type
	JSB	ERROR_DISPLAY			;Display error on console
	BRB	15$				;Set error status
10$:
	CMPB	INTR_COMPLETE,#1		;Error?
	BGTR	15$				;Yes, set error status
	CLRL	R0				;Indicate normal status
	RSB					;Return to CON7
15$:
	MOVZBL	#1,R0				;Indicate error status
	RSB					;Return to CON7
	.ALIGN	LONG
CON7_780_INTR_SERV:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	INCB	INTR_COMPLETE			;Indicate interrupt occured
	MOVL	(R7),R8				;Get vector received
	BRB	CON7_INTR_CONTINUE
	.ALIGN	LONG
CON7_750_INTR_SERV:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	INCB	INTR_COMPLETE			;Indicate interrupt occured
	MFPR	#PR$_IPL,R0			;Get current priority level
	CMPB	R0,PRIORITY			;Correct priority?
	BEQL	5$				;Yes
	SUBB3	#^X10,PRIORITY,PRIO_EXPT	;Store expected priority
	ADDB	#^A/0/,PRIO_EXPT		;Convert to acsii
	SUBB3	#^X10,R0,PRIO_FOUND		;Store found priority
	ADDB	#^A/0/,PRIO_FOUND		;Convert to ascii
	MOVAL	VECT_FOUND,R4			;Address to store conversion
	MOVL	R5,R0				;Vector address to convert
	MOVZBL	#12,R1				;Index for conversion
	JSB	OCTAL_ASCII			;Convert to ascii
	CALLG	INVAL_PRIO_MESS,CONSOL_OUT	;Inval, prio message
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	INCB	INTR_COMPLETE			;Indicate error
	REI					;Return from interrupt
5$:	CLRL	R8				;No interrupt vector
	CLRL	R5				;No interrupt vector
	BRB	CON7_INTR_CONTINUE		;Continue test ready
CON7_INTR_CONTINUE:
	BICW	#DTC_ENABL_121,(R2)		;Disable interrupt
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	JSB	CHECK_READY			;Check for ready
	BLBC	R0,5$				;If clear ready
	MOVB	#OFF_LINE,ERROR_TYPE		;Not ready error
	JSB	ERROR_DISPLAY			;Display error on console
	INCB	INTR_COMPLETE			;Indicate interrupt but error
5$:
	CMPW	R8,R5				;Valid vector?
	BNEQ	CON7_INVAL_VECTOR		;No
	REI					;Return from interrupt
CON7_INVAL_VECTOR:
	PUSHR	#^M<R4>				;Save register
	MOVL	R8,R0				;Get vector received
	MOVAL	INVAL_VECT,R4			;Address of conversion area
	MOVZBL	#12,R1				;Index
	JSB	OCTAL_ASCII			;Convert to ascii(vector)
	CALLG	INVAL_VECT_MESS,CONSOL_OUT	;Error message
	POPR	#^M<R4>
	INCB	INTR_COMPLETE			;Indicate interrupt but error
	REI					;Return from interrupt
	.ALIGN	LONG
CON7_750_BAD_INTR:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	BICW	#DTC_ENABL_121,(R2)		;Disable interrupt
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	INCB	INTR_COMPLETE			;Indicate interrupt occured
	CLRL	R8				;No interrupt vector
	BRB	CON7_INVAL_VECTOR		;Bad interrupt
	.SUBTITLE Test 8  - DMA invalid address test
;********************************************************
;* Controller test #8					*
;*							*
;* This test checks the error logic of the controller	*
;* for addressing an invalid address in DMA. The	*
;* following steps take place:				*
;*							*
;* 1. The mapping register is set-up with an illegal	*
;*    memory page. (FFFFF)				*
;*							*
;* 2. Max dump is requested for plot.			*
;*							*
;* 3. The program then waits for 512 milliseconds.	*
;*							*
;* 4. Bit 15 of the plot status register is checked.	*
;*    If th error bit is not set error.			*
;*							*
;* 5. Bit 15 is then cleared and then checked to be	*
;*    reset if not error.				*
;********************************************************
CON8:
	CALLG	COM8,CONSOL_OUT			;Output to console
CON8_CONTINUE:
	ADDL3	#UBA$L_MAP,UBA_ADDR_SPACE,R2	;First mapping register
	MOVL	#^XFFFFF,(R2)			;Maximum page address (illegal)
	BISL	#UBA$M_MAP_VALID,(R2)		;Indicate valid map
	MOVL	DMA_ADDR_REG,R5			;DMA address register
	BBC	#V_PRINTER_ONLY,TYPE_PRINTER,10$	;Printer only
	MOVB	#18,MODE			;Set mode indicator
	MOVL	PRINT_CSR,R2			;Print csr address
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If 121 skip
	JSB	SET_PRINT_122			;Set print mode
	BRB	20$				;Go around 121 setup
5$:
	MOVL	DMA_PRINT_REG,R3		;DMA print byte count register
	BRB	20$				;Go around plot setup
10$:
	MOVB	#21,MODE			;Setup mode type
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,15$	;If 121 skip
	MOVL	PRINT_CSR,R2			;Get 122 CSR
	JSB	SET_PLOT_122			;Set plot mode
	BRB	20$				;Skip around 121 setup
15$:
	MOVL	PLOT_CSR,R2			;Plot csr address
	MOVL	DMA_PLOT_REG,R3			;DMA plot byte count register
20$:
	MTPR	#-512,#PR$_NICR			;512 microseconds wait
	MOVW	#1,WAIT_COUNT			;Set wait period
	MOVL	UBA_ADDR_SPACE,R6		;Get UBA address
 
	CASEB	TYPE_CPU,#1,#NMB_CPUS		;Find correct procedure
25$:
		.WORD	100$-25$		;VAX11/780
		.WORD	200$-25$		;VAX11/750
		.WORD	200$-25$		;VAX11/730
;************************************************
;* VAX11/780 Processor				*
;************************************************
100$:
	CLRL	UBA$L_CR(R6)			;Allow no interrupts
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,105$	;If 121 skip
	BISW	#DMA_ADDR_122,(R2)		;Indicate DMA address load
	CLRW	2(R2)				;Select first map reg. for test
	BISW	#DMA_BCNT_122,(R2)		;Indicate DMA byte count load
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
	CLRW	2(R2)				;Max data transfer
	INCB	(R2)				;START DMA
	BRB	110$				;Go wait
105$:
	MOVW	#0,(R5)				;Select first map reg. for test
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
	MOVW	#^X7FFF,(R3)			;Enable DMA transfer
110$:
	TSTW	WAIT_COUNT			;Timed out?
	BNEQ	110$				;No not yet
	BISL	#UBA$M_SR_CXTMO,UBA$L_SR(R6)	;Clear error bit
	JSB	RESET_CPU			;Reset SBI error
	BITW	#ERROR_BIT,(R2)			;Error bit set?
	BNEQ	115$				;No
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Setup error type
	JSB	ERROR_DISPLAY			;Display error on console
	BRW	CON8_CONTINUE			;Loop on error
115$:	BICW	#ERROR_BIT,(R2)			;Clear error and interrupt
	MOVW	#1,WAIT_COUNT			;Set wait for .5 microseconds
	MTPR	#-512,#PR$_NICR			;512 microseconds wait
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
120$:
	TSTW	WAIT_COUNT			;See if timed out
	BNEQ	120$				;No
	BITW	#ERROR_BIT,(R2)			;Is error bit still set?
	BNEQ	125$				;Yes
	BRW	1000$				;No everything is o.k.
125$:	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Error bit on adnormal
	JSB	ERROR_DISPLAY			;Display error on console
	BRW	CON8_CONTINUE			;Loop on error
;************************************************
;* VAX11/750/730 Processor				*
;************************************************
200$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,205$	;If 121 skip
	BISW	#DMA_ADDR_122,(R2)		;Indicate DMA address load
	CLRW	2(R2)				;Select first map reg. for test
	BISW	#DMA_BCNT_122,(R2)		;Indicate DMA byte count load
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
	CLRW	2(R2)				;Max data transfer
	INCB	(R2)				;Start DMA operation
	BRB	210$				;Go wait
205$:
	MOVW	#0,@DMA_ADDR_REG		;Select first map reg. for test
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
	MOVW	#^X7FFF,(R3)			;Enable DMA transfer
210$:
	TSTW	WAIT_COUNT			;Timed out?
	BNEQ	210$				;No not yet
	CMPB	#V11730,TYPE_CPU		;Is system a 730?
	BEQL	215$				;Yes
	MFPR	#PR$_MCSR,R6			;Get machine check status
	BITL	#NON_750_EXIST_MEMORY,R6	;Non exisist memory?
	BNEQ	220$				;YES
	BRW	115$				;No error
215$:
	MOVL	CSR1_730,R6			;Get CSR1 address
	MOVL	(R6),R6				;Get status information
	BITL	#NON_730_EXIST_MEMORY,R6	;Non exisist memory?
	BNEQ	220$				;YES
	BRW	115$				;No error
220$:
	BITW	#ERROR_BIT,(R2)			;Error bit set?
	BNEQ	225$				;Yes
	BRW	115$				;No error
225$:
	BICW	#ERROR_BIT,(R2)			;Clear error bit
	MOVW	#1,WAIT_COUNT			;Set wait for .5 seconds
	MTPR	#-512,#PR$_NICR			;512 millaseconds wait
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Enable clock
230$:
	TSTW	WAIT_COUNT			;See if timed out
	BNEQ	230$				;No
	BITW	#ERROR_BIT,(R2)			;Is error bit still set?
	BEQL	1000$				;No
	BRW	125$				;Yes error
1000$:
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset cpu
	JSB	RESTORE				;Restore map registers
	RSB					;Return to main logic
	.SUBTITLE 122 Controller Tests
	.SUBTITLE Test 9  - Plot byte swap function test
;*******************************************************
;*  CONTROLLER TEST #9                                *
;*                                                     *
;*  THIS TEST VERIFIES THE BYTE SWAP FUNCTION          *
;*  IN PLOT MODE. THE TEST PERFORMS THE                *
;*  FOLLOWING STEPS:                                   *
;*   1. CHECKS IF OTHER THAN PRINTER ONLY AND          *
;*      AND BRANCHES OUT IF NOT.                       *
;*   2. SETS THE BYTE SWAP FUNCTION BIT AND            *
;*      TESTS THAT IT SET.                             *
;*   3. FILLS BUFFER WITH 377 OCTAL.                   *
;*   4. OUTPUTS 8 SCANS AFTER WHICH IT SETS            *
;*      THE BYTE SWAP BIT AND OUTPUTS 8 MORE           *
;*      SCANS.                                         *
;*   5. DOES STEP 3 FOR 25 ITERATIONS OUTPUTING        *
;*      A CHECKER BOARD IMAGE.                         *
;*******************************************************
CON9:
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If no 122 return
	RSB						;Return to main logic
5$:
	BBC	#V_PRINTER_ONLY,TYPE_PRINTER,10$	;Printer only?
	RSB					;Yes, don't execute
10$:
	CALLG	COM9,CONSOL_OUT			;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,15$	;Form feed?
	JSB	PRINT_RFMD			;Output a remote form feed
15$:
	MOVL	PRINT_CSR,R2			;Get CSR address
	JSB	SET_PLOT_122			;Set plot mode
20$:
	BISW	#SWAP_BIT_122,(R2)		;Set byte swap
	BITW	#SWAP_BIT_122,(R2)		;Bit still set?
	BNEQ	25$				;Yes
	MOVB	#28,MODE			;Set error mode
	MOVB	#3,ERROR_TYPE			;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRB	20$				;Loop on error
25$:
	BICW	#SWAP_BIT_122,(R2)		;Clear byte swap
	MOVW	#^XFF,PLOT_PATTERN		;Plot pattern
	CLRW	PLOT_GEN_FILL			;Full scan fill
	JSB	PLOT_GEN			;Fill plot buffer
	MOVZWL	#25,R11				;Number of cycles
30$:
	MOVZWL	#8,R10				;Number of scan line to output
35$:
	BISW	#DMA_ADDR_122,(R2)		;Set DMA address mode
	MOVAL	PLOT_BUF,R3			;Buffer address
	MOVW	R3,2(R2)			;Load buffer address
	BISW	#DMA_BCNT_122,(R2)		;Set DMA byte count mode
	MNEGW	PLOT_SIZE,2(R2)			;Get byte count negated
	INCW	(R2)				;Start DMA operation
	JSB	CHECK_READY			;Wait for ready
	SOBGTR	R10,35$				;Output number of scans
	BITW	#SWAP_BIT_122,(R2)		;Swap bit set?
	BNEQ	40$				;Yes
	BISW	#SWAP_BIT_122,(R2)		;Set swap bit
	BRB	30$				;Reset scan couniter
40$:
	BICW	#SWAP_BIT_122,(R2)		;Clear byte swap bit
	SOBGTR	R11,30$				;Cycle 25 times
	RSB					;Return to main program
	.SUBTITLE Test 10  - Print byte swap function test
;*******************************************************
;*  CONTROLLER TEST #10                                *
;*                                                     *
;*  THIS TEST VERIFIES THE BYTE SWAP FUNCTION          *
;*  IN PRINT MODE. THE TEST PERFORMS THE               *
;*  FOLLOWING STEPS:                                   *
;*   1. CHECKS IF PLOTTER ONLY, BRANCHES OUT           *
;*      OF TEST IF TRUE.                               *
;*   2. SETS THE BYTE SWAP FUNCTION BIT AND            *
;*      TESTS THAT IT SET.                             *
;*   3. FILLS BUFFER WITH ASCII "X" & "SPACE"          *
;*   4. OUTPUTS A PRINT LINE.                          *
;*   5. SETS BYTE SWAP BIT AND OUTPUTS ONE             *
;*      PRINT LINE.                                    *
;*   6. STEP FOUR IS REPEATED FOR TWENTY               *
;*      FIVE ITERATIONS.                               *
;*******************************************************
CON10:
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If not 122 return
	RSB					;Return to main logic
5$:
	BBC	#V_PLOTTER_ONLY,TYPE_PRINTER,10$	;If plotter only don't test
	RSB					;Don't execute
10$:
	CALLG	COM10,CONSOL_OUT		;Output test message
	MOVL	PRINT_CSR,R2			;Get print CSR
	JSB	SET_PRINT_122			;Set print mode
15$:
	BISW	#SWAP_BIT_122,(R2)		;Set byte swap bit
	BITW	#SWAP_BIT_122,(R2)		;Still set?
	BNEQ	20$				;Yes
	MOVB	#27,MODE			;Set error message
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRB	15$				;Loop on error
20$:
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,25$	;Form feed?
	JSB	PRINT_RFMD			;Output a remote form feed
25$:
	BICW	#SWAP_BIT_122,(R2)		;Clear swap bit
	MOVW	PRINT_SIZE,R3			;# of print characters
	DIVW2	#2,R3				;Convert to words
	MOVW	#^A/ X/,R1
	CLRL	R0				;Initialize index pointer
30$:
	MOVW	R1,PRINT_BUF[R0]
	ACBW	R3,#1,R0,30$			;Fill buffer
	MOVZWL	#25,R11				;Cycle count
	MOVAL	PRINT_BUF,R3			;Buffer address
35$:
	BISW	#DMA_ADDR_122,(R2)		;Set DMA address mode
	MOVW	R3,2(R2)			;Load buffer address
	BISW	#DMA_BCNT_122,(R2)		;Set DMA byte count mode
	MNEGW	PRINT_SIZE,2(R2)		;Load negated byte count
	INCW	(R2)				;Start DMA operation
	JSB	CHECK_READY			;Wait for ready
	BITW	#SWAP_BIT_122,(R2)		;Swap function bit set?
	BNEQ	40$				;Yes
	BISW	#SWAP_BIT_122,(R2)		;Set swap bit
	BRB	35$				;Output another buffer
40$:	BICW	#SWAP_BIT_122,(R2)		;Clear byte swap function bit
	SOBGTR	R11,35$				;Loop 25 times
	RSB					;Return to main logic
	.SUBTITLE Test 11  - Print/plot bit set/reset test
;********************************************************
;*  CONTROLLER TEST #11 					*
;*							*
;*  THIS TEST CHECKS THAT THE PRINT/PLOT BIT CAN BE	*
;*  SET AND RESET.					*
;*							*
;*  PROCEDURE IS:					*
;*	1. SET PLOT MODE AND CHECK THAT PLOT MODE IS SET*
;*	2. SET PRINT MODE AND CHECK THAT PLOT MODE IS	*
;*		RESET.					*
;********************************************************
CON11:
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If not 112 return
	RSB					;return to main logic
5$:
	CMPW	#2,TYPE_PRINTER			;Printer/plotter
	BGTR	30$				;No, skip test
	CALLG	COM11,CONSOL_OUT 		;Output test message
	MOVL	PRINT_CSR,R2			;Get print CSR
	MOVW	#PLOT_BIT_122,R3		;Get print/plot bit
10$:	JSB	CHECK_READY			;Make sure ready
	MOVW	R3,(R2)				;Set plot mode
	JSB	CHECK_READY			;Make sure ready
	BITW	R3,(R2)				;Plot mode set?
	BNEQ	20$				;Yes, go reset bit
	MOVB	#29,MODE			;Error message code
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;No, point to error message
	JSB	ERROR_DISPLAY			;Output error message
	BRB	10$				;Loop on error
20$:	JSB	CHECK_READY			;Make sure ready
	BICW	R3,(R2)				;Reset plot mode
	BITW	R3,(R2)				;Print mode?
	BEQL	30$				;Yes, done with test
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Error type
	JSB	ERROR_DISPLAY			;Output error
	BRW	10$				;Loop on error
30$:	RSB					;Return
	.SUBTITLE Test 12  - Read/write bit function test
;********************************************************
;*  CONTROLLER TEST 12					*
;*							*
;*  THIS TEST CHECKS THE READ/WRITE CAPABILITY OF THE	*
;*  DMA MODE BITS, AND THE ABILITY OF THE RESET ALL	*
;*  FUNCTION TO CLEAR ALL THE SELECT BITS IN THE CSR.	*
;*  PROCEDURE IS:					*
;*	1.SET BAR (01) MODE AND CHECK FOR BAR SET.	*
;*	2.SET BCR (11) MODE AND CHECK FOR BCR SET.	*
;*	3.SET NULL (10) MODE AND CHECK FOR NULL SET.	*
;*	4.SET PLOT,SWAP,SPP,BCR,BITS AND CHECK		*
;*		FOR SET.				*
;*	5.ISSUE RESET ALL AND CHECK FOR CLEAR.		*
;********************************************************
CON12:	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If not 122 return
	RSB					;Return to main logic
5$:
	CALLG	COM12,CONSOL_OUT		;Output test message
10$:	MOVL	PRINT_CSR,R2			;Get csr address
	BISW	#DMA_ADDR_122,(R2)		;Set DMA address mode
	CMPW	#<DMA_ADDR_122!READY_BIT>,(R2)	;Check DMA addr and ready bits
	BEQL	15$				;OK, go set DMA byte count
	MOVB	#30,MODE			;Set error message
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRB	10$				;Loop on error
15$:
	BISW	#DMA_BCNT_122,(R2)		;Set DMA byte count mode
	CMPW	#<DMA_BCNT_122!DMA_ADDR_122!READY_BIT>,(R2) ;Is DMA byt cnt set
	BEQL	20$				;Found set, go set null
	MOVB	#31,MODE			;Set message
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRW	10$				;Loop on error
20$:
	BICW	#DMA_ADDR_122,(R2)		;Set null mode
	CMPW	#<DMA_BCNT_122!READY_BIT>,(R2)	;Check for null and ready
	BEQL	25$				;Null set, go reset all bits
	MOVB	#30,MODE			;Error message code
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRW	10$				;Loop on error
25$:
	BISW	#ALL_BITS_122,(R2)		;Set SPP,swap,plot,bcr bits
	CMPW	#^X3E80,(R2)			;Check for bits set
	BEQL	30$				;Bits set, go reset all bits
	MOVB	#32,MODE			;Set error message code
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRW	10$				;Loop on error
30$:
	BISB	#RESETALL_BIT_122,(R2)		;Issue reset all
	JSB	CHECK_READY			;Wait for reset-all
	CMPW	#READY_BIT,(R2)			;All bits cleared
	BEQL	35$				;Yes, done
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Set error type
	MOVB	#32,MODE			;Set error message
	JSB	ERROR_DISPLAY			;Output error message
	BRW	10$				;Loop on error
35$:	RSB					;Return to main logic
	.SUBTITLE Test 13  - Byte swap test for pio
;********************************************************
;*  CONTROLLER TEST 13					*
;*							*
;*  THIS TEST CHECKS THE SWAP BYTE OPERATION IN PIO MODE*
;*  PROCEDURE IS:					*
;*	1. SEND 'X ' TO PRINTER WITH WORD TFER NOSWAP	*
;*		5 TIMES.				*
;*	2. SEND 'X' TO PRINTER USING BYTE TFER.		*
;*	3. SEND 'X ' TO PRINTER USING WORD TFER SWAP	*
;*		5 TIMES.				*
;*	4. SEND ' ' TO PRINTER USING BYTE TFER.		*
;*	5. REPEAT STEPS 1-4 3 TIMES/LINE FOR 10 LINES	*
;*		ALTERNATING SWAP AND NOSWAP FIRST.	*
;*	6. FOR PLOTTER ONLY, USE 377(8) INSTEAD OF 'X'	*
;*		AND 0 INSTEAD OF ' '.			*
;********************************************************
CON13:	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If not 122 return
	RSB					;Return to main logic
5$:	
	CALLG	COM13,CONSOL_OUT		;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,10$	;Form feed?
	JSB	PRINT_RFMD			;Output remote form feed
10$:
	MOVL	PRINT_CSR,R2			;Get CSR address
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,15$	;If plotter only set plot mode
	JSB	SET_PRINT_122			;Set print mode
	MOVW	#^A/X /,R3			;Put un-swapped data in register
	MOVW	#^A/ X/,R4			;Put swapped data in register
	MOVW	#1,R12				;Repeat line one time
	BRB	17$
15$:	JSB	SET_PLOT_122			;Yes, set plot mode
	MOVZBL	#^XFF,R3			;For plot fill every other byte
	MOVZWL	#^XFF00,R4			;Opposite of register 3
	MOVW	#8,R12				;Repeat line eight times
17$:
	MOVZBL	#10,R11				;Loop for 10 times
20$:
	MOVW	R12,R8				;Move count to R13
22$:
	MOVZBL	#3,R10				;Three sets of lines
25$:
	JSB	CON13_SUB			;Print or plot line five times
	MOVB	R3,2(R2)			;Send one character
	JSB	CHECK_READY			;Wait for ready
	JSB	CON13_SUB 			;Print or plot 5 more times
	MOVB	R4,2(R2)			;Send last character
	SOBGTR	R10,25$				;Done with line?
	JSB	CHECK_READY			;Wait for ready
	BISB	#LNTERM_BIT_122,(R2)		;Issue remote line term.
	JSB	CHECK_READY			;Wait for ready
	SOBGTR	R8,22$				;Done with line?
	MOVW	R3,R6				;Switch un-swapped data in register
	MOVW	R4,R3				;with swapped data in register
	MOVW	R6,R4				;to reverse pattern
	SOBGTR	R11,20$				;Loop till test done
	RSB					;Return to main logic
CON13_SUB:
	MOVZBL	#5,R9				;Number of times to send text
5$:
	MOVW	R3,2(R2)			;Send text
	JSB	CHECK_READY			;Wait for ready
	SOBGTR	R9,5$				;Loop till done
	BITW	#SWAP_BIT_122,(R2)		;Swap bit on?
	BEQL	10$				;No, set it
	BICW	#SWAP_BIT_122,(R2)		;Yes, clear it
	RSB					;Return
10$:
	BISW	#SWAP_BIT_122,(R2)		;Set swap for next time
	RSB					;Return
	.SUBTITLE Test 14  - Bit write lock test
;********************************************************
;*  CONTROLLER TEST #14					*
;*							*
;*  THIS TEST CHECKS THE WRITE LOCK PLACED ON BITS	*
;*  8-14 WHILE DMA IS IN OPERATION.  THIS TEST IS	*
;*  CONDUCTED WITH THE PRINTER/PLOTTER TURNED OFF IN	*
;*  ORDER TO ALLOW PLENTY OF TIME TO TEST WITHOUT	*
;*  DANGER OF DMA COMPLETING. PROCEDURE IS:		*
;*	1.ASK THE USER TO TURN THE PRINTER/PLOTTER OFF.	*
;*	2.START DMA OPERATION.				*
;*	3.TRY TO SET PIO,SPP,PLOT,SWAP      		*
;*	4.CHECK FOR 114001, ELSE ERROR. (BCR,OFFLINE,	*
;*		DMA ACTIVE).				*
;*	5.ISSUE RESET ALL TO STOP DMA			*
;*	6.ASK USER TO TURN PLOTTER ON, CHECK FOR READY.	*
;********************************************************
CON14:	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If not 122 skip
	RSB					;Don't execute test
5$:
	MOVL	PRINT_CSR,R2			;Get print CSR
	JSB	SET_PRINT_122			;Set print mode
	CALLG	COM14,CONSOL_OUT		;Output test message
10$:	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupts
	CALLG	OPIN2,CONSOL_OUT		;Turn off printer/plotter
	CALLG	OPIN7,RQEST			;And press return
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupts
	BISW	#DMA_ADDR_122,(R2)		;Set DMA address mode
	MOVAL	PRINT_BUF,R3			;Buffer address
	MOVW	R3,2(R2)			;Load buffer address
	BISW	#DMA_BCNT_122,(R2)		;Set DMA byte count mode
	CLRW	2(R2)				;Load with 0 byte count(=-32768)
	INCB	(R2)				;Start DMA
	MOVW	#^X2600,(R2)			;Try to set PIO,SPP,SWAP,PLOT
	CMPW	#^X9801,(R2)			;Check for BCR,DMA GO,not ready
	BEQL	15$				;Branch if ok
	MOVB	#32,MODE			;Set error message code
	MOVB	#BIT_ON_ADM,ERROR_TYPE		;Set error type
	JSB	ERROR_DISPLAY			;Output error message
	BRW	10$				;Loop on error
15$:
	BISB	#RESETALL_BIT_122,(R2)		;Issue remote reset
	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interupts
	CALLG	OPIN3,CONSOL_OUT		;Turn on plotter
	CALLG	OPIN7,RQEST			;Wait for plotter turned on
	MTPR	#INTR_ENABL,#PR$_RXCS		;Enable console interrupts
	CMPW	#READY_BIT,(R2)			;Ready
	BEQL	25$				;Yes
	MOVB	#BIT_OFF_ADM,ERROR_TYPE		;Set error type
	MOVB	#17,MODE			;Set message code
	JSB	ERROR_DISPLAY			;Output error message
	BRW	10$				;Loop on error
25$:
	RSB					;Return to main logic
	.SUBTITLE Test 15  - Null remote function test
;********************************************************
;*  CONTROLLER TEST #15					*
;*							*
;*  THIS TEST CHECKS THE NULL REMOTE FUNCTION CODE	*
;*  (111) TO MAKE SURE IT IS NOT PERFORMING ANY REMOTE	*
;*  FUNCTIONS.  PROCEDURE IS:				*
;*	1. LOAD AN 'A' (377(8) FOR PLOTTER ONLY)	*
;*	2. ISSUE REMOTE NULL 10 TIMES			*
;*	3. LOAD A 'B' (1(8) FOR PLOTTER ONLY)		*
;*	4. ISSUE A REMOTE LINE TERMINATE		*
;*	5. REPEAT STEPS 1-4 10 TIMES			*
;********************************************************
CON15:	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,40$	;If not 122 skip
	CALLG	COM15,CONSOL_OUT		;Output test message
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,5$	;If no form feed skip
	JSB	PRINT_RFMD			;Issue remote form feed
5$:
	MOVZBL	#10,R11				;Loop ten times
	MOVL	PRINT_CSR,R2			;Get CSR address
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,10$	;If plotter only skip print setup
	JSB	SET_PRINT_122			;Set print mode
	MOVB	#^A/A/,R3			;Text buffer one
	MOVB	#^A/B/,R4			;Text for buffer two
	BRB	20$
10$:
	JSB	SET_PLOT_122			;Set plot mode
	MOVZBL	#^XFF,R3			;Plot pattern number one
	MOVZBL	#^X01,R4			;Plot pattern number two
20$:
	MOVB	R3,2(R2)			;Transfer 'A' or 'FF' hex
	JSB	CHECK_READY			;Wait for ready
	MOVZBL	#10,R10				;Loop count
30$:
	BISB	#NULL_BIT_122,(R2)		;Issue remote null
	JSB	CHECK_READY			;Wait for ready
	SOBGTR	R10,30$				;Issue null 5 times
	MOVB	R4,2(R2)				;Transfer a 'B' or '252'
	JSB	CHECK_READY			;Wait for ready
	BISB	#LNTERM_BIT_122,(R2)		;Issue remote line terminate
	JSB	CHECK_READY			;Wait for ready
	SOBGTR	R11,20$				;Loop till done
40$:
	RSB					;Return to main logic
	.PAGE
	.SUBTITLE Print tests
	.SUBTITLE Test 1  - Full buffer print rotate test
;************************************************
;* Print test #1				*
;*						*
;* This is a full buffer print rotate test.	*
;* Test will rotate each character thru each	*
;* print position.				*
;************************************************
PRN1:
	CALLG	PRM1,CONSOL_OUT			;Output test message
	MOVZWL	PRINT_SIZE,R11			;Set up loop count
	JSB	CHAR_GEN			;Generate character buffer
	JSB	PRINT_SETUP			;Setup for print
5$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
	MOVZWL	FILL_COUNT,R0			;Get fill count
	DECL	R0				;Minus 1 character
	MOVB	PRINT_BUF,R6			;Save first character in buffer
	MOVC5	R0,PRINT_BUF+1,R6,FILL_COUNT,PRINT_BUF	;Shift left 1 char.
	SOBGTR	R11,5$				;Loop till characters rotated
	RSB					;Return to main logic
	.SUBTITLE Test 2  - Remote buffer clear test
;************************************************
;* Print test #2				*
;*						*
;* This is the remote buffer clear test		*
;* for print. message "buffer not cleared"	*
;* is sent to printer/plotter followed by a	*
;* remote clear. Then "buffer cleared" is sent	*
;* to the printer followed by a remote line	*
;* terminate. test will be repeated 10		*
;* times.					*
;************************************************
PRN2:
	CALLG	PRM2,CONSOL_OUT			;Output test message
	MOVZBL	#10,R11				;Set up loop count
5$:
	CALLG	PRN2_MESS_PRM,PRINT_MESS	;Print message on printer
	MOVB	#REM_CLEARPR,MODE		;Select remote clear
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer/plotter
	CALLG	PRN2A_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Issue a remote line terminate
	SOBGTR	R11,5$				;Repeat 10 times
	RSB					;Return to main logic
	.SUBTITLE Test 3  - Remote reset test
;************************************************
;* Print test #3				*
;*						*
;* This is the remote reset test for		*
;* print. "remote reset test" is sent to	*
;* printer 9 times followed by a remote		*
;* line terminate. Then "buffer not reset"	*
;* is sent to printer. Then a remote reset	*
;* is issued to printer. Then the message	*
;* "buffer reset test" is issued to		*
;* printer followed by a remote line		*
;* terminate. The messag "buffer not		*
;* reset" should not be printed.		*
;************************************************
PRN3:
	CALLG	PRM3,CONSOL_OUT			;Output test message
	MOVZBL	#9,R11				;Loop count
5$:
	CALLG	PRN3_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Terminate line
	SOBGTR	R11,5$				;Output 9 times
	CALLG	PRN3A_MESS_PRM,PRINT_MESS	;Print message on printer
	MOVB	#REM_RESETPR,MODE		;Remote reset request
	JSB	PRINTER_PLOTTER_DRIVER		;Rest all buffers
	CALLG	PRN3_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Terminate line
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,10$	;If not 122 return
	RSB					;Return to main logic
10$:
	MOVL	PRINT_CSR,R2			;Get print csr
	MOVZBL	#9,R11				;Loop count
15$:
	CALLG	PRN3_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Terminate line
	SOBGTR	R11,15$				;Output 9 times
	CALLG	PRN3A_MESS_PRM,PRINT_MESS	;Print message on printer
	MOVB	#RESETALL_BIT_122,(R2)		;Remote reset all
	JSB	CHECK_READY			;Wait for ready
	CALLG	PRN3_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Terminate line
	RSB					;Return to main logic
	.SUBTITLE Test 4  - Line terminate test
;************************************************
;* Print test #4				*
;*						*
;* This is the line terminate test for		*
;* print. the following occurs:			*
;*						*
;* 1. "REMOTE LINE TERMINE" sent to print	*
;*     buffer.					*
;*						*
;* 2. Remote line terminate issued.		*
;*						*
;* 3. If printer over 124 character set skip	*
;*    to step 9.				*
;*						*
;* 4. "CR LINE TERMINATE" sent to print		*
;*    buffer followed by ascii carriage	return.	*
;*						*
;* 5. "LF LINE TERMINATE" sent to print		*
;*     buffer followed by ascii line feed.	*
;*						*
;* 6. "LF LF LINE TERMINATE" sent to print	*
;*    buffer followed by two ascii line		*
;*    feed characters.				*
;*						*
;* 7. "LF CR LINE TERMINATE" sent to print	*
;*    buffer followed by ascii carriage		*
;*    return and line feed.			*
;* 8. "CR LF LINE TERMINATE" sent to print	*
;*    buffer followed by ascii line feed	*
;*    and carriage return.			*
;* 9. "End of PR04" is sent to print		*
;*    buffer followed by a remote line		*
;*    terminate.				*
;************************************************
PRN4:
	CALLG	PRM4,CONSOL_OUT			;Output test message
	MOVZBL	#3,R11				;Setup repeat count
	CMPW	MAX_CHAR_SIZE,CHAR_SIZE		;Character set >124?
	BLSS	5$				;Yes skip initialization
	MOVB	CARG_RET,PRN4A_MESS_TERM	;Store carriage return
	MOVB	LINE_FEED,PRN4B_MESS_TERM	;Store line feed
	MOVW	LFLF,PRN4C_MESS_TERM		;Store lf lf
	MOVW	LFCR,PRN4D_MESS_TERM		;Store lf cr
	MOVW	CRLF,PRN4E_MESS_TERM		;Store cr lf
5$:
	CALLG	PRN4_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Remote line terminate
	CMPW	MAX_CHAR_SIZE,CHAR_SIZE		;Character set > 124?
	BLSS	10$				;Yes
	CALLG	PRN4A_MESS_PRM,PRINT_MESS	;Print message on printer
	CALLG	PRN4B_MESS_PRM,PRINT_MESS	;Print message on printer
	CALLG	PRN4C_MESS_PRM,PRINT_MESS	;Print message on printer
	CALLG	PRN4D_MESS_PRM,PRINT_MESS	;Print message on printer
	CALLG	PRN4E_MESS_PRM,PRINT_MESS	;Print message on printer
10$:
	SOBGTR	R11,5$				;Loop 3 times
	CALLG	PRN4F_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_LNTERM			;Terminate line
	RSB					;Return to main logic
	.SUBTITLE Test 5  - Full buffer terminate test
;************************************************
;* Print test #5				*
;*						*
;* This is the full buffer terminate test	*
;* for print. A full line of "l" is sent	*
;* to printer/plotter followed by a CR/LF.	*
;* The ascii control should be ignored.		*
;* This test is repeated 10 times.		*
;************************************************
PRN5:
	CALLG	PRM5,CONSOL_OUT			;Output test message
	MOVZBL	#10,R11				;Set loop count
	JSB	PRINT_SETUP			;Initialize for print call
	MOVC5	#0,PRINT_BUF,#^A/L/,PRINT_SIZE,PRINT_BUF ;Fill print buffer
	MOVB	CARG_RET,(R3)+			;Store carriage return
	MOVB	LINE_FEED,(R3)			;Store line feed
5$:
	ADDW	#2,COUNT			;Include cr and lf in count
	CMPW	CHAR_SIZE,#124			;Character set > 124?
	BGTR	10$				;Yes skip code
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
10$:
	SUBW	#2,COUNT			;Exclude cr/lf
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
	SOBGTR	R11,5$				;Loop till done
	RSB					;Return to main logic
	.SUBTITLE Test 6  - Formfeed test
;************************************************
;* Print test #6				*
;*						*
;* This is the formfeed test for print.		*
;* The following steps are performed:		*
;*						*
;* 1."FF-ASCII" followed by an ascii		*
;*    formfeed is sent to printer/plotter.	*
;*    This step is skipped if the		*
;*    character set size is greater than	*
;*    96 character set.				*
;*						*
;*   2."FF-REMOTE" is sent to printer/plotter	*
;*     followed by a remote formfeed.		*
;*						*
;*   3. test repeates steps 1-2 two times.	*
;************************************************
PRN6:
	CALLG	PRM6,CONSOL_OUT			;Output test message
	MOVZBL	#2,R11				;Setup repeat count
	CMPW	MAX_CHAR_SIZE,CHAR_SIZE		;Character set > 124?
	BLSS	10$				;Yes exit to main logic
	MOVB	FORM_FEED,PRN6_MESS_TERM	;Store ascii form feed in message
5$:
	CALLG	PRN6_MESS_PRM,PRINT_MESS	;Print message on printer
	CALLG	PRN6A_MESS_PRM,PRINT_MESS	;Print message on printer
	JSB	PRINT_RFMD			;Issue remote form feed
	SOBGTR	R11,5$				;Repeat 2 times
10$:
	RSB					;Return to main logic
	.SUBTITLE Test 7  - EOT test
;************************************************
;* print test #7				*
;*						*
;* This is the EOT test for print. the		*
;* following steps are performed:		*
;*						*
;* 1."EOT-ASCII" followed by an ascii EOT is	*
;*    sent to the printer/plotter. this step	*
;*    is skipped if character set greater than	*
;*    96 character set.				*
;*						*
;* 2."EOT-REMOTE" followed by remote EOT is	*
;*    sent to printer/plotter.			*
;*						*
;*   3. steps 1-2 are repeated two times.	*
;************************************************
PRN7:
	CALLG	PRM7,CONSOL_OUT			;Output test message
	MOVZBL	#2,R11				;Setup repeat count
5$:
	CMPW	#MAX_CHAR_SIZE,CHAR_SIZE	;Character set > 124?
	BLSS	15$				;Yes branch
	MOVB	END_OF_TRAN,PRN7_MESS_TERM	;Store ascii EOT in message
	MOVZBL	#32,R10				;Setup repeat count
10$:
	JSB	PRINT_LNTERM			;Issue remote line terminate
	SOBGTR	R10,10$				;Repeat 32 times
	CALLG	PRN7_MESS_PRM,PRINT_MESS	;Print message on printer
15$:
	MOVZBL	#32,R10				;Setup repeat count
20$:
	JSB	PRINT_LNTERM			;Issue remote line terminate
	SOBGTR	R10,20$				;Repeat 32 times
	CALLG	PRN7A_MESS_PRM,PRINT_MESS	;Print message on printer
	MOVB	#REM_EOTPR,MODE			;Select remote line terminate
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer/plotter
	SOBGTR	R11,5$				;Repeat 2 times
	RSB					;Return to main logic
	.PAGE
	.SUBTITLE Plot tests
	.SUBTITLE Test 1  - Full buffer plot test
;************************************************
;* Plot test #1					*
;*						*
;* This is a full buffer plot test.		*
;*						*
;* 1. Test will send enough full plot scans	*
;*    for 2 inches of plot. The plot pattern is	*
;*    all bits on.				*
;*						*
;* 2. Test will then send another 2 inches of	*
;*    full plot scans with all bits off.	*
;*						*
;* 3. Steps 1-2 are repeated twice.		*
;************************************************
PLT1:
	CALLG	PLM1,CONSOL_OUT			;Output test message
	MOVZBL	#2,R11				;Setup repeat count
	JSB	PLOT_SETUP			;Setup for plot transfer
5$:
	MOVC5	#0,PLOT_BUF,#^XFF,PLOT_SIZE,PLOT_BUF
	CLRL	R10				;Clean register
	MULW3	#2,NIBSPR_INCH,R10		;Count for two inches
10$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output a solid line
	SOBGTR	R10,10$				;Produce 2 inches of solid plot
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF
	CLRL	R10				;Clean register
	MULW3	#2,NIBSPR_INCH,R10		;Count for two inches
15$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output 2 inches of blank scans
	SOBGTR	R10,15$				;Loop till d1
	SOBGTR	R11,5$				;Repeat 2 times
	RSB					;Return to main logic
	.SUBTITLE Test 2  - Single bit rotate test
;************************************************
;* Plot test #2					*
;*						*
;* This is the single bit plot rotate test.	*
;* The test will rotate a single bit		*
;* across the page in plot mode for the		*
;* number of plot bits for 1 scan.		*
;************************************************
PLT2:
	CALLG	PLM2,CONSOL_OUT			;Output test message
	JSB	PLOT_SETUP			;Setup for plot
	MOVC5	#0,PLOT_BUF,#^XFF,PLOT_SIZE,PLOT_BUF
	JSB	PRINTER_PLOTTER_DRIVER		;Output bar to plotter
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF	;Zero buffer
	MOVAL	PLOT_BUF,R2			;Buffer to fill
	MOVZWL	PLOT_SIZE,R11			;Number of plot bytes
	MOVL	R11,R4				;Get byte count
	DECL	R4				;Start from zero
	BISB	#1,PLOT_BUF(R4)			;Set last bit of buffer
	MOVZBL	#^X40,R5			;Initialize plot bit
	MOVZBL	#7,R10				;Rotate loop count
5$:
	MOVB	R5,(R2)				;Store plot pattern
	BISB	#^X80,PLOT_BUF			;1st bit of buffer set
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	ROTL	#RIGHT_ONE,R5,R5		;Rotate right 1 bit
	CMPL	R11,#1				;Last byte?
	BNEQ	10$				;No
	INCB	R5				;Set last bit
	CMPL	R10,#2				;Last bit?
	BEQL	15$				;Yes
10$:
	SOBGTR	R10,5$				;Not finished yet
	MOVZBL	#8,R10				;Reset loop count
	CLRB	(R2)+				;Zero plot byte
	MOVZBL	#^X80,R5			;Reset plot pattern
	DECL	R11				;Decrement byte count
	BRW	5$				;Do next byte
15$:
	MOVC5	#0,PLOT_BUF,#^XFF,PLOT_SIZE,PLOT_BUF
	JSB	PRINTER_PLOTTER_DRIVER		;Output bar to plotter
	RSB					;Return to main logic
	.SUBTITLE Test 3  - Sail plot test
;************************************************
;* Plot test #3					*
;*						*
;* This is the sail plot test. The test will	*
;* start with the left most bit and increase	*
;* a bit for each scan. This will continue	*
;* the number of plot bits for one scan. The	*
;* number of byte output per scan will also	*
;* increase by one byte for every 8 scans of	*
;* output.					*
;************************************************
PLT3:
	CALLG	PLM3,CONSOL_OUT			;Output test message
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF	;Zero buffer
	MOVZWL	PLOT_SIZE,R11			;Get number of byte for scan
	MOVAL	PLOT_BUF,R2			;Address of buffer
	JSB	PLOT_SETUP			;Setup for plot
	MOVW	#1,COUNT			;Start with one byte
5$:
	MOVZBL	#^X80,R3			;Plot pattern
	MOVZBL	#8,R10				;Loop count
10$:
	BISB	R3,(R2)				;Set next bit
	MOVB	#PLOT_MODE,MODE			;Select plot mode
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	JSB	PLOT_LNTERM			;Terminate plot scan
	ROTL	#-1,R3,R3			;Shift right 1
	SOBGTR	R10,10$				;Set next bit
	INCL	COUNT				;Increase one byte
	INCL	R2				;Bump address
	SOBGTR	R11,5$				;Finished sail?
	RSB					;Yes
	.SUBTITLE Test 4  - Cross talk test
;************************************************
;* Plot test #4					*
;*						*
;* This is the plot test to check cross		*
;* talk. Test will send a full scan of		*
;* plot data with every other plot byte		*
;* have all bits off. The test is repeated	*
;* the number of plot nibs/inch.		*
;************************************************
PLT4:
	CALLG	PLM4,CONSOL_OUT			;Output test message
	MOVZWL	NIBSPR_INCH,R11			;Initialize loop count
	DIVL	#2,R11				;
	MULW	#5,R11				;2.5 inches of plot
	MOVL	R11,R10				;Save for later
	JSB	PLOT_SETUP			;Setup for plot transfers
	CLRW	PLOT_GEN_FILL			;Use entire buffer
	MOVW	#^XFF,PLOT_PATTERN		;Fill every other byte
	JSB	PLOT_GEN			;Fill plot buffer
5$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R11,5$				;Plot for 2.5 inches
	MOVW	#^XFF00,PLOT_PATTERN		;Plot pattern
	JSB	PLOT_GEN			;Fill plot buffer
10$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R10,10$				;Loop for 2.5 inches of plot
	RSB					;Return to main logic
	.SUBTITLE Test 5  - Nib test
;************************************************
;* Plot test #5					*
;*						*
;* This is the nib test routine. A single	*
;* nib in each byte is turned on for 1		*
;* inch of plot. The first nib turned on	*
;* is the first nib to the left in each		*
;* byte. The nib is then turned off and		*
;* next nib to the right is turned on. the	*
;* test is repeated until all 8 nibs have	*
;*  been turned on.				*
;************************************************
PLT5:
	CALLG	PLM5,CONSOL_OUT			;Output test message
	JSB	PLOT_SETUP			;Setup for plotting
	CLRW	PLOT_GEN_FILL			;Fill entire buffer
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF	;Zero buffer
	MOVZBL	#64,R6				;Byte to start with
	MOVL	R6,R7				;Save current value
	MOVZBL	#5,R10				;Loop count
5$:
	BISB	#1,PLOT_BUF(R6)			;Set bit
	ADDL	R7,R6				;Bump index
	CMPW	R6,PLOT_SIZE			;Finished?
	BLEQ	5$				;No
	CLRL	R3				;Clean register
	DIVW3	#2,NIBSPR_INCH,R3		;Get loop count
10$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R3,10$				;Output one half inch
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF	;Zero buffer
	DIVW	#2,R7				;Next increment
	MOVL	R7,R6				;Set for next loop
	SOBGTR	R10,5$				;Do next loop
	MOVW	#^X8080,PLOT_BUF		;Setup initial pattern
	MOVZBL	#8,R11				;Set loop count
15$:
	MOVZWL	PLOT_BUF,PLOT_PATTERN		;Get plot pattern
	JSB	PLOT_GEN			;Store new plot pattern
	CLRL	R10				;Clean register
	DIVW3	#2,NIBSPR_INCH,R10		;Half inch of plot
20$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R10,20$				;Output half inch of plot
	ROTL	#RIGHT_ONE,PLOT_BUF,PLOT_BUF	;Rotate right 1
	SOBGTR	R11,15$				;Rotate all 8 bits
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF	;Zero buffer
	MOVZBL	#4,R6				;Byte to start with
	MOVL	R6,R7				;Save
	MOVZBL	#5,R10				;Loop count
25$:
	BISB	#1,PLOT_BUF(R6)			;Set bit
	ADDL	R7,R6				;Add offset
	CMPW	R6,PLOT_SIZE			;Buffer full?
	BLEQ	25$				;No
	DIVW3	#2,NIBSPR_INCH,R3		;Get plot length
30$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R3,30$				;Output half inch of plot
	MOVC5	#0,PLOT_BUF,#0,PLOT_SIZE,PLOT_BUF	;Zero buffer
	MULW	#2,R7				;Next increment
	MOVL	R7,R6				;Set for next loop
	SOBGTR	R10,25$				;Do next loop
	RSB					;Return to main logic
	.SUBTITLE Test 6  - Remote clear test
;************************************************
;* Plot test #6					*
;*						*
;* This test is the remote clear test for	*
;*  plot. Tthe following steps take place:	*
;*						*
;* 1. Half a scan of solid plot data is sent	*
;*    to the plotter followed be a remote	*
;*    clear.					*
;*						*
;* 2. Another half scan of every other byte	*
;*    on is sent to the plotter followed by	*
;*    a remote line terminate.			*
;*						*
;* 3. Steps 1-2 are repeated 10 times.		*
;************************************************
PLT6:
	CALLG	PLM6,CONSOL_OUT			;Output test message
	JSB	PLOT_SETUP			;Setup for plot transfers
	CLRW	PLOT_GEN_FILL			;Fill entire buffer
	MOVW	#^XFF00,PLOT_PATTERN		;Pattern to use
	MOVZBL	#10,R11				;Setup loop count
	DIVW3	#2,PLOT_SIZE,COUNT		;Get plot_size/2
5$:
	MOVC5	#0,PLOT_BUF,#^XFF,PLOT_SIZE,PLOT_BUF	;Fill buffer
	MOVB	#PLOT_MODE,MODE			;Select plot transfers
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	MOVB	#REM_CLEARPL,MODE		;Select remote clear for plot
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	MOVB	#PLOT_MODE,MODE			;Select plot transfers
	JSB	PLOT_GEN			;Fill plot buffer
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	JSB	PLOT_LNTERM			;Issue remote line terminate
	SOBGTR	R11,5$				;Repeat 10 times
	RSB					;Return to main logic
	.SUBTITLE Test 7  - Remote formfeed test
;************************************************
;* Plot test #7					*
;*						*
;* This is the remote form feed test for	*
;* plot. The test sends 10 scans of a solid	*
;* plot pattern followed by a remote form feed. *
;* This sequence is performed twice.		*
;************************************************
PLT7:
	CALLG	PLM7,CONSOL_OUT			;Output test message
	MOVZBL	#2,R11				;Setup loop count
	MOVC5	#0,PLOT_BUF,#^XFF,PLOT_SIZE,PLOT_BUF
5$:
	JSB	PLOT_SETUP			;Setup for plot transfers
	MOVZBL	#10,R10				;Loop count
10$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R10,10$				;Loop for 10 times
	MOVB	#REM_FRMFDPL,MODE		;Remote form feed for plot
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R11,5$				;Repeat twice
	RSB					;Return to main logic
	.SUBTITLE Test 8  - Remote EOT test
;************************************************
;* Plot test #8					*
;*						*
;* This is the remote EOT test for plot.	*
;* The test issues enough plot remote line	*
;* terminates to position writing head half	*
;* way down page, then sending 10 full scans	*
;* of solid plot pattern followed by a remote	*
;* EOT. The sequence is performed twice.	*
;************************************************
PLT8:
	CALLG	PLM8,CONSOL_OUT			;Output test message
	MOVZBL	#2,R11				;Seup repeat count
	MOVC5	#0,PLOT_BUF,#^XFF,PLOT_SIZE,PLOT_BUF	;Fill buffer
5$:
	CLRL	R10				;Clean register
	MULW3	#4,NIBSPR_INCH,R10		;Counter for 4 inches of plot
10$:
	JSB	PLOT_LNTERM			;Issue a remote line terminate
	SOBGTR	R10,10$				;Plot for 4 inches
	MOVZBL	#10,R10				;Setup loop counter
	JSB	PLOT_SETUP			;Setup for plot transfers
15$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R10,15$				;Repeat 10 times
	MOVB	#REM_EOTPL,MODE			;Select remote EOT for plot
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R11,5$				;Repeat twice
	RSB					;Return to main logic
	.PAGE
	.SUBTITLE Print/plot tests
	.SUBTITLE Test 1  - Alternate print/plot test
;************************************************
;* Print/plot test #1				*
;*						*
;* This test checks the printer/plotters	*
;* capability of changing print to plot modes.	*
;* the following steps take place:		*
;*						*
;* 1. Send full buffer of print data to  the	*
;*    printer.					*
;*						*
;* 2. Send 16 scans of solid plot data to the	*
;*    plotter.					*
;*						*
;* 3. Steps 1-2 are repeated 10 times.		*
;************************************************
PPL1:
	CALLG	PPM1,CONSOL_OUT			;Output test message
	MOVW	#^XFF00,PLOT_PATTERN		;Plot pattern
	CLRW	PLOT_GEN_FILL			;Full buffer fill
	JSB	PLOT_GEN			;Generate plot pattern
	JSB	CHAR_GEN			;Generate character buffer
	MOVZBL	#10,R11				;Loop counter
5$:
	JSB	PRINT_SETUP			;Setup for print
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
	MOVZBL	#16,R10				;Loop count
	JSB	PLOT_SETUP			;Setup for plot transfers
10$:
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	SOBGTR	R10,10$				;Repeat 16 times
	SOBGTR	R11,5$				;Repeat test 10 times
	RSB					;Return to main logic
	.PAGE
	.SUBTITLE SPP tests
	.SUBTITLE Test 1  - SPP bar test
;************************************************
;* SPP test #1					*
;*						*
;* This test checks the SPP option of the	*
;* printer/plotter. the following steps take	*
;* place:					*
;*						*
;* 1. Printer/plotter in put into print and	*
;*    SPP modes.				*
;*						*
;* 2. A full buffer of print is sent to the	*
;*    printer.					*
;*						*
;* 3. A 16 by number of scans for SPP is sent	*
;*    to the plotter. a solid plot word is	*
;*    is used after 16 scans is sent to the	*
;*    plotter. that word is cleared and the	*
;*    next word to the right is turned on. a	*
;*    remote line terminate for plot is used	*
;*    for each scan.				*
;*						*
;* 4. steps 2-3 are repeated until the number	*
;*    of bytes per scan divided by 2 occurs.	*
;************************************************
SPP1:
	CALLG	SPM1,CONSOL_OUT			;Output test message
	JSB	CHAR_GEN			;Generate character buffer
	MOVAL	PLOT_BUF,R2			;Plot buffer address
	MOVZBL	#2,R3				;Initial plot byte count
	MOVB	#ENTER_SPPPR,MODE		;Select SPP print
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
5$:
	CMPW	R3,PLOT_SIZE			;Finished?
	BGTR	15$				;Yes
	JSB	PRINT_SETUP			;Setup for print
	MOVW	SPPLN_SIZE,COUNT		;Byte count for SPP
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
	MOVZWL	SCANPR_CHAR,R10			;Loop count
	MOVW	#-1,(R2)			;Plot pattern
10$:
	JSB	PLOT_SETUP			;Setup for plot transfers
	MOVW	R3,COUNT			;Plot byte count
	JSB	PRINTER_PLOTTER_DRIVER		;Output to plotter
	JSB	PLOT_LNTERM			;Issue a remote lint terminate
	SOBGTR	R10,10$				;Repeat till defined
	CLRW	(R2)+				;Clear plot pattern
	ADDW	#2,R3				;Bump plot byte count
	BRW	5$				;Check if finished?
15$:
	MOVB	#XIT_SPPPR,MODE			;Select exit SPP mode
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
	RSB					;Return to main logic
	.PAGE
	.SUBTITLE Utilities
;*************************************************
;*  Driver setup for print from print_buf	 *
;*************************************************
PRINT_SETUP:
	MOVB	#PRINT_MODE,MODE		;Print request
	MOVAL	PRINT_BUF,LOC			;Buffer address
	MOVW	PRINT_SIZE,COUNT		;Byte count
	RSB					;Return to caller
;************************************************
;*  Driver setup for print from messages	*
;************************************************
	.ENTRY	PRINT_MESS,^M<>
	MOVB	#PRINT_MODE,MODE		;Select print mode
	MOVL	(AP),LOC			;Address of text to transfer
	MOVW	4(AP),COUNT			;Number of bytes to transfer
	JSB	PRINTER_PLOTTER_DRIVER		;Output to printer
	RET					;Return to caller
;************************************************
;*  Remote formfeed routine for print		*
;************************************************
PRINT_RFMD:
	MOVB	#REM_FRMFDPR,MODE		;Remote formfeed for print
	JSB	PRINTER_PLOTTER_DRIVER		;Output remote formfeed
	RSB					;Return to caller
;************************************************
;*  Remote line terminate routine for print	*
;************************************************
PRINT_LNTERM:
	MOVB	#REM_LNTRMPR,MODE		;Remote line terminate print
	JSB	PRINTER_PLOTTER_DRIVER		;Output line terminate
	RSB					;Return to caller
;************************************************
;*  Set print mode for 122 controller		*
;************************************************
SET_PRINT_122:
	PUSHR	#^M<R2>				;Save register 2
	MOVL	PRINT_CSR,R2			;Get CSR address for 122
	JSB	CHECK_READY			;Wait for ready
	BICW	#PLOT_BIT_122,(R2)		;Set print mode
	JSB	CHECK_READY			;Wait for ready
	POPR	#^M<R2>				;Rsetore register 2
	RSB					;Return to calling routine
;************************************************
;*  Set plot mode for 122 controller		*
;************************************************
SET_PLOT_122:
	PUSHR	#^M<R2>				;Save register 2
	MOVL	PRINT_CSR,R2			;Get CSR address for 122
	JSB	CHECK_READY			;Wait for ready
	BISW	#PLOT_BIT_122,(R2)		;Set plot mode
	JSB	CHECK_READY			;Wait for ready
	POPR	#^M<R2>				;Rsetore register 2
	RSB					;Return to calling routine
;************************************************
;*  Driver setup for plot data			*
;************************************************
PLOT_SETUP:
	MOVB	#PLOT_MODE,MODE			;Plot mode
	MOVAL	PLOT_BUF,LOC			;Buffer address
	MOVW	PLOT_SIZE,COUNT			;Byte count
	RSB					;Return to caller
;************************************************
;*  Remote line terminate for plot		*
;************************************************
PLOT_LNTERM:
	MOVB	#REM_LNTRMPL,MODE		;Remote line terminate plot
	JSB	PRINTER_PLOTTER_DRIVER		;Output remote line terminate
	RSB					;Return to caller
;************************************************
;*  Character buffer generate subroutine	*
;************************************************
CHAR_GEN:
	PUSHR	#^M<R2,R3,R4,R5>		;Save registers
	MOVZWL	FILL_COUNT,R2			;Get fill count
	MOVAL	PRINT_BUF,R3			;Initialize buffer pointer
5$:
	MOVZWL	CHAR_SIZE,R4			;Get character set size
	CMPW	R4,#96				;>96?
	BGTR	10$				;Yes
	MOVZBL	#<BLANK-1>,R5			;Ascii blank
	BRB	30$				;Generate bufffer
10$:
	CLRL	R5				;Start from 0
15$:
	CMPW	CHAR_SIZE,#124.			;124 character set?
	BNEQ	20$				;No
	CMPB	R5,LINE_FEED			;Line feed?
	BEQL	30$				;Yes don't store in buffer
	CMPB	R5,CARG_RET			;Carraige return?
	BEQL	30$				;Yes don't store in buffer
	CMPB	R5,FORM_FEED			;Form feed?
	BEQL	30$				;Yes don't store in buffer
	CMPB	R5,END_OF_TRAN			;End of transmission?
	BEQL	30$				;Yes don't store in buffer
	CMPB	R5,#CAN				;Cancel character?
	BEQL	30$				;Yes ignore
20$:
	MOVB	R5,(R3)+			;Store data byte in buffer
25$:
	DECW	R2				;Buffer full
	BEQL	35$				;Yes
30$:
	DECL	R4				;Finished with character set?
	BEQL	5$				;Yes
	INCW	R5				;Bump to next data byte
	BRW	15$				;Repeat with next data byte
35$:
	POPR	#^M<R2,R3,R4,R5>		;Restore registers
	RSB					;Return to calling program
;************************************************
;* Plot buffer fill routine			*
;*						*
;* Will fill buffer with pattern in reg 0	*
;* reg 1 contains number of byte to fill	*
;************************************************
PLOT_GEN:
	PUSHR	#^M<R2,R3>			;Save registers
	MOVAL	PLOT_BUF,R2			;Get address of plot buffer
	MOVZWL	PLOT_GEN_FILL,R3		;Get fill count
	BNEQ	5$				;Has fill count
	MOVZWL	PLOT_SIZE,R3			;Fill entire buffer
5$:
	DIVW	#2,R3				;Convert to words
10$:
	MOVW	PLOT_PATTERN,(R2)+		;Setup plot pattern
	SOBGTR	R3,10$				;Loop till pattern setup
	POPR	#^M<R2,R3>			;Restore registers
	RSB					;Return to calling program
;************************************************
;*  Test name check routine			*
;************************************************
NAME_CHECK:
	MOVAL	CONSOL_BUF,R4			;Address of console input buffer
	CMPL	(R4),#^A/HELP/			;Help?
	BNEQ	5$				;No
	CMPB	4(R4),#CR			;Terminated properly?
	BNEQ	5$
	CALLG	HELP_INFO_MESS,CONSOL_OUT	;Output help information
	BRW	90$				;Force select next test message
5$:
	CMPW	(R4),#^X0D52			;Re-configure diagnostic?
	BNEQ	20$				;No
	BRW	RE_START			;Yes reconfigure diagnostic
20$:
	CMPW	(R4),#^X0D54			;Change mode?
	BNEQ	30$				;No
	JSB	CHANGE_MODE			;Change transfer mode
	BRW	90$				;Go to main logic
30$:
	BICB	#M_MANUAL_SELECT,DIAG_CONTROL	;Indicate automatic mode
	CMPB	(R4),#^A/A/			;Automatic testing?
	BEQL	40$				;Yes
	CMPB	(R4),#^A/M/			;Manual testing?
	BEQL	35$				;No error in command
	BRW	90$				;Error in command
35$:
	BISB	#M_MANUAL_SELECT,DIAG_CONTROL	;Manual selected
40$:
	INCL	R4				;Bump address to next byte
	CMPB	(R4)+,#BLANK			;Is it a blank character?
	BEQL	45$				;No error
	BRW	90$				;Error
45$:
	MATCHC	#2,CONSOL_BUF+2,#TYPE_TBL_SIZE,TYPE_TEST_TBL
	TSTL	R0				;Found valid test?
	BEQL	50$				;Yes
	BRW	90$				;No must be error
50$:
	DIVW	#2,R2				;Determine index
	MOVB	R2,TYPE_TEST			;Initialize type test
	MOVL	R2,R5				;Save for later use
	BEQL	75$				;Controller test selected
	CMPB	R2,#ALL_REQUEST			;All of type p/p requested?
	BNEQ	55$				;No
	BRW	80$				;Yes
55$:
	MULW	#3,R5				;Get proper index
	BBS	#V_SPP_PLOTTER,TYPE_PRINTER,75$	;SPP plotter?
	BBC	#V_PRPLTR_ONLY,TYPE_PRINTER,70$	;Printer/plotter only?
	CMPB	R2,TYPE_PRINTER_OFFSET		;Valid selection?
	BLEQ	75$				;Yes
	BRW	90$				;No
70$:
	CMPB	R2,TYPE_PRINTER_OFFSET		;Valid selection?
	BNEQ	90$				;No error
75$:
	MOVAL	CONSOL_BUF,R0			;Get address of console buffer
	MOVB	(R1)+,(R0)+			;Get test number
	MOVB	(R1)+,(R0)+
	CMPB	(R1),#CR			;Terminated properly?
	BNEQ	90$				;No must be error
	MOVB	#CR,(R0)			;Store terminator
	JSB	DECMAL_CONV			;Convert to binary
	BCS	90$				;Error on conversion
	TSTB	R0				;All of type test?
	BEQL	85$				;All of type requested
	CMPL	R0,TNMTB [R5]			;Valid request?
	BGTR	90$				;No error
	DECB	R0				;Start from 0 offset
	INCW	R5				;Bump index
	MULW	#4,R0				;Get proper index
	ADDL3	R0,TNMTB [R5],FIRST_TEST	;Get address of test
	MOVL	FIRST_TEST,LAST_TEST		;Only 1 test to perform
	BICPSW	#<CARRY>			;Good return
	RSB					;Return to main logic
80$:
	ADDB	TYPE_PRINTER_OFFSET,R5		;Displacement for type
	DECW	R5				;Correct displacement
	MULW	#3,R5				;Get correct index
85$:
	INCB	R5				;Bump index to address of first test
	MOVL	TNMTB [R5],FIRST_TEST		;Get address of first test
	INCB	R5				;Bump index
	MOVL	TNMTB [R5],LAST_TEST		;Get address of last test
	BICPSW	#<CARRY>			;Good return
	RSB					;Return to main logic
90$:
	BISPSW	#<CARRY>			;Error return
	RSB
;************************************************
;* Decimal to bunary convert routine		*
;* R0 = Converted value				*
;*						*
;* The routine will convert the hex ascii	*
;* string in th consol_buf to binary. If an	*
;* error occurs in conversion the carry		*
;* bit of the PSW will be set otherwise		*
;*  it will be cleared.				*
;************************************************
DECMAL_CONV:
	PUSHR	#^M<R1,R2>			;Save registers
	MOVAL	CONSOL_BUF,R1			;Get address of input buffer
	CMPB	#CR,(R1)			;If carriage return error
	BEQL	15$				;It make error return
	CLRL	R0				;Initialize for result
5$:
	MOVZBL	(R1)+,R2			;Get character
	CMPB	#CR,R2				;Are we d1?
	BEQL	10$				;Yes
	CMPB	#^A/0/,R2			;Is it non-numeric?
	BGTR	15$				;Yes take error return
	CMPB	#^A/9/,R2			;Non-numeric?
	BLSS	15$				;Yes take error return
	BICB	#^XF0,R2			;Mask of bits not needed
	MULL	#10,R0				;Multiply by 1 decimal
	ADDL	R2,R0				;Add to previous value
	BRB	5$				;Get next byte
10$:
	BICPSW	#<CARRY>			;Clear carry in PSW
	POPR	#^M<R1,R2>			;Restore registers
	RSB					;Return to calling routine
15$:
	BISPSW	#<CARRY>			;Set carry to indicate error
	POPR	#^M<R1,R2>			;Restore registers
	RSB					;Return to calling routine
;************************************************
;* Octal to binary conversion routine		*
;*						*
;* Result returned in register R0. If		*
;* conversion was in error on return the carry	*
;* bit of the PSW will be set. if no error	*
;* occured on conversion the carry bit of the	*
;* PSW will be cleared.				*
;************************************************
OCTAL_CONV:
	PUSHR	#^M<R1,R2>			;Save registers
	MOVAL	CONSOL_BUF,R1			;Get console input buffer address
	CMPB	#CR,(R1)			;If carraige return an error
	BEQL	15$				;Yes take the error return
	CLRL	R0				;Clear for res
5$:
	MOVZBL	(R1)+,R2			;Get next data byte
	CMPB	#CR,R2				;Finished yet?
	BEQL	10$				;Yes
	CMPB	#^A/0/,R2			;Numeric data?
	BGTR	15$				;No take error return
	CMPB	#^A/7/,R2			;Valid octal value?
	BLSS	15$				;No take error exit
	BICB	#^XF0,R2			;Get rid of unused bits
	MULL	#8,R0				;Multiply by 8 decimal
	ADDL	R2,R0				;Add to previous value
	BRB	5$				;Go get next data byte
10$:
	BICPSW	#<CARRY>			;Clear carry no error
	POPR	#^M<R1,R2>			;Restore registers
	RSB					;Return to calling routine
15$:
	BISPSW	#<CARRY>			;Set carry for error return
	POPR	#^M<R1,R2>			;Restore registers
	RSB					;Return to calling routine
;************************************************
;* binary to octal ascii convert routine	*
;*						*
;* R0 = Value to convert			*
;* R1 = Bit index				*
;* R4 = Buffer address				*
;************************************************
OCTAL_ASCII:
	PUSHR	#^M<R1,R2>			;Save registers
	CLRL	R2				;Clear register
5$:
	EXTZV	R1,#3,R0,R2			;Get three bits
	ADDB3	#^A/0/,R2,(R4)+			;Store converted character
	SUBB	#3,R1				;Point to next 3 bits
	BGEQ	5$				;If not < continue
	POPR	#^M<R1,R2>			;Restore register
	RSB					;Return to calling routine
;************************************************
;* Hex_ascii					*
;*						*
;* This routine is used to convert from		*
;* binary to hex ascii.				*
;*						*
;* R0 = value to convert			*
;* R1 = bit to start with(4bits)		*
;* R4 = buffer address				*
;************************************************
HEX_ASCII:
	PUSHR	#^M<R1,R2>			;Save registers
	CLRL	R2				;Clean register
	MOVZBL	#28,R1				;Bit to start with
5$:
	EXTZV	R1,#4,R0,R2			;Get four bits
	CMPW	R2,#9				;Less or equal 9?
	BGTR	10$				;No
	ADDB3	#^A/0/,R2,(R4)+			;Convert to hex
	BRB	15$				;See if done
10$:
	SUBW	#10,R2				;Start from zero
	ADDB3	#^A/A/,R2,(R4)+			;Convert to hex
15$:
	SUBW	#4,R1				;Next four bits
	BGEQ	5$				;Not done yet
	POPR	#^M<R1,R2>			;Restore register
	RSB					;Return calling program
	.PAGE
	.SUBTITLE Controller configuration
;********************************************
;*  Controller initialization routine       *
;********************************************
CONTROLLER_INIT:
	CALLG	CTM1,CONSOL_OUT			;Controller init message
5$:
	CALLG	CTM2,RQEST			;121 OR 122 controller?
	CMPL	CONT_122,CONSOL_BUF		;122 controller?
	BNEQ	10$				;No
	JSB	DIAG_INIT_122			;Go setup diagnostic for 122
	BRB	15$				;Check on standard controller
10$:
	CMPL	CONT_121,CONSOL_BUF		;121 controller?
	BNEQ	5$				;No, ask again
	JSB	DIAG_INIT_121			;Go setup diagnostic for 121
15$:
	CALLG	CTM3,RQEST			;Standard controller?
	CMPB	#^A/Y/,CONSOL_BUF		;Check for yes
	BNEQ	20$				;No go get device addresses
	BRW	55$				;Go validate addresses
20$:
	CMPB	#^A/N/,CONSOL_BUF		;Make sure answer no
	BEQL	25$				;Ok
	BRW	15$				;No, error in response
25$:
	CALLG	CTM4,RQEST			;Get print vector
	JSB	OCTAL_CONV			;Convert vector to binary
	BCS	25$				;Error in conversion
	MOVL	R0,PRINT_VECTOR			;Store print vector
30$:
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,35$
	CALLG	CTM5,RQEST			;Get plot vector
	JSB	OCTAL_CONV			;Convert vector to binary
	BCS	30$				;Error in conversion
	MOVL	R0,PLOT_VECTOR			;Store plot vector
	CMPL	R0,PRINT_VECTOR			;Are vectors the same?
	BNEQ	35$				;No
	CALLG	VECTOR_ERR_MESS,CONSOL_OUT	;Error they are the same
	BRB	25$				;Get vectors again
35$:
	CALLG	CTM6,RQEST			;Get controller priority
	JSB	OCTAL_CONV			;Convert priority to bunary
	BCS	35$				;Error in conversion
	CMPB	R0,#4				;Below minimum priority?
	BLSS	35$				;Yes get it again
	CMPB	R0,#7				;Is it above maximum?
	BGTR	35$				;Yes get it again
	SUBB	#4,R0				;Index for priority conversion
	MOVB	PRIORTY_TABL(R0),PRIORITY	;Get correct priority
40$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,45$	;If 121 skip
	CALLG	CTM11,RQEST			;Get 122 CSR address
	JSB	OCTAL_CONV			;Convert to binary
	BCS	40$				;Error in conversion
	BISL3	#^X30000,R0,PRINT_CSR		;Force bits 16 & 17 to be set
	BRB	55$				;Go see if valid address
45$:
	CALLG	CTM7,RQEST			;Get plot csr address
	JSB	OCTAL_CONV			;Convert to binary
	BCS	45$				;Error in conversion
	BISL3	#^X30000,R0,PLOT_CSR		;Force bits 16 & 17 to be set
50$:
	CALLG	CTM8,RQEST			;Get DMA address
	JSB	OCTAL_CONV			;Convert to binary
	BCS	50$				;Error in conversion
	BISL3	#^X30000,R0,DMA_PLOT_REG	;Force bits 16 & 17 to be set
55$:
	CASEB	TYPE_CPU,#1,#NMB_CPUS		;Determine which processor
60$:
	;	.WORD	ADAPTOR_790-60$		;VAX11/790
		.WORD	ADAPTOR_780-60$		;VAX11/780
		.WORD	ADAPTOR_750-60$		;VAX11/750
		.WORD	ADAPTOR_730-60$		;VAX11/730
 
	CALLG	CONFIG_ERROR,CONSOL_OUT		;Bad processor to run on
	HALT					;Halt diagnostic
ADAPTOR_790:
ADAPTOR_780:
	CALLG	CTM10,RQEST			;Get UBA number
	JSB	OCTAL_CONV			;Convert to binary
	BCS	ADAPTOR_780			;Error in conversion
	TSTL	R0				;Valid adaptor number?
	BLSS	ADAPTOR_780			;No, try again
	CMPL	R0,#MAX_UBAS_780		;Valid adaptor number?
	BGTR	ADAPTOR_780			;No, try again
	MOVL	UBA_780_ADDR [R0],UBA_ADDR_SPACE	;Define UBA register space
	MOVB	TR_NUMBER_TABLE [R0],TR_NUMBER_780	;Get correct arbritation
	MOVL	UBA_780_IO_SPACE [R0],R2	;Get correct Unibus I/O space
	JSB	VERIFY_UNIBUS			;Make sure unibus valid
	BLBS	R0,ADAPTOR_780			;Not valid try again
	JSB	FIND_CONTROLLER_INIT		;Find and init controller registers
	BLBC	R0,5$				;If everything O.K., continue
	BRW	CONTROLLER_INIT			;Else try again
5$:
	MOVZBL	PRIORITY,R0			;Get priority
	SUBW	#^X14,R0			;Get index
	MULW3	#4,R0,BRRVR_USED		;Byte offset
	ADDW3	#^X30,BRRVR_USED,BRRVR_USED	;Get brrvr used for interrupt
	MOVZBL	TR_NUMBER_780,R1		;Get UBA TR number
	MULW	#^X40,R0			;Offset by priority
	MULW	#4,R1				;Byte offset
	ADDW	R1,R0				;Combine both offsets
	ADDW3	#^X100,R0,INTR_VECTOR		;Save for controller test usage
	BRW	CHANGE_MODE			;Get transfer mode
ADAPTOR_750:
	CALLG	CTM12,RQEST			;Get Unibus interface number
	JSB	OCTAL_CONV			;Convert to binary
	BCS	ADAPTOR_750			;Error try again
	TSTL	R0				;Is less than zero
	BLSS	ADAPTOR_750			;Yes, error
	CMPL	R0,#MAX_UBAS_750		;Is valid UBI requested?
	BGTR	ADAPTOR_750			;No, try again
	MOVL	UBA_750_ADDR [R0],UBA_ADDR_SPACE ;Save UBA register address
	MOVL	UBA_750_IO_SPACE [R0],R2	;Get correct Unibus I/O space
	JSB	VERIFY_UNIBUS			;Make sure Unibus valid
	BLBS	R0,ADAPTOR_750			;Error, try again
	JSB	FIND_CONTROLLER_INIT		;Find controller and init registers
	BLBC	R0,CHANGE_MODE			;If O.K., See what transfer mode
	BRW	CONTROLLER_INIT			;Try again
ADAPTOR_730:
	MOVL	UBA_730_ADDR,UBA_ADDR_SPACE	;Save UBA register space
	MOVL	UBA_730_IO_SPACE,R2		;Get correct Unibus I/O space
	JSB	FIND_CONTROLLER_INIT		;Find controller and init registers
	BLBC	R0,CHANGE_MODE			;If O.K., see what transfer mode
	BRW	CONTROLLER_INIT			;Try again
CHANGE_MODE:
	CALLG	CTM9,RQEST			;What is transfer mode?
	MOVAL	CONSOL_BUF,R0			;Get address of input buffer
	CMPL	DPC_ANS,(R0)			;Is is DPC?
	BEQL	5$				;Yes
	CMPL	DMA_ANS,(R0)			;Is it DMA?
	BNEQ	CHANGE_MODE			;No error
	BISB	#M_DMA_SELECT,DIAG_CONTROL	;Select DMA transfers
	RSB
5$:
	BICB	#M_DMA_SELECT,DIAG_CONTROL	;Select DPC trnafers
	RSB					;Return to main logic
;************************************************
;*  Verify Unibus routine			*
;* 						*
;*  This routine is called by CONTROLLER_INIT to*
;*  verify that the Unibus requested is on the	*
;*  system. If not an error message is displayed*
;************************************************
VERIFY_UNIBUS:
	MOVAL	BAD_ADAPTOR_SRV+1,MACH_CHECK_VEC	;Setup machine check vector
	MOVL	UBA_ADDR_SPACE,R1
	CLRL	R0				;Clear error return
	TSTL	UBA$L_CSR(R1)			;If UBA present no error
VERIFY_UNIBUS_CONT:
	MOVAL	INVAL_MACH_CHK+1,MACH_CHECK_VEC	;Restore machine vector
	JSB	RESET_CPU			;Make sure CPU o.k.
	RSB					;Return to CONTROLLER_INIT
	.ALIGN	LONG
BAD_ADAPTOR_SRV:
	MOVL	(SP)+,R7			;Get number of arguments on stack
	ADDL	R7,SP				;Correct stack
	JSB	RESET_CPU			;Reset processor
	CALLG	UBA_ADDR_MESS,CONSOL_OUT	;Output bad UBA message
	MOVAL	VERIFY_UNIBUS_CONT,(SP)		;New return address
	MOVZBL	#1,R0				;Indicate error
	REI					;Return from exception
;************************************************
;*  Find controller and init registers		*
;* 						*
;*  This routine is called by CONTROLLER_INIT to*
;*  find the either the 121 or 122 controller on*
;*  the particular Unibus Adaptor. The following*
;*  parameters are passed to this routine:	*
;*						*
;*  R2 = Address of Adaptor I/O space		*
;************************************************
FIND_CONTROLLER_INIT:
	JSB	RESET_CPU			;Ready CPU
	JSB	RESET_UNIBUS			;Ready Unibus
	CMPB	#V11780,TYPE_CPU		;Is CPU a 780?
	BNEQ	10$				;No
	MOVL	#^X100,R0			;Set byte of device interrupts
	MOVZBL	TR_NUMBER_780,R1		;Get arbitation number
	MOVZBL	#4,R3				;Loop count
5$:
	MOVAL	BAD_CONTROLLER_SRV,SCB(R0) [R1]		;Invalid interrupt routines
	ADDW	#^X40,R0			;Bump offset for next priority level
	SOBGTR	R3,5$				;Loop till priority levels filled
10$:
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,15$	;If 121 skip
	MOVAL	PRINT_CSR,R3			;Get Address to store CSR address
	MOVL	PRINT_CSR,R4			;Get CSR address
	MOVZBL	#2,R5				;Only two registers
	BRB	20$				;Set up registers
15$:
	MOVAL	PLOT_CSR,R3			;Get address to store plot csr
	MOVL	PLOT_CSR,R4			;Get plot CSR address
	MOVZBL	#4,R5				;Setup loop count
20$:
	BISL3	R4,R2,R6			;Get correct address
	MOVAL	BAD_CONTROLLER_SRV+1,MACH_CHECK_VEC	;Setup for machine check
	CLRL	R0				;Clear lower bit
25$:
	MOVL	R6,(R3)+			;Store new adddress
	TSTW	(R6)+				;Valid address?
	BLBS	R0,45$				;If lower bit set error
	SOBGTR	R5,25$				;Loop till new address stored
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,30$	;If 122 skip DMA setup
	BRW	40$				;Go make sure system O.K.
30$:
	BISL3	DMA_PLOT_REG,R2,R6		;Get correct address
	MOVAL	DMA_PLOT_REG,R3			;Address to store new address
	MOVZBL	#4,R4				;Setup loop count
35$:
	MOVL	R6,(R3)+			;Store new address
	TSTW	(R6)+				;Vaild address?
	BLBS	R0,45$				;If lower bit set error
	SOBGTR	R4,35$				;Store all new DMA addresses
40$:
	MOVAL	INVAL_MACH_CHK+1,MACH_CHECK_VEC	;Restore machine check
	JSB	RESET_CPU			;Make sure CPU O.K.
	JSB	RESET_UNIBUS			;Make sure unibus O.K.
	CLRL	R0				;Indicate no error
45$:
	RSB					;Return to CONTROLLER_INIT
	.ALIGN	LONG
BAD_CONTROLLER_SRV:
	CMPB	#V11780,TYPE_CPU		;Is CPU 780?
	BEQL	5$				;Yes
	MOVL	(SP)+,R7			;Get number of arguments on stack
	ADDL	R7,SP				;Correct stack
5$:
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	CALLG	CNTRL_ADDR_MESS,CONSOL_OUT	;Controller not found
	MOVZBL	#1,R0				;Indicate an error
	REI					;Return from exception
;************************************************
;*  121 diagnostic init routine			*
;************************************************
DIAG_INIT_121:
	BICB	#M_122_CONTROLLER,TYPE_CONTROLLER	;Indicate 121 controller
	MOVAL	FUNBIT_TABLE_121,R0		;Get address of driver function bits for 122
	MOVZWL	#FUNBIT_TABLE_LEN,R1		;Get length of table
	MOVAL	FUNBIT_TABLE,R2			;Get address of function table
5$:	MOVW	(R0)+,(R2)+			;Setup driver function table
	SOBGTR	R1,5$				;Loop till table setup
	MOVC5	#0,PLOT_CSR,#0,#INFO_PLOT_SIZ,PLOT_CSR	;Zero controller registers
	MOVW	#SPP_BIT_121,SPP_BIT		;Initialize SPP bit
	MOVW	#DMABUSY_BIT_121,DMABUSY_BIT	;Initialize DMA busy bit
	MOVL	STANDARD_CSR_121,PLOT_CSR	;Setup for standard controller
	MOVL	STAN_DMA_PLTRG,DMA_PLOT_REG	;Standard DMA address
	MOVB	DEF_PRIORITY,PRIORITY		;Default priority
	MOVL	DEFPR_VECTOR,PRINT_VECTOR	;Default print vector
	MOVL	DEFPL_VECTOR,PLOT_VECTOR	;Default plot vector
	MOVB	#^A/ /,PL_MESS			;Restore error message for 121
	MOVW	#^A/13/,MOD_ERM_23		;Restore error message for 121
	MOVW	#^A/13/,MOD_ERM_24		;Restore error message for 121
	MOVW	#^A/ 0/,MOD_ERM_25		;Restore error message for 121
	MOVW	#^A/ 0/,MOD_ERM_26		;Restore error message for 121
	RSB					;Return to controller init routine
;************************************************
;*  122 diagnostic init routine			*
;************************************************
DIAG_INIT_122:
	BISB	#M_122_CONTROLLER,TYPE_CONTROLLER	;Indicate 122 controller
	MOVAL	FUNBIT_TABLE_122,R0		;Get address of driver function bits for 122
	MOVZWL	#FUNBIT_TABLE_LEN,R1		;Get length of table
	MOVAL	FUNBIT_TABLE,R2			;Get address of function table
5$:	MOVW	(R0)+,(R2)+			;Setup driver function table
	SOBGTR	R1,5$				;Loop till table setup
	MOVC5	#0,PLOT_CSR,#0,#INFO_PLOT_SIZ,PLOT_CSR	;Zero controller registers
	MOVW	#SPP_BIT_122,SPP_BIT		;Initialize SPP bit
	MOVW	#DMABUSY_BIT_122,DMABUSY_BIT	;Initialize DMA busy bit
	MOVL	STANDARD_CSR_122,PRINT_CSR	;Setup for standard controller
	MOVB	DEF_PRIORITY,PRIORITY		;Default priority
	MOVL	DEFPR_VECTOR,PRINT_VECTOR	;Default print vector
	MOVL	DEFPR_VECTOR,PLOT_VECTOR	;Default plot vector same as print
	CLRB	PL_MESS				;Setup error message for 122
	MOVW	#^A/ 0/,MOD_ERM_23		;Restore error message for 122
	MOVW	#^A/ 0/,MOD_ERM_24		;Restore error message for 122
	MOVW	#^A/13/,MOD_ERM_25		;Restore error message for 122
	MOVW	#^A/13/,MOD_ERM_26		;Restore error message for 122
	RSB					;Return to controller init routine
	.PAGE
	.SUBTITLE Printer/plotter configuration
;********************************************
;*  Printer/plotter configuration routine   *
;********************************************
PRINTER_PLOTTER_INIT:
	CALLG	MTM1,CONSOL_OUT			;Printer/plotter configuration
5$:
	CALLG	MTM2,RQEST			;Get plotter type
	CLRL	R2				;Clear index register
7$:	CMPW	CONSOL_BUF,TYPE_DEVICE_TBL[R2]	;Valid printer/plotter type?
	BEQL	10$				;Yes
	ACBW	#TYPE_DEVICE_SIZ,#1,R2,7$
	BRB	5$				;Error try again
10$:
	MOVB	TYPE_INDEX_CNVRT[R2],TYPE_PRINTER	;Set type printer bit
15$:
	INCB	R2				;Bump by 1(1-4)
	MOVB	R2,TYPE_PRINTER_OFFSET		;Save offset for name check
	BBS	#V_PLOTTER_ONLY,TYPE_PRINTER,45$	;Plotter only?
25$:
	CALLG	MTM3,RQEST			;Get columns per line
	JSB	DECMAL_CONV			;Convert to binary
	BCS	25$				;Error in conversion
	MOVW	R0,PRINT_SIZE			;Store columns per line
30$:
	CALLG	MTM4,RQEST			;Get character set size
	JSB	DECMAL_CONV			;Convert to binary
	BCS	30$				;Error in conversion
	MOVW	R0,CHAR_SIZE			;Store character set size
	CMPW	R0,PRINT_SIZE			;Character set > than columns?
	BGTR	35$				;Yes
	MOVW	PRINT_SIZE,FILL_COUNT		;Store max fill count
	BRB	40$				;Go see if plotter
35$:
	MOVW	R2,FILL_COUNT			;Store fill buffer count
40$:
	BBC	#V_PRINTER_ONLY,TYPE_PRINTER,45$	;Printer only?
	BRW	65$				;Yes
45$:
	CALLG	MTM5,RQEST			;Get number plot bytes
	JSB	DECMAL_CONV			;Convert to binary
	BCS	45$				;Error in conversion
	MOVW	R0,PLOT_SIZE			;Store plot byte count
	MULW3	#8,R0,NIBSPR_SCAN		;Determine nibs per scan
50$:
	CALLG	MTM6,RQEST			;Get nibs per inch
	JSB	DECMAL_CONV			;Convert to binary
	BCS	50$				;Error in conversion
	MOVW	R0,NIBSPR_INCH			;Store nibs per inch
	BBC	#V_SPP_PLOTTER,TYPE_PRINTER,65$	;SPP printer/plotter?
55$:
	CALLG	MTM7,RQEST			;Get scan/print line for SPP
	JSB	DECMAL_CONV			;Convert from ascii
	BCS	55$				;Error in conversion
	MOVW	R0,SCANPR_CHAR			;Store scans/print line for SPP
	CMPW	PRINT_SIZE,#80			;Is plotter 200a?
	BNEQ	60$				;No
	MOVW	#70,SPPLN_SIZE			;SPP character byte count
	RSB					;Return to main logic
60$:
	MOVW	PRINT_SIZE,SPPLN_SIZE		;SPP character byte count
65$:
	RSB					;Return to main logic
	.PAGE
	.SUBTITLE Processor identification
;************************************************
;* Processor identification routine		*
;*						*
;* This routine is called to determine		*
;* what type of processor the diag. is		*
;* running on. The routine will then make	*
;* the necessary changes for that processor.	*
;************************************************
IDENT_CPU:
	MFPR	#PR$_SID,R0			;Get system id register
	EXTZV	#24,#8,R0,R0			;Get processor type
	MOVB	R0,TYPE_CPU			;Store type cpu
	CASEB	R0,#1,#NMB_CPUS			;Setup message for cpu
5$:
		.WORD	10$-5$			;VAX11/780
		.WORD	15$-5$			;VAX11/750
		.WORD	20$-5$			;VAX11/730
		.WORD	30$-5$			;VAX11/790
10$:
	MOVC	#3,VAX_780_MESS,DIAG_INFO_TYPE	;Store 780 message
	RSB
15$:
	MOVC	#3,VAX_750_MESS,DIAG_INFO_TYPE	;Store 750 message
	RSB
20$:
	MOVC	#3,VAX_730_MESS,DIAG_INFO_TYPE	;Store 730 message
	RSB
30$:
	CALLG	CONFIG_ERROR,CONSOL_OUT		;I can't work with 790
	HALT					;Force a halt
	.PAGE
	.SUBTITLE Console utilities
;************************************************
;* Console input routine			*
;*						*
;* This is the console input routine. The	*
;* routine will look for 2 special characters,	*
;* (1) control u and (2) delete or rubout	*
;* character. A control U will cause an entire	*
;* line to be deleted. The delete character	*
;* will cause a single character to be deleted. *
;************************************************
CONSOL_IN:
	PUSHR	#^M<R0,R2,R3>			;Save registers
5$:
	MOVAL	CONSOL_BUF,R0			;Get address of console buffer
10$:
	MFPR	#PR$_RXCS,R3			;Get console receive status
	CMPB	#READY_BIT,R3			;Ready?
	BNEQ	10$				;No wait
	MFPR	#PR$_RXDB,R2			;Get byte from keyboard
	BICB	#^X80,R2			;Get rid of garbiage
	CMPB	R2,#CONTROL_R			;Repeat line?
	BNEQ	20$				;No
	MOVB	#CR,R2				;Terminate current line
	JSB	CHAR_OUT			;Output to console
	MOVB	#LF,R2				;Line feed character
	JSB	CHAR_OUT			;Output to console
	MOVAL	CONSOL_BUF,R3			;Get address of buffer
15$:
	CMPL	R3,R0				;Finished?
	BEQL	10$				;Yes
	MOVB	(R3)+,R2			;Get next character
	JSB	CHAR_OUT			;Output to console
	BRB	15$				;See if finished
20$:
	CMPB	R2,#CR				;Carriage return?
	BNEQ	30$				;No
	TSTB	CONSOL_EDT			;In edit mode?
	BEQL	25$				;No
	CLRB	CONSOL_EDT			;Terminate deletion
	MOVB	#BACK_SLASH,R2			;Back slash character
	JSB	CHAR_OUT			;Output to console
	MOVB	#CR,R2				;Carriage return
25$:
	JSB	CHAR_OUT			;Output to console
	MOVB	R2,(R0)				;Store in input buffer
	MOVB	#LF,R2				;Line feed character
	JSB	CHAR_OUT			;Output to console
	POPR	#^M<R0,R2,R3>			;Restore registers
	RSB					;Return to calling program
30$:
	CMPB	R2,#DELETE			;Delete character?
	BNEQ	45$				;No
	CMPL	R0,#CONSOL_BUF			;At beginnign of buffer?
	BNEQ	35$				;No
	BRW	10$				;Yes
35$:
	TSTB	CONSOL_EDT			;Already deleting?
	BNEQ	40$				;Yes
	INCB	CONSOL_EDT			;Indicate editing
	MOVB	#BACK_SLASH,R2			;Edit character
	JSB	CHAR_OUT			;Output to console
40$:
	DECL	R0				;Correct buffer address
	MOVB	(R0),R2				;Get deleted character
	JSB	CHAR_OUT			;Display on console
	BRW	10$				;Get next character
45$:
	CMPB	R2,#CONTROL_U			;Delete entire line?
	BNEQ	50$				;No
	CALLG	CNTRL_U_MESS,CONSOL_OUT		;Control u message
	CLRB	CONSOL_EDT			;Clear flag
	BRW	5$				;Reset buffer
50$:
	TSTB	CONSOL_EDT			;Deletion mode?
	BEQL	55$				;No
	CLRB	CONSOL_EDT			;Terminate deletion
	MOVL	R2,R3				;Save character
	MOVB	#BACK_SLASH,R2			;Back slash character
	JSB	CHAR_OUT			;Output to console
	MOVL	R3,R2				;Retrieve character
55$:
	CMPB	R2,#BLANK			;Is character printable?
	BGEQ	60$				;Yes, don't echo character
	BRW	10$				;Get another character
60$:	JSB	CHAR_OUT			;Echo character
	MOVB	R2,(R0)+			;Place in input buffer
	BRW	10$				;Get another character
;************************************************
;* Console output routine			*
;*						*
;* This is the console output routine. Messages	*
;* are passed to this routine via a procedure	*
;* call (callg). The address pointer (AP) will	*
;* contain the address of the message. The line	*
;* of text must be terminated by a 0 or null	*
;* character. The message will automatically be	*
;* terminated with a carriage return and line	*
;* feed characters.				*
;************************************************
	.ENTRY	CONSOL_OUT,^M<R2>
5$:
	BBS	#V_MESS_DISPLAY,DIAG_CONTROL,15$;Disabled?
	MOVZBL	(AP)+,R2			;Get character from buffer
	BEQL	10$				;If 0 end of line
	JSB	CHAR_OUT			;Output character
	BRB	5$				;Go get next character
10$:
	MOVB	#CR,R2				;Carriage return character
	JSB	CHAR_OUT			;Issue carraige return
	MOVB	#LF,R2				;Line feed character
	JSB	CHAR_OUT			;Issue a line feed
15$:
	RET					;Return to caller
CHAR_OUT:
	PUSHR	#^M<R3>				;Save register
5$:
	MFPR	#PR$_TXCS,R3			;Get transmit status
	CMPB	#READY_BIT,R3			;Ready?
	BNEQ	5$				;No
	MTPR	R2,#PR$_TXDB			;Transfer character
	POPR	#^M<R3>				;Restore register
	RSB					;Return to calling routine
;************************************************
;* Console input request routine		*
;*						*
;* Routine will output message by address	*
;* contained in the address pointer (ap). The	*
;* routine will then wait for console input	*
;* from the user.				*
;************************************************
	.ENTRY	RQEST,^M<>
	CALLG	(AP),CONSOL_OUT			;Output message to console
	JSB	CONSOL_IN			;Call console input routine
	RET					;Return to caller
;************************************************
;* Console receive interrupt service routine	*
;*						*
;* This is the console receive interrupt	*
;* service routine. there are 4 control		*
;* characters that can be used by the user	*
;* during test execution. The following is	*
;* is a description of those control		*
;* characters:					*
;*						*
;*    Control C - This control character will	*
;*		  terminate the current test	*
;*		  and go to the next test.	*
;*						*
;*    Control Z - This control character will	*
;*		  terminate all testing and	*
;*		  return user to main part of	*
;*		  diagnostic to select another	*
;*		  test.				*
;*						*
;*    Control O - This control character will	*
;*		  allow the user to enable or	*
;*		  disable the printing of error	*
;*		  messages on the console. The	*
;*		  first time the user issues a	*
;*		  control O, the messages will	*
;*		  be disabled. The second time	*
;*		  the user issues a control O	*
;*		  the messages display will	*
;*		  be enabled.			*
;*						*
;*   Control F -  This control character is	*
;*		  used to control the usage of	*
;*		  remote form feed between	*
;*		  tests. If there is a problem	*
;*		  with form feed the first	*
;*		  occurence of the control	*
;*		  character will disable form	*
;*		  feeds. The second occurence	*
;*		  of the control character will	*
;*		  re-enable form feeds between	*
;*		  tests.			*
;************************************************
	.ALIGN LONG
CONSOL_INTR:
	PUSHR	#^M<R2,R6,AP>			;Save registers
	MFPR	#PR$_RXDB,R6			;Get character from console
	BICB	#^X80,R6			;Get rid of garbage
	CMPB	R6,#CONTROL_C			;Terminate current test?
	BEQL	15$				;Yes
	CMPB	R6,#CONTROL_Z			;Terminate testing?
	BEQL	20$				;Yes
	CMPB	R6,#CONTROL_O			;Control error message diaplay?
	BNEQ	5$				;No
	BRW	25$				;Yes
5$:	CMPB	R6,#CONTROL_F			;Form feed between tests?
	BNEQ	10$				;No
	BRW	35$				;Yes
10$:
	POPR	#^M<R2,R6,AP>			; Restore registers
	REI					;Return from interrupt
15$:
	CALLG	CNTRL_C_MESS,CONSOL_OUT		;Control C message
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor errors
	JSB	RESTORE				;Restore map and vectors
	MOVAL	START,SP			;Reset stack
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	MTPR	#START,#PR$_KSP			;Reset kernal stack
	MTPR	#START,#PR$_ISP			;Reset interrupt stack
	BRW	LOOP2				;Go to main logic
20$:
	CALLG	CNTRL_Z_MESS,CONSOL_OUT		;Control Z message
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	JSB	RESTORE				;Restore map and vectors
	MOVAL	START,SP			;Reset stack
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	MTPR	#START,#PR$_KSP			;Reset kernal stack
	MTPR	#START,#PR$_ISP			;Reset interrupt stack
	BRW	REQT1				;Go to main logic
25$:
	BBC	#V_MESS_DISPLAY,DIAG_CONTROL,30$;Message enabled?
	BICB	#M_MESS_DISPLAY,DIAG_CONTROL	;Enable message display
	CALLG	CNTRL_O_MESS,CONSOL_OUT		;Control o message
	POPR	#^M<R2,R6,AP>			;Restore register
	REI					;Return from interrupt
30$:
	BISB	#M_MESS_DISPLAY,DIAG_CONTROL	;Disable message diaplay
	POPR	#^M<R2,R6,AP>			;Restore register
	REI					;Return from interrupt
35$:
	BBS	#V_FORMFD_SELECT,DIAG_CONTROL,40$ ;Form feed disabled?
	CALLG	FF_DIS_MESS,CONSOL_OUT		;Disable ff message
	BISB	#M_FORMFD_SELECT,DIAG_CONTROL	;Disable formfeeds
	POPR	#^M<R2,R6,AP>			;Restore registers
	REI					;Return from interrupt
40$:
	CALLG	FF_ENA_MESS,CONSOL_OUT		;Enable ff message
	BICB	#M_FORMFD_SELECT,DIAG_CONTROL	;Enable formfeeds
	POPR	#^M<R2,R6,AP>			;Restore registers
	REI					;Return from interrupt
	.PAGE
;************************************************
;* Display printer/plotter error routine	*
;* 						*
;* Routine is called to output an error		*
;* message to the console when the printer/	*
;* plotter or controller has an error.		*
;************************************************
ERROR_DISPLAY:
	PUSHR	#^M<R0,R4,R10,R11>		;Save registers
	MOVZWL	@PRINT_CSR,R10			;Get print status
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If 122 no plot status
	MOVZWL	@PLOT_CSR,R11			;Get plot status
5$:
	BBS	#V_MESS_DISPLAY,DIAG_CONTROL,30$	;Messages disabled?
	MOVL	R10,R0				;Get print status
	MOVAL	PR_STATUS,R4			;Buffer address
	MOVZBL	#15,R1				;Set index
	JSB	OCTAL_ASCII			;Convert print status
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,10$	;If 122 no plot status
	MOVAL	PL_STATUS,R4			;Buffer address
	MOVZBL	#15,R1				;Index(bit 15)
	MOVL	R11,R0				;Get plot status
	JSB	OCTAL_ASCII			;Convert to plot status
10$:
	MOVZBL	ERROR_TYPE,R0			;Get error type
	MOVL	ERM_TYPE_TBL [R0],R0		;Address of type message
	MOVAL	ERROR_MESS,R1			;Address to store message
15$:
	MOVZBL	(R0)+,R4			;Get byte
	BEQL	20$				;End of message
	MOVB	R4,(R1)+			;Store message
	BRB	15$				;Get next byte
20$:
	MOVZBL	MODE,R0				;Get mode
	MOVL	ERM_MODE_TBL [R0],R0		;Address of message
25$:
	MOVB	(R0)+,(R1)+			;Store message
	BNEQ	25$				;If not 0 more message
	CALLG	ERROR_MESS,CONSOL_OUT		;Error message
	CALLG	STATUS_MESS,CONSOL_OUT		;Status message
30$:
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	POPR	#^M<R0,R4,R10,R11>		;Restore registers
	RSB					;Return to calling routine
;************************************************
;* This routine is used to setup the vector	*
;* address of the second page of the SCB, if	*
;* the processor is a VAX11/780.		*
;*						*
;* Arguments					*
;*						*
;* R4 = Address of good interrupt service	*
;* R5 = Address of bad interrupt service	*
;************************************************
VECTOR_750_SETUP:
	PUSHR	#^M<R0,R1,R2,R3>
	MOVAL	SCB+^X200,R0			;Get address of second page
	ADDL3	PRINT_VECTOR,R0,R1		;Offset for print vector
	ADDL3	PLOT_VECTOR,R0,R2		;Offset for plot vector
	MOVZWL	#NUMBER_VECTORS,R3		;Number of vectors to set up
5$:
	CMPL	R0,R1				;Print interrupt vector?
	BEQL	10$				;Yes
	CMPL	R0,R2				;Plot interrupt vector?
	BEQL	10$				;Yes
	MOVL	R5,(R0)				;Store bad vector address
	BRB	15$				;Bump address
10$:
	MOVL	R4,(R0)				;Store good vector address
15$:
	ADDL	#4,R0				;Bump address
	SOBGTR	R3,5$				;Setup all vector addresses
	POPR	#^M<R0,R1,R2,R3>
	RSB					;Return to calling routine
;************************************************
;* This routine is used to reset the unibus	*
;* and controller if an error occurs or a test	*
;* has been aborted.				*
;************************************************
RESET_UNIBUS:
	PUSHR	#^M<R0>				;Save register
	CASEB	TYPE_CPU,#1,#NMB_CPUS
5$:
		.WORD	10$-5$			;VAX11/780
		.WORD	20$-5$			;VAX11/750
		.WORD	20$-5$			;VAX11/730
10$:
	MOVL	UBA_ADDR_SPACE,R0		;Get UBA address of 780
	BISL	#UBA$M_CR_INIT,UBA$L_CR(R0)	;Initialize unibus
15$:
	BITL	#UBA$M_CSR_UBIC,UBA$L_CSR(R0)	;Powered up?
	BEQL	15$				;No
	BISL	#UBA$M_CR_ALENA,UBA$L_CR(R0)	;Enable unibus interrupts
	BRB	100$				;Go restore map registers
20$:
	MTPR	#1,#PR$_INUBA			;Iinitialize unibus
100$:
	JSB	RESTORE				;Restore mapping registers
	POPR	#^M<R0>				;Restore register
	RSB					;Return to calling routine
;****************************************
;* Reset CPU routine			*
;*					*
;* This routine is called when an error	*
;* occurs to make sure no errors	*
;* exist on processor.			*
;****************************************
RESET_CPU:
	PUSHR	#^M<R0>				;Save register
	CASEB	TYPE_CPU,#1,#NMB_CPUS
5$:
		.WORD	10$-5$			;VAX11/780
		.WORD	15$-5$			;VAX11/750
		.WORD	15$-5$			;VAX11/730
10$:
	MFPR	#PR$_SBIFS,R0			;Get SBI fault register
	BICL	#SBIFS_NEF,R0			;Clear error bit
	MTPR	R0,#PR$_SBIFS			;Restore fault register
	MFPR	#PR$_SBIER,R0			;Get SBI error register
	BISW	#SBIER_NEF,R0			;Set bits to clear
	MTPR	R0,#PR$_SBIER			;Clear latched bits
	BRB	100$				;Return to calling routine
15$:
	MFPR	#PR$_MCESR,R0			;Get error summary
	MTPR	R0,#PR$_MCESR			;Clear latched bits
100$:
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	POPR	#^M<R0>				;Restroe register
	RSB					;Return
;****************************************
;* Restore map routine			*
;*					*
;* This routine is called to restore	*
;* the unibus mapping registers and the *
;* unibus interrupt vector.		*
;****************************************
RESTORE:
	PUSHR	#^M<R0,R1,R2,R3>		;Save registers
	MTPR	#INIT_IPL,#PR$_IPL		;Restore priority
	BBS	#V_122_CONTROLLER,TYPE_CONTROLLER,5$	;If 122 skip
	CLRW	@DMA_EXT_REG			;Clear extedded bits for DMA
 
5$:
	CASEB	TYPE_CPU,#1,#NMB_CPUS
10$:
		.WORD	15$-10$			;VAX11/780
		.WORD	25$-10$			;VAX11/750
		.WORD	25$-10$			;VAX11/730
15$:
	MOVL	#^X100,R0			;Set byte of device interrupts
	MOVZBL	TR_NUMBER_780,R1		;Get arbitation number
	MOVAL	INVAL_INTTBL,R3			;Address invalid interrupt of table
	MOVZBL	#4,R2				;Loop count
20$:
	MOVL	(R3)+,SCB(R0) [R1]		;Invalid interrupt routines
	ADDW	#^X40,R0			;Bump offset for next priority level
	SOBGTR	R2,20$				;Loop till priority levels filled
25$:
	ADDL3	#UBA$L_MAP,UBA_ADDR_SPACE,R0	;First mapping register
	MOVZWL	#MAP_LIMIT,R1			;# of registers to fill
	CLRL	R2				;Start from page 0
	BISL	#UBA$M_MAP_VALID,R2		;Set valid bit
30$:
	MOVL	R2,(R0)+			;Initialize register
	INCL	R2				;Bump to next page
	SOBGTR	R1,30$				;Fill all registers
	POPR	#^M<R0,R1,R2,R3>		;Restore registers
	MOVAL	INVAL_MACH_CHK+1,MACH_CHECK_VEC	;Restore machine check
	RSB					;Return to calling routine
	.PAGE
	.SUBTITLE Service routines
;************************************************
;* Interval timer service routine		*
;*						*
;* This is the interrupt service routine for	*
;* the interval timer. Each time an interrupt	*
;* occurs the service routine will decrement	*
;* the wait_count register. If the register is	*
;* not 0, the interval timer will be started	*
;* again. If the register is 0 the interval	*
;* timer will be disabled.			*
;************************************************
	.ALIGN	LONG
TIMER_INTR:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	DECW	WAIT_COUNT			;Decrement wait_count register
	BEQL	5$				;Register has timed out
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Re-enable clock
5$:
	REI					;Return from interrupt
;************************************************
;* Invalid interrupt vector routines		*
;************************************************
	.ALIGN	LONG
INVINT_BR4:
	PUSHR	#^M<R0>				;Save regisetr
	ADDL3	#^X30,UBA_ADDR_SPACE,R0		;Determine brrvr used
	MOVL	(R0),R0				;Get vector
	MOVB	#^A/4/,PRIO_FOUND		;Priority found
	JSB	INVAL_PRI_INTR			;Output to console
	POPR	#^M<R0>				;Restore register
	REI					;Return
	.ALIGN	LONG
INVINT_BR5:
	PUSHR	#^M<R0>				;Save register
	ADDL3	#^X34,UBA_ADDR_SPACE,R0	;Brrvr used
	MOVL	(R0),R0				;Get vector
	MOVB	#^A/5/,PRIO_FOUND		;Priority 5
	JSB	INVAL_PRI_INTR			;Output to console
	POPR	#^M<R0>				;Restore register
	REI					;Return
	.ALIGN	LONG
INVINT_BR6:
	PUSHR	#^M<R0>				;Save register
	ADDL3	#^X38,UBA_ADDR_SPACE,R0	;Brrvr used
	MOVL	(R0),R0				;Get vector
	MOVB	#^A/6/,PRIO_FOUND		;Priority 6
	JSB	INVAL_PRI_INTR			;Output to console
	POPR	#^M<R0>				;Restore register
	REI					;Return
	.ALIGN	LONG
INVINT_BR7:
	PUSHR	#^M<R0>				;Save register
	ADDL3	#^X3C,UBA_ADDR_SPACE,R0		;Brrvr used
	MOVL	(R0),R0				;Get vector
	MOVB	#^A/7/,PRIO_FOUND		;Priority 7
	JSB	INVAL_PRI_INTR			;Output to console
	POPR	#^M<R0>				;Restore register
	REI					;Return
INVAL_PRI_INTR:
	PUSHR	#^M<R1,R4>			;Save registers
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	ADDB	#2,INTR_COMPLETE		;Indicate error
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	MOVAL	VECT_FOUND,R4			;Address to store conversion
	MOVZBL	#12,R1				;Index
	JSB	OCTAL_ASCII			;Convert vector to ascii
	SUBB3	#^X10,PRIORITY,PRIO_EXPT	;Get correct value
	ADDB	#^A/0/,PRIO_EXPT		;Convert to ascii
	CALLG	INVAL_PRIO_MESS,CONSOL_OUT	;Inval. prio. message
	POPR	#^M<R1,R4>			;Restore registers
	RSB					;Return
;****************************************
;* Invalid machine check routine	*
;*					*
;* This routine is executed when a	*
;* machine check is caused when not	*
;* expected. This routine will output	*
;* the contents of the stack, the SBI	*
;* registers,the unibus registers and	*
;* the location where the machine	*
;* check occured the routine will then 	*
;* restart the diagnostic.		*
;****************************************
	.ALIGN	LONG
INVAL_MACH_CHK:
	MTPR	#INTR_DSABL,#PR$_RXCS		;Disable console interrupt
	MOVL	44(SP),R0			;Get location of error
	MOVAL	INVAL_LOC,R4			;Location for conversion
	JSB	HEX_ASCII			;Convert to ascii
	CALLG	INVAL_EXCEPTION,CONSOL_OUT	;Exception message
	CALLG	STACK_MESS,CONSOL_OUT		;Output message
	MOVZBL	(SP),R11			;Loop count
	DIVW	#4,R11				;Get # long words
5$:
	MOVAL	INVAL_MESS,R4			;Address for conversion
	MOVL	SP,R0				;Value to convert
	JSB	HEX_ASCII			;Convert to ascii
	MOVAL	INVAL_CONT,R4			;Address for conversion
	MOVL	(SP)+,R0			;Value to convert
	JSB	HEX_ASCII			;Convert to ascii
	CALLG	INVAL_MESS,CONSOL_OUT		;Output message
	SOBGTR	R11,5$				;Output machine check
	MOVAL	START,SP			;Reset stack pointer
	JSB	RESET_UNIBUS			;Reset unibus
	JSB	RESET_CPU			;Reset processor
	JSB	RESTORE				;Restore registers
	BRW	REQT1				;Go select next test
	.PAGE
	.SUBTITLE Print/plot driver
;********************************************************
;* Printer/plotter driver				*
;*							*
;* The driver is a multi-purpose driver which will	*
;* allow the user to transfer print, plot, SPP data in	*
;* DPC and DMA modes and also issue remote functions.	*
;*							*
;*  calling sequence					*
;*							*
;*  	JSB	PRINTER_PLOTTER_DRIVER			*
;*							*
;*	Mode = Type of call (byte)			*
;*	Loc  = Address of data (long)			*
;*	Count  = Byte count (word)			*
;*							*
;*							*
;*							*
;*  Mode indicator					*
;*	1-8 for print					*
;*							*
;*  Mode 1 = Remote clear				*
;*  Mode 2 = Remote line terminate			*
;*  Mode 3 = Remote formfeed				*
;*  Mode 4 = Remote EOT					*
;*  Mode 5 = Remote reset				*
;*  Mode 6 = Enter SPP mode				*
;*  Mode 7 = Exit SPP mode				*
;*  Mode 8 = Output print data				*
;*							*
;*	9-16 for plot					*
;*							*
;*  Mode 9  = Remote clear				*
;*  Mode 10 = Remote line terminate			*
;*  Mode 11 = Remote formfeed				*
;*  Mode 12 = Remote EOT				*
;*  Mode 13 = Remote reset				*
;*  Mode 14 = Enter SPP					*
;*  Mode 15 = Exit SPP					*
;*  Mode 16 = Transfer plot data			*
;********************************************************
PRINTER_PLOTTER_DRIVER:
	PUSHR	#^M<R2,R3,R4,R5>		;Save register
DRIVER_CONTINUE:
	MOVZBL	MODE,R3				;Get mode selection
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,SETUP_121
SETUP_122:
	MOVL	PRINT_CSR,R2			;Get controller CSR
	MOVL	PRINT_DATA_REG,R4		;Get controller data register
	CMPB	R3,#PRINT_MODE			;Print?
	BGTR	10$				;No plot
	CLRB	DRIVER_MODE			;Indicate driver in print mode
	JSB	SET_PRINT_122			;Set print mode for 122
	BRB	EXEC_COMND			;Go execute function
10$:
	MOVB	#1,DRIVER_MODE			;Indicate driver in plot mode
	JSB	SET_PLOT_122			;Set plot mode for 122
	SUBB	#8,R3				;Correct offset
	BRB	EXEC_COMND			;Go execute function
SETUP_121:
	CMPB	R3,#PRINT_MODE			;Print request
	BGTR	10$				;No plot
	CLRB	DRIVER_MODE			;Indicate driver in print mode
	MOVL	PRINT_CSR,R2			;Print csr
	BBS	#V_DMA_SELECT,DIAG_CONTROL,5$	;DMA output requested?
	MOVL	PRINT_DATA_REG,R4		;Print DPC data buffer
	BRB	EXEC_COMND			;Go execute function
5$:
	MOVL	DMA_PRINT_REG,R4		;Print DMA byte count register
	BRB	EXEC_COMND			;Go execute function
10$:
	MOVB	#1,DRIVER_MODE			;Indicate driver in plot mode
	SUBB	#8,R3				;Start from 0
	MOVL	PLOT_CSR,R2			;Get plot csr
	BBS	#V_DMA_SELECT,DIAG_CONTROL,15$	;DMA output requested?
	MOVL	PLOT_DATA_REG,R4		;DPC plot data buffer
	BRB	EXEC_COMND			;Go execute function
15$:
	MOVL	DMA_PLOT_REG,R4			;DMA plot byte count register
EXEC_COMND:
	DECB	R3				;Correct displacement
	MULL3	#4,R3,R5			;Get byte offset
	JMP	@DRIVER_FUNTBL(R5)		;Goto routine requested
REMOTE_FUN:
	MOVB	#2,DRIVER_MODE			;Indicate remote function
	MULW	#2,R3				;Word offset
	BISW	FUNBIT_TABLE(R3),(R2)		;Set selected function
	JSB	CHECK_READY			;Go check for ready or error
	BLBC	R0,5$				;No error
	BRW	PRINTER_PLOTTER_ERROR		;Error
5$:
	POPR	#^M<R2,R3,R4,R5>		;Restore register
	RSB					;Return to caller
OUTPUT_DATA:
	MOVL	LOC,R3				;Get address of buffer to output
	MOVZWL	COUNT,R5			;Get byte count
	BBS	#V_DMA_SELECT,DIAG_CONTROL,20$	;DMA output requested?
	JSB	CHECK_READY			;Check for ready
	CMPB	#1,R0				;Check for error
	BNEQ	5$				;Branch, no error
	BRW	PRINTER_PLOTTER_ERROR		;Error
5$:
	MOVB	(R3)+,(R4)			;Transfer 1 byte to controller
	CMPL	R5,#1				;Was it last byte?
	BNEQ	10$				;No
	TSTB	DRIVER_MODE			;Print mode?
	BNEQ	10$				;No
	BITW	SPP_BIT,(R2)			;SPP mode?
	BNEQ	15$				;Yes don't check ready
10$:
	CMPB	#READY_BIT,(R2)			;If ready, continue
	BEQL	15$				;Branch if equal
	JSB	CHECK_READY			;Ready?
	BLBS	R0,PRINTER_PLOTTER_ERROR	;Branch if error
15$:
	SOBGTR	R5,5$				;Loop till data transfered
	BRB	30$				;Go restore registers
20$:
	JSB	CHECK_READY			;Ready?
	BLBS	R0,PRINTER_PLOTTER_ERROR	;Branch if error
	BBC	#V_122_CONTROLLER,TYPE_CONTROLLER,25$
	BISW	#DMA_ADDR_122,(R2)		;Indicate 16 bit address to follow
	MOVW	R3,2(R2)			;Load 16 bit address to controller
	BISW	#DMA_BCNT_122,(R2)				;Indicate byte count to controller
	MNEGW	R5,2(R2)				;Load byte count in controller
	INCW	(R2)				;Start DMA operation
	BRB	30$				;Now go check status
25$:
	MOVW	R3,@DMA_ADDR_REG		;Lower 16 bits of buffer address
	MOVW	R5,(R4)				;Set DMA byte count
	TSTB	DRIVER_MODE			;Print mode?
	BNEQ	30$				;No check ready
	BITW	SPP_BIT,(R2)			;SPP mode?
	BNEQ	35$				;Yes just return
30$:
	JSB	CHECK_READY			;Ready?
	BLBS	R0,PRINTER_PLOTTER_ERROR	;Branch if error
35$:
	POPR	#^M<R2,R3,R4,R5>		;Restore register
	RSB					;Return to calling routine
EXIT_SPP:
	BICW	SPP_BIT,(R2)			;Clear SPP enable bit
	POPR	#^M<R2,R3,R4,R5>		;Restore register
	RSB					;Return to calling routine
PRINTER_PLOTTER_ERROR:
	MOVB	#OFF_LINE,ERROR_TYPE		;Indicate offline
	JSB	ERROR_DISPLAY			;Output error to console
	BRW	DRIVER_CONTINUE			;Repeat error
;************************************************
;* Check_ready routine				*
;*						*
;* This routine is called by the print/plot	*
;* driver and controller tests. the routine	*
;* expects R0 to contain the address of the	*
;* CSR to check for ready and error status.	*
;************************************************
CHECK_READY:
	BITW	#ERROR_BIT,(R2)			;Error?
	BNEQ	25$				;We have an error
	BITW	#READY_BIT,(R2)			;Ready?
	BEQL	5$				;No
	CLRL	R0				;No error
	RSB					;Return to calling routine
5$:
	MOVB	EXTN_TIME_COUNT,EXTN_TIME	;Set to wait for 100 seconds
	MTPR	INTERVAL_TIME,#PR$_NICR		;Set interval timer for 1 second
10$:
	MOVW	TIME_COUNT,WAIT_COUNT		;Set wait count
	MTPR	#ENABLE_CLOCK,#PR$_ICCS		;Start clock running
15$:
	BITW	#ERROR_BIT,(R2)			;Error?
	BEQL	20$				;No
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
	BRB	25$				;Error return
20$:
	BITW	#READY_BIT,(R2)			;Ready?
	BNEQ	30$				;Yes
	TSTW	WAIT_COUNT			;Timed out?
	BNEQ	15$				;No
	CALLG	OPIN4,CONSOL_OUT		;Output message
	DECB	EXTN_TIME			;Timed out?
	BNEQ	10$				;No
25$:
	MOVL	#1,R0				;Indicate error
	RSB					;Return to caller
30$:
	MTPR	#DISABLE_CLOCK,#PR$_ICCS	;Disable clock
35$:
	CLRL	R0				;Indicate no error on return
	RSB					;Return to caller
	.PAGE
	.SUBTITLE System control block
		.ALIGN	PAGE
SCB:
		.LONG		0
MACH_CHECK_VEC:	.ADDRESS	INVAL_MACH_CHK+1	;Machine check vector
	.REPEAT	46
		.LONG		0
	.ENDR
		.ADDRESS	TIMER_INTR	;Interval timer service routine
	.REPEAT	13
		.LONG		0
	.ENDR
		.ADDRESS	CONSOL_INTR	;Console receive service routine
	.ALIGN	PAGE
SCB_VECTOR:				;Second page for VAX11/750
	.REPEAT	128
	.LONG	0			;Fill with zeros
	.ENDR
	.PAGE
	.SUBTITLE Data storage area
;   main process section variables
;
NEXT_TEST:
FIRST_TEST:	.LONG	0			;First test indicator
LAST_TEST:	.LONG	0			;Last test indicator
CURNT_TEST:	.LONG	0			;Currrent test indicator
;************************************************
;*   Controller and printer/plotter variables	*
;************************************************
TYPE_PRINTER:	.LONG	0			;Type printer/plotter
TYPE_PRINTER_OFFSET:	.LONG	0		;Offset used by NAME_CHECK
DIAG_CONTROL:	.LONG	0			;Diagnostic control
TYPE_CONTROLLER:.LONG	0			;Type controller
PRINT_SIZE:	.WORD	0			;Columns per line
CHAR_SIZE:	.WORD	0			;Character set size
PLOT_SIZE:	.WORD	0			;Plot size
NIBSPR_INCH:	.WORD	0			;Nibs per inch
NIBSPR_SCAN:	.WORD	0			;Nibs per scan
SPPLN_SIZE:	.WORD	0			;Colums/line for SPP
SCANPR_CHAR:	.WORD	0			;Scans per character for SPP
SPP_BIT:	.WORD	0			;SPP bit for current controller
DMABUSY_BIT:	.WORD	0			;DMA busy bit for current controller
PLOT_PATTERN:	.WORD	0			;Plot pattern register
PLOT_GEN_FILL:	.WORD	0			;Plot fill count
LINE_FEED:	.BYTE	LF			;Line feed character
MAX_CHAR_SIZE:	.WORD	124			;Maximum character set
CARG_RET:	.BYTE	CR			;Carriage return
END_OF_TRAN:	.BYTE	EOT			;End of transmission
FORM_FEED:	.BYTE	FF			;Form feed character
LFLF:		.BYTE	<LF>,<LF>		;Line feed,line feed
CRLF:		.BYTE	<CR>,<LF>		;Carraige return, line feed
LFCR:		.BYTE	<LF>,<CR>		;Line feed, carriage return
ERROR_TYPE:	.BYTE	0			;Error type byte
MODE:		.BYTE	0			;Request mode indicator
LOC:		.LONG	0			;Address of data buffer
COUNT:		.WORD	0			;Driver byte count
WAIT_COUNT:	.WORD	0			;# seconds for check_ready to wait
INTERVAL_TIME:	.LONG	-1000000		;One second wait value
TIME_COUNT:	.WORD	10			;10 second wait count value
EXTN_TIME:	.BYTE	0			;Extend time counter
EXTN_TIME_COUNT:.BYTE	10			;Default extend time(100 sec.)
DRIVER_MODE:	.BYTE	0			;Drivers current mode
INTR_COMPLETE:	.BYTE	0			;Interrupt complete flag
;************************************************
;* Controller registers				*
;************************************************
STANDARD_CSR_121:	.LONG	^O777510	;Standard plot csr address
STANDARD_CSR_122:	.LONG	^O777514	;Standard CSR for 122
STAN_DMA_PLTRG:	.LONG	^O777500		;Standard DMA address
DEFPR_VECTOR:	.LONG	^X80			;Standard print vector
DEFPL_VECTOR:	.LONG	^X7C			;Standard plot vector
DEF_PRIORITY:	.BYTE	^X14			;Default priority
PLOT_CSR:	.LONG	0			;Plot status word
PLOT_DATA_REG:	.LONG	0			;Plot data register
PRINT_CSR:	.LONG	0			;Print status word
PRINT_DATA_REG:	.LONG	0			;Print data register
DMA_PLOT_REG:	.LONG	0			;DMA plot byte count trgister
DMA_EXT_REG:	.LONG	0			;DMA extended addressing register
DMA_PRINT_REG:	.LONG	0			;DMA print byte count register
DMA_ADDR_REG:	.LONG	0			;DMA buffer address register
PLOT_VECTOR:	.LONG	0			;Plot vector address
PRINT_VECTOR:	.LONG	0			;Print vector address
INTR_VECTOR:	.WORD	0			;Address of unibus vector
PRIORITY:	.BYTE	0			;Priorty level
TYPE_TEST:	.BYTE	0			;Type test indicator
FILL_COUNT:	.WORD	0			;Fill count for cgen and crot
END_INFO_PLOT:
INFO_PLOT_SIZ	=	<END_INFO_PLOT-PLOT_CSR>;Length of controller registers
PRIORTY_TABL:					;Unibus interrupt level table
		.BYTE	^X14			;Device level 4
		.BYTE	^X15			;Device level 5
		.BYTE	^X16			;Device level 6
		.BYTE	^X17			;Device level 7
TYPE_INDEX_CNVRT:				;Convert form integer to bit
		.BYTE	1
		.BYTE	2
		.BYTE	4
		.BYTE	8
;************************************************
;*     VAX variables and registers		*
;************************************************
TYPE_CPU:	.BYTE	0			;Type cpu register
UBA_ADDR_SPACE:
		.LONG	0			;Unibus register space
;
;     VAX-11/730 variables and registers
;
UBA_730_ADDR:	.LONG	^XF26000		;VAX11/730 Unibus space
UBA_730_IO_SPACE:
		.LONG	^XFC0000		;VAX11/730 I/O PORTS
CSR1_730:
		.LONG	^XF20004		;CSR1 REGISTER
;
;     VAX-11/750 variables and registers
;
UBA_750_ADDR:	.LONG	^XF30000		;Unibus #0
		.LONG	^XF32000		;Unibus #1
UBA_750_IO_SPACE:
		.LONG	^XFC0000		;VAX11/750 I/O ports
		.LONG	^XF80000		
;
;     VAX-11/780 variables and registers
;
BRRVR_USED:	.BYTE	0			;Offset values of brrvr used
CONSOL_EDT:	.BYTE	0			;Console buffer edit flag
UBA_780_IO_SPACE:
		.LONG	^X2013E000		;VAX11/780 I/O ports
		.LONG	^X2017E000
		.LONG	^X201BE000
		.LONG	^X201FE000
UBA_780_ADDR:
		.LONG	^X20006000		;Unibus #0
		.LONG	^X20008000		;Unibus #1
		.LONG	^X2000A000		;Unibus #2
		.LONG	^X2000C000		;Unibus #3
TR_NUMBER_TABLE:
		.BYTE	3			;Valid UNIBUS TR NUMBER
		.BYTE	4
		.BYTE	5
		.BYTE	6
TR_NUMBER_780:	.BYTE	0			;Transfer number of UBA 0-15
	.PAGE
	.SUBTITLE Table directory
;************************************************
;*   Test address table				*
;************************************************
CONTB:						;Addresses of available tests
	.ADDRESS	CON1
	.ADDRESS	CON2
	.ADDRESS	CON3
	.ADDRESS	CON4
	.ADDRESS	CON5
	.ADDRESS	CON6
	.ADDRESS	CON7
	.ADDRESS	CON8
	.ADDRESS	CON9
	.ADDRESS	CON10
	.ADDRESS	CON11
	.ADDRESS	CON12
	.ADDRESS	CON13
	.ADDRESS	CON14
CONEND:	.ADDRESS	CON15
PRNTB:
	.ADDRESS	PRN1			;Print tests
	.ADDRESS	PRN2
	.ADDRESS	PRN3
	.ADDRESS	PRN4
	.ADDRESS	PRN5
	.ADDRESS	PRN6
PRNEND:	.ADDRESS	PRN7
PLTTB:
	.ADDRESS	PLT1			;Plot tests
	.ADDRESS	PLT2
	.ADDRESS	PLT3
	.ADDRESS	PLT4
	.ADDRESS	PLT5
	.ADDRESS	PLT6
	.ADDRESS	PLT7
PLTEND:	.ADDRESS	PLT8
PPTTB:						;Print/plot tests
PPEND:	.ADDRESS	PPL1
SPPTB:						;SPP tests
SPPEND:	.ADDRESS	SPP1
;*************************************************
;* Test type table				 *
;*						 *
;* This table is used by the routine name_check  *
;* to determine the type test requested. If not  *
;* found in this table an error will be generated*
;*************************************************
TYPE_TEST_TBL:
	.ASCII	/AL/				;All printer/plotter test
	.ASCII	/SP/				;SPP tests request
	.ASCII	/PP/				;Print/plot tests request
	.ASCII	/PL/				;Plot only tests
	.ASCII	/PR/				;Print only tests
	.ASCII	/CO/				;Contoller tests
TYPE_TBL_SIZE	=	.-TYPE_TEST_TBL		;Number of bytes in table
;*************************************************
;* Valid type printer/plotter table		 *
;*						 *
;* This table is used by printer_plotter_init	 *
;* to compare what the user has entered in the   *
;* console input buffer.			 *
;*************************************************
TYPE_DEVICE_TBL:
	.ASCII	/PR/				;Printer/plotter with SPP option
	.ASCII	/PL/				;Printer/plotter
	.ASCII	/PP/				;Plotter only
	.ASCII	/SP/				;Printer only
TYPE_DEVICE_SIZ	=	<.-TYPE_DEVICE_TBL>/2	;Size of table in words
;************************************************
;* Execution table				*
;*						*
;* Table contains the following info:		*
;*						*
;*   long word 1 = # of tests			*
;*						*
;*   long word 2 = address of first test	*
;*						*
;*   long word 3 = address of first test	*
;*************************************************
TNMTB:						;Controller test
	.LONG		<<CONEND-CONTB>/4>+1
	.ADDRESS	CONTB
	.ADDRESS	CONEND
						;Print test
	.LONG		<<PRNEND-PRNTB>/4>+1
	.ADDRESS	PRNTB
	.ADDRESS	PRNEND
						;Plotter test
	.LONG		<<PLTEND-PLTTB>/4>+1
	.ADDRESS	PLTTB
	.ADDRESS	PLTEND
						;Printer/plotter test
	.LONG		<<PPEND-PPTTB>/4>+1
	.ADDRESS	PPTTB
	.ADDRESS	PPEND
						;SPP test
	.LONG		<<SPPEND-SPPTB>/4>+1
	.ADDRESS	SPPTB
	.ADDRESS	SPPEND
						;All printer test
	.LONG		<<PRNEND-PRNTB>/4>+1
	.ADDRESS	PRNTB
	.ADDRESS	PRNEND
						;All plot test
	.LONG		<<PLTEND-PLTTB>/4>+1
	.ADDRESS	PLTTB
	.ADDRESS	PLTEND
						;All printer/plotter test
	.LONG		<<PPEND-PRNTB>/4>+1
	.ADDRESS	PRNTB
	.ADDRESS	PPEND
						;All printer/plotter & SPP test
	.LONG		<<SPPEND-PRNTB>/4>+1
	.ADDRESS	PRNTB
	.ADDRESS	SPPEND
 
;************************************************
;*  Driver address function table		*
;************************************************
DRIVER_FUNTBL:
	.ADDRESS	REMOTE_FUN		;Remote clear
	.ADDRESS	REMOTE_FUN		;Remote line terminate
	.ADDRESS	REMOTE_FUN		;Remote formfeed
	.ADDRESS	REMOTE_FUN		;Remote EOT
	.ADDRESS	REMOTE_FUN		;Remote reset
	.ADDRESS	REMOTE_FUN		;Enter SPP mode
	.ADDRESS	EXIT_SPP		;Exit SPP mode
	.ADDRESS	OUTPUT_DATA		;Output data
FUNBIT_TABLE:
	.WORD		0			;Remote clear bit
	.WORD		0			;Remote line terminate bit
	.WORD		0			;Remote formfeed bit
	.WORD		0			;Remote EOT bit
	.WORD		0			;Remote reset bit
	.WORD		0			;SPP bit
FUNBIT_TABLE_END:
FUNBIT_TABLE_LEN = <<FUNBIT_TABLE_END-FUNBIT_TABLE>/2>
 
FUNBIT_TABLE_121:
	.WORD		CLEAR_BIT_121		;Remote clear bit
	.WORD		LNTERM_BIT_121		;Remote line terminate bit
	.WORD		FORMFD_BIT_121		;Remote formfeed bit
	.WORD		EOT_BIT_121		;Remote EOT bit
	.WORD		RESET_BIT_121		;Remote reset bit
	.WORD		SPP_BIT_121		;SPP bit
FUNBIT_TABLE_122:
	.WORD		CLEAR_BIT_122		;Remote clear bit
	.WORD		LNTERM_BIT_122		;Remote line terminate bit
	.WORD		FORMFD_BIT_122		;Remote formfeed bit
	.WORD		EOT_BIT_122		;Remote EOT bit
	.WORD		RESET_BIT_122		;Remote reset bit
	.WORD		SPP_BIT_122		;SPP bit
 
;****************************************
;* Invalid interrupt service table	*
;*					*
;* This table contains the address of	*
;* the interrupt service routines	*
;* that will be used for a good         *
;* interrupt but wrong priority.        *
;****************************************
INVAL_INTTBL:
	.ADDRESS	INVINT_BR4		;Priority 4
	.ADDRESS	INVINT_BR5		;Priority 5
	.ADDRESS	INVINT_BR6		;Priority 6
	.ADDRESS	INVINT_BR7		;Priority 7
;********************************
;* Print message parameters     *
;********************************
PRN2_MESS_PRM:
	.ADDRESS	PRN2_MESS		;Address of message
	.WORD		PRN2_MESS_SIZ		;Number of bytes to transfer
PRN2A_MESS_PRM:
	.ADDRESS	PRN2A_MESS
	.WORD		PRN2A_MESS_SIZ
PRN3_MESS_PRM:
	.ADDRESS	PRN3_MESS
	.WORD		PRN3_MESS_SIZ
PRN3A_MESS_PRM:
	.ADDRESS	PRN3A_MESS
	.WORD		PRN3A_MESS_SIZ
PRN4_MESS_PRM:
	.ADDRESS	PRN4_MESS
	.WORD		PRN4_MESS_SIZ
PRN4A_MESS_PRM:
	.ADDRESS	PRN4A_MESS
	.WORD		PRN4A_MESS_SIZ
PRN4B_MESS_PRM:
	.ADDRESS	PRN4B_MESS
	.WORD		PRN4B_MESS_SIZ
PRN4C_MESS_PRM:
	.ADDRESS	PRN4C_MESS
	.WORD		PRN4C_MESS_SIZ
PRN4D_MESS_PRM:
	.ADDRESS	PRN4D_MESS
	.WORD		PRN4D_MESS_SIZ
PRN4E_MESS_PRM:
	.ADDRESS	PRN4E_MESS
	.WORD		PRN4E_MESS_SIZ
PRN4F_MESS_PRM:
	.ADDRESS	PRN4F_MESS
	.WORD		PRN4F_MESS_SIZ
PRN6_MESS_PRM:
	.ADDRESS	PRN6_MESS
	.WORD		PRN6_MESS_SIZ
PRN6A_MESS_PRM:
	.ADDRESS	PRN6A_MESS
	.WORD		PRN6A_MESS_SIZ
PRN7_MESS_PRM:
	.ADDRESS	PRN7_MESS
	.WORD		PRN7_MESS_SIZ
PRN7A_MESS_PRM:
	.ADDRESS	PRN7A_MESS
	.WORD		PRN7A_MESS_SIZ
;********************************
;* Error message type table     *
;********************************
ERM_TYPE_TBL:
	.ADDRESS	ERM_TYPE_0
	.ADDRESS	ERM_TYPE_1
	.ADDRESS	ERM_TYPE_2
	.ADDRESS	ERM_TYPE_3
	.ADDRESS	ERM_TYPE_4
	.ADDRESS	ERM_TYPE_5
	.ADDRESS	ERM_TYPE_6
	.ADDRESS	ERM_TYPE_7
	.ADDRESS	ERM_TYPE_8
	.ADDRESS	ERM_TYPE_9
;********************************
;* Error mode table		*
;********************************
ERM_MODE_TBL:
	.ADDRESS	ERM_MODE_0
	.ADDRESS	ERM_MODE_1
	.ADDRESS	ERM_MODE_2
	.ADDRESS	ERM_MODE_3
	.ADDRESS	ERM_MODE_4
	.ADDRESS	ERM_MODE_5
	.ADDRESS	ERM_MODE_6
	.ADDRESS	ERM_MODE_7
	.ADDRESS	ERM_MODE_8
	.ADDRESS	ERM_MODE_9
	.ADDRESS	ERM_MODE_10
	.ADDRESS	ERM_MODE_11
	.ADDRESS	ERM_MODE_12
	.ADDRESS	ERM_MODE_13
	.ADDRESS	ERM_MODE_14
	.ADDRESS	ERM_MODE_15
	.ADDRESS	ERM_MODE_16
	.ADDRESS	ERM_MODE_17
	.ADDRESS	ERM_MODE_18
	.ADDRESS	ERM_MODE_19
	.ADDRESS	ERM_MODE_20
	.ADDRESS	ERM_MODE_21
	.ADDRESS	ERM_MODE_22
	.ADDRESS	ERM_MODE_23
	.ADDRESS	ERM_MODE_24
	.ADDRESS	ERM_MODE_25
	.ADDRESS	ERM_MODE_26
	.ADDRESS	ERM_MODE_27
	.ADDRESS	ERM_MODE_28
	.ADDRESS	ERM_MODE_29
	.ADDRESS	ERM_MODE_30
	.ADDRESS	ERM_MODE_31
	.ADDRESS	ERM_MODE_32
	.PAGE
	.SUBTITLE Message section
;************************************************
;*   diagnostic information message		*
;************************************************
DIAG_INFO_MESS:
	.ASCII	<CR><LF><LF>\        **** VERSATEC VAX11/\
DIAG_INFO_TYPE:
	.BYTE	0,0,0
	.ASCII	\ ****\<CR><LF><LF>
	.ASCII	\ 121/122 Printer/Plotter and Controller Diagnostic Rev. G\
	.ASCII	<CR><LF><LF>
	.ASCII	\ Default controller address for 121 controller:\<CR><LF><LF>
	.ASCII	\     Plot Control Status Register  = 777510\<CR><LF>
	.ASCII	\     Plot Data register            = 777512\<CR><LF>
	.ASCII	\     Print Control Status Register = 777514\<CR><LF>
	.ASCII	\     Print Data Register           = 777516\<CR><LF><LF>
	.ASCII	\     DMA Plot Byte Count Register  = 777500\<CR><LF>
	.ASCII	\     DMA Ext. Address Register     = 777502\<CR><LF>
	.ASCII	\     DMA Print Byte Count Register = 777504\<CR><LF>
	.ASCII	\     DMA Address Register          = 777506\<CR><LF><LF>
	.ASCII	\ Default controller address for 122 controller\<CR><LF><LF>
	.ASCII	\     Control Status Register       = 777514\<CR><LF>
	.ASCII	\     Command/Data Register         = 777516\<CR><LF><LF>
	.ASCII	\ For more information type HELP\
	.ASCII	\ followed by a carriage return,\<CR><LF>
	.ASCII	\ after configuring the diagnostic.\<CR><LF><LF><0>
;
VAX_730_MESS:	.ASCII	\730\
VAX_750_MESS:	.ASCII	\750\
VAX_780_MESS:	.ASCII	\780\
VAX_790_MESS:	.ASCII	\790\
	.PAGE
	.SUBTITLE Controller configuration messages
;************************************************	
;   Controller configure messages		*
;************************************************
CTM1:	.ASCIZ	\Controller configuration\
CTM2:	.ASCIZ	\Enter controller model number (121, 122)\
CTM3:	.ASCIZ	\Standard device address? (Y or N)\
CTM4:	.ASCIZ	\Enter print interrupt vector\
CTM5:	.ASCIZ	\Enter plot interrupt vector\
CTM6:	.ASCIZ	\Enter controller priority (4,5,6,7)\
CTM7:	.ASCIZ	\Enter DPC plot control and status register address\
CTM8:	.ASCIZ	\Enter DMA plot byte count register address\
CTM9:	.ASCIZ	\Enter transfer mode (DPC or DMA)\
CTM10:	.ASCIZ	\Enter UBA number (0,1,2,3)\
CTM11:	.ASCIZ	\Enter control and status register address\
CTM12:	.ASCIZ	\Enter UBI number (0,1)\
	.ALIGN	LONG
CONT_121:	.ASCII	/121/<CR>		;Type controller response
CONT_122:	.ASCII	/122/<CR>		;Type controller response
DPC_ANS:	.ASCII	/DPC/<CR>		;DPC transfer mode response
DMA_ANS:	.ASCII	/DMA/<CR>		;DMA transfer mode response
	.PAGE
	.SUBTITLE Printer/plotter configuration messages
;************************************************
;   Printer/plotter configuration messages	*
;************************************************
MTM1:	.ASCIZ	\Printer/Plotter configuration\
MTM2:	.ASCIZ	\Enter Printer/Plotter type (PR,PL,PP,SP)\
MTM3:	.ASCIZ	\Enter print size (BYTES)\
MTM4:	.ASCIZ	\Enter character set size (64,96,124,128,256)\
MTM5:	.ASCIZ	\Enter plot size (BYTES)\
MTM6:	.ASCIZ	\Enter number of NIBS per inch\
MTM7:	.ASCIZ	\Enter number of scan lines per character line for SPP\
	.PAGE
	.SUBTITLE Operator command messages
;************************************************	
;   Operator command messages			*
;************************************************
OPIN1:	.ASCIZ	<CR><LF>\Select next test\
OPIN2:	.ASCIZ	\Power down printer/plotter\
OPIN3:	.ASCIZ	\Power up printer/plotter\
OPIN4:	.ASCIZ	\Waiting for printer/plotter\
OPIN5:	.ASCIZ	\Remove paper and push advance\
OPIN6:	.ASCIZ	\Replace paper\
OPIN7:	.ASCIZ	\then press carriage return on console\
CNTRL_C_MESS:	.ASCIZ	\^C\
CNTRL_O_MESS:	.ASCIZ	\^O\
CNTRL_Z_MESS:	.ASCIZ	\^Z\
CNTRL_U_MESS:	.ASCIZ	\^U\
FF_DIS_MESS:	.ASCIZ	<CR><LF>\Form feed between tests disabled\<CR><LF>
FF_ENA_MESS:	.ASCIZ	<CR><LF>\Form feed between tests enabled\<CR><LF>
	.PAGE
	.SUBTITLE Printer/plotter test messages
;************************************************
;	Printer/plotter test messages		*
;************************************************
		.EVEN
PRN2_MESS:	.ASCII	\BUFFER NOT CLEARED\
PRN2_MESS_SIZ	=	.-PRN2_MESS
		.EVEN
PRN2A_MESS:	.ASCII	\BUFFER CLEARED\
PRN2A_MESS_SIZ	=	.-PRN2A_MESS
		.EVEN
PRN3_MESS:	.ASCII	\REMOTE RESET TEST\
PRN3_MESS_SIZ	=	.-PRN3_MESS
		.EVEN
PRN3A_MESS:	.ASCII	\BUFFER NOT RESET\
PRN3A_MESS_SIZ	=	.-PRN3A_MESS
		.EVEN
PRN4_MESS:	.ASCII	\REMOTE LINE TERMINATE\
PRN4_MESS_SIZ	=	.-PRN4_MESS
		.EVEN
PRN4A_MESS:	.ASCII	\CR LINE TERMINATE\
PRN4A_MESS_TERM:.BYTE	0
PRN4A_MESS_SIZ	=	.-PRN4A_MESS
		.EVEN
PRN4B_MESS:	.ASCII	\LF LINE TERMINATE\
PRN4B_MESS_TERM:.BYTE	0
PRN4B_MESS_SIZ	=	.-PRN4B_MESS
		.EVEN
PRN4C_MESS:	.ASCII	\LF LF LINE TERMINATE\
PRN4C_MESS_TERM:.BYTE	0,0
PRN4C_MESS_SIZ	=	.-PRN4C_MESS
		.EVEN
PRN4D_MESS:	.ASCII	\LF CR LINE TERMINATE\
PRN4D_MESS_TERM:.BYTE	0,0
PRN4D_MESS_SIZ	=	.-PRN4D_MESS
		.EVEN
PRN4E_MESS:	.ASCII	\CR LF LINE TERMINATE\
PRN4E_MESS_TERM:.BYTE	0,0
PRN4E_MESS_SIZ	=	.-PRN4E_MESS
		.EVEN
PRN4F_MESS:	.ASCII	\END OF PR04\
PRN4F_MESS_SIZ	=	.-PRN4F_MESS
		.EVEN
PRN6_MESS:	.ASCII	\FF-ASCII\
PRN6_MESS_TERM:	.BYTE	0			;Space for formfeed character
PRN6_MESS_SIZ	=	.-PRN6_MESS
		.EVEN
PRN6A_MESS:	.ASCII	\FF-REMOTE\
PRN6A_MESS_SIZ	=	.-PRN6A_MESS
		.EVEN
PRN7_MESS:	.ASCII	\EOT-ASCII\
PRN7_MESS_TERM:	.BYTE	0			;Space for EOT character
PRN7_MESS_SIZ	=	.-PRN7_MESS
		.EVEN
PRN7A_MESS:	.ASCII	\EOT-REMOTE\
PRN7A_MESS_SIZ	=	.-PRN7A_MESS
	.PAGE
	.SUBTITLE Error messages
;************************************************
;  Error messages				*
;************************************************
CONFIG_ERROR:
		.ASCII	<CR><LF>\Right now I know about a\
		.ASCII	\ VAX11/780, VAX11/750 and a VAX11/730.\
		.ASCII	\ I don't know how to work on this processor, so \
		.ASCII	\ I must abort my self.\<CR><LF><LF><0>
ERROR_MESS:	.BLKB	80			;Space for error messages
STATUS_MESS:	.ASCII	\Print status = \
PR_STATUS:	.BLKB	6
PL_MESS:	.ASCII	\ plot status = \
PL_STATUS:	.BLKB	6
		.BYTE	0
VECTOR_ERR_MESS:
		.ASCIZ	\*** Print and plot vectors can not be the same ***\
CNTRL_ADDR_MESS:.ASCII	\*** Could not find controller on Unibus\
		.ASCIZ	\ or wrong Unibus Adaptor selected ***\
UBA_ADDR_MESS:	.ASCIZ	\*** Unibus Adaptor not found ***\
INVAL_VECT_MESS:.ASCII	\*** Interrupt occured but wrong vector address \
INVAL_VECT:	.BLKB	5
		.ASCIZ	\ ***\
INVAL_PRIO_MESS:.ASCII	\*** Interrupt occured at vector address \
VECT_FOUND:	.BLKB	5
		.BYTE	<CR>,<LF>
		.ASCII	\    but priority was \
PRIO_FOUND:	.BYTE	0
		.ASCII	\ and expected priority \
PRIO_EXPT:	.BYTE	0,0
INVAL_EXCEPTION:.ASCII	\*** Invalid machine check occured at location \
INVAL_LOC:	.BLKB	8
		.ASCIZ	\ ***\
STACK_MESS:	.ASCIZ	\*** Stack contents ***\
INVAL_MESS:	.BLKB	8
		.ASCII	\    \
INVAL_CONT:	.BLKB	8
		.BYTE	0
ERM_TYPE_0:	.ASCIZ	\How do I know what is wrong!!!\
ERM_TYPE_1:	.ASCIZ	\Not ready \
ERM_TYPE_2:	.ASCIZ	\Bit on abnormal \
ERM_TYPE_3:	.ASCIZ	\Bit off abnormal \
ERM_TYPE_4:	.ASCIZ	\Not ready after interrupt (PRINT) \
ERM_TYPE_5:	.ASCIZ	\Not ready after interrupt (PLOT) \
ERM_TYPE_6:	.ASCIZ	\No interrupt for DPC (PRINT) \
ERM_TYPE_7:	.ASCIZ	\No interrupt for DPC (PLOT) \
ERM_TYPE_8:	.ASCIZ	\No interrupt for DTC (PRINT) \
ERM_TYPE_9:	.ASCIZ	\No interrupt for DTC (PLOT) \
ERM_MODE_0:	.BYTE	0
ERM_MODE_1:	.ASCIZ	\issuing remote clear (PRINT)\
ERM_MODE_2:	.ASCIZ	\issuing remote line terminate (PRINT)\
ERM_MODE_3:	.ASCIZ	\issuing remote form feed (PRINT)\
ERM_MODE_4:	.ASCIZ	\issuing remote EOT (PRINT)\
ERM_MODE_5:	.ASCIZ	\issuing remote reset (PRINT)\
ERM_MODE_6:	.ASCIZ	\entering SPP mode (PRINT)\
ERM_MODE_7:	.ASCIZ	\exiting SPP mode (PRINT)\
ERM_MODE_8:	.ASCIZ	\transferring print data\
ERM_MODE_9:	.ASCIZ	\issuing remote clear (PLOT)\
ERM_MODE_10:	.ASCIZ	\issuing remote line terminate (PLOT)\
ERM_MODE_11:	.ASCIZ	\issuing remote form feed (PLOT)\
ERM_MODE_12:	.ASCIZ	\issuing remote EOT (PLOT)\
ERM_MODE_13:	.ASCIZ	\issuing remote reset (PLOT)\
ERM_MODE_14:	.ASCIZ	\entering SPP mode (PLOT)\
ERM_MODE_15:	.ASCIZ	\exiting SPP mode (PLOT)\
ERM_MODE_16:	.ASCIZ	\transferring plot data\
ERM_MODE_17:	.ASCIZ	\ready bit (bit 7-print status)\
ERM_MODE_18:	.ASCIZ	\error bit (bit 15-print status)\
ERM_MODE_19:	.ASCIZ	\interrupt bit (bit 6-print status)\
ERM_MODE_20:	.ASCIZ	\ready bit (bit 7-plot status)\
ERM_MODE_21:	.ASCIZ	\error bit (bit 15-plot status)\
ERM_MODE_22:	.ASCIZ	\interrupt bit (bit 6-plot status)\
ERM_MODE_23:	.ASCII	\DMA busy bit (bit \
MOD_ERM_23:	.ASCIZ	\13-print status)\
ERM_MODE_24:	.ASCII	\DMA busy bit (bit \
MOD_ERM_24:	.ASCIZ	\13-plot status)\
ERM_MODE_25:	.ASCII	\SPP bit (bit \
MOD_ERM_25:	.ASCIZ	\ 0-print status)\
ERM_MODE_26:	.ASCII	\SPP bit (bit \
MOD_ERM_26:	.ASCIZ	\ 0-plot status)\
ERM_MODE_27:	.ASCIZ	\DMA swap byte bit (bit 9-print status)\
ERM_MODE_28:	.ASCIZ	\DMA swap byte bit (bit 9-plot status)\
ERM_MODE_29:	.ASCIZ	\print/plot bit (bit 10)\
ERM_MODE_30:	.ASCIZ	\DMA mode bit (bit 11)\
ERM_MODE_31:	.ASCIZ	\DMA mode bit (bit 12)\
ERM_MODE_32:	.ASCIZ	\DMA mode,print/plot,SPP, and/or swap bits\
.PAGE
	.SUBTITLE Test sequence number messages
;************************************************
;   Test sequence number messages		*
;************************************************
COM1:		.ASCIZ	\CO01 - Error and ready bit test\
COM2:		.ASCIZ	\CO02 - Out of paper test\
COM3:		.ASCIZ	\CO03 - SPP bit test\
COM4:		.ASCIZ	\CO04 - DPC interrupt test\
COM5:		.ASCIZ	\CO05 - DMA busy bit test\
COM6:		.ASCIZ	\CO06 - DMA addressing test\
COM7:		.ASCIZ	\CO07 - DTC interrupt test\
COM8:		.ASCIZ	\CO08 - DMA illegal memory address test\
COM9:		.ASCIZ	\CO09 - Plot byte swap function test\
COM10:		.ASCIZ	\CO10 - Print byte swap function test\
COM11:		.ASCIZ	\CO11 - Print/plot bit test\
COM12:		.ASCIZ	\CO12 - DMA mode bits and reset all test\
COM13:		.ASCIZ	\CO13 - Swap bytes in PIO mode test\
COM14:		.ASCIZ	\CO14 - Bit lock test\
COM15:		.ASCIZ	\CO15 - Null remote function code test\
PRM1:		.ASCIZ	\PR01 - Full buffer print test\
PRM2:		.ASCIZ	\PR02 - Buffer clear test\
PRM3:		.ASCIZ	\PR03 - Buffer reset test\
PRM4:		.ASCIZ	\PR04 - Line terminate test\
PRM5:		.ASCIZ	\PR05 - Full buffer terminate test\
PRM6:		.ASCIZ	\PR06 - Form feed test\
PRM7:		.ASCIZ	\PR07 - End of transmission test\
PLM1:		.ASCIZ	\PL01 - Full buffer plot test\
PLM2:		.ASCIZ	\PL02 - Diagonal line with box test\
PLM3:		.ASCIZ	\PL03 - Sail plot test\
PLM4:		.ASCIZ	\PL04 - Cross talk test\
PLM5:		.ASCIZ	\PL05 - Nib test\
PLM6:		.ASCIZ	\PL06 - Remote clear test\
PLM7:		.ASCIZ	\PL07 - Remote form feed test\
PLM8:		.ASCIZ	\PL08 - Remote EOT test\
PPM1:		.ASCIZ	\PP01 - Print and plot alternate test\
SPM1:		.ASCIZ	\SP01 - Full buffer print diagonal line test\
	.PAGE
	.SUBTITLE Help message section
HELP_INFO_MESS:
	.ASCII	<CR><LF><LF>\Command Structure:\<CR><LF><LF>
	.ASCII	\    [A or M ] AANNCR\<CR><LF><LF>
	.ASCII	\    Where:\<CR><LF><LF>
	.ASCII	\         A  = Automatic Mode\<CR><LF>
	.ASCII	\         M  = Manual Mode\<CR><LF>
	.ASCII	\         AA = Type of test\<CR><LF>
	.ASCII	\            = AL - Select all tests\<CR><LF>
	.ASCII	\            = PR - Select print tests\<CR><LF>
	.ASCII	\            = PL - Select plot tests\<CR><LF>
	.ASCII	\            = PP - Select print/plot tests\<CR><LF>
	.ASCII	\            = SP - Select SPP tests\<CR><LF>
	.ASCII	\            = CO - Select controller tests\<CR><LF>
	.ASCII	\         NN = Test Number\<CR><LF>
	.ASCII	\            = 00  - Select all of type test\<CR><LF>
	.ASCII	\            = 01-NN - Specific test number\<CR><LF>
	.ASCII	\         CR = Carriage return\<CR><LF><LF>
	.ASCII	\Special Commands:\<CR><LF><LF>
	.ASCII	\         R  = Re-configure diagnostic\<CR><LF>
	.ASCII	\         T  = Change transfer mode (DPC or DMA)\<CR><LF>
	.ASCII	<LF><LF>\Note: All commands are terminated by a\
	.ASCII	\ carriage return\<CR><LF><LF>
	.ASCII	\Tests Available:\<CR><LF><LF>
	.ASCII	\      CO00 - All controller tests\<CR><LF>
	.ASCII	\      CO01 - Error and ready bit test\<CR><LF>
	.ASCII	\      CO02 - Out of paper test\<CR><LF>
	.ASCII	\      CO03 - SPP bit test\<CR><LF>
	.ASCII	\      CO04 - DPC interrupt test\<CR><LF>
	.ASCII	\      CO05 - DMA busy bit test\<CR><LF>
	.ASCII	\      CO06 - DMA addressing test\<CR><LF>
	.ASCII	\      CO07 - DTC interrupt test\<CR><LF>
	.ASCII	\      CO08 - DMA illegal memory address test\<CR><LF>
	.ASCII	\      CO09 - Plot byte swap function test\<CR><LF>
	.ASCII	\      CO10 - Print byte swap function test\<CR><LF>
	.ASCII	\      CO11 - Print/plot bit test\<CR><LF>
	.ASCII	\      CO12 - DMA mode bits and reset all test\<CR><LF>
	.ASCII	\      CO13 - Swap bytes in PIO mode test\<CR><LF>
	.ASCII	\      CO14 - Bit lock test\<CR><LF>
	.ASCII	\      CO15 - Null remote function code test\<CR><LF><LF>
	.ASCII	\      PR00 - All print tests\<CR><LF>
	.ASCII	\      PR01 - Full buffer print test\<CR><LF>
	.ASCII	\      PR02 - Buffer clear test\<CR><LF>
	.ASCII	\      PR03 - Buffer reset test\<CR><LF>
	.ASCII	\      PR04 - Line terminate test\<CR><LF>
	.ASCII	\      PR05 - Full buffer terminate test\<CR><LF>
	.ASCII	\      PR06 - Form feed test\<CR><LF>
	.ASCII	\      PR07 - End of transmission test\<CR><LF><LF>
	.ASCII	\      PL00 - All plot tests\<CR><LF>
	.ASCII	\      PL01 - Full buffer plot test\<CR><LF>
	.ASCII	\      PL02 - Diagonal line with box test\<CR><LF>
	.ASCII	\      PL03 - Sail plot test\<CR><LF>
	.ASCII	\      PL04 - Cross talk test\<CR><LF>
	.ASCII	\      PL05 - Nib test\<CR><LF>
	.ASCII	\      PL06 - Remote clear test\<CR><LF>
	.ASCII	\      PL07 - Remote form feed test\<CR><LF>
	.ASCII	\      PL08 - Remote EOT test\<CR><LF><LF>
	.ASCII	\      PP00 - All print/plot tests\<CR><LF>
	.ASCII	\      PP01 - Print and plot alternate test\<CR><LF><LF>
	.ASCII	\      SP00 - All SPP tests\<CR><LF>
	.ASCII	\      SP01 - Full buffer print diagonal line test\<CR><LF><0>
		.PAGE
	.SUBTITLE Print/plot buffers
	.ALIGN	PAGE
CONSOL_BUF:					;Console input buffer
PRINT_BUF:	.BLKW	1000			;Print buffer
	.EVEN
PLOT_BUF:	.WORD	0			;Plot buffer
	.END START
