ER[DGP];

%TO ASSEMBLE:	@MI@ DGP
		IGNORE REDEFINING W ERROR AT TPL1C+8 (NO PROBLEM)
TO RUN:		MIDAS RDGP
		START;G

TESTS ALL P-REGISTER INPUTS (EXCEPT P←P1 AND P←B WHICH HAVE ALREADY BEEN
TESTED), YKPTR←, ASHOVF, XMASK, AMASK, BAMASK, SAMASK, NEGY, BPC
%
INSERT[DBEG.MC];
TARGET[ILC];

*SET UP SCRATCH MEMORY CONSTANTS WHICH MIGHT HAVE BEEN CLOBBERED BY THE
*SCRATCH MEMORY TEST

SV[777S,777];

PTEST:	Q←A1;
	-1S←Q, CALL[Q11];	 *Q←777
	777S←Q, CALL[Q41];	*Q←77
	L13←R13←77S←Q, CALL[Q42], P←B;	*P←77, Q←17
	B←P-Q-1, Q RSH 1, P←B;	*P←57, Q←7
	B←P-Q-1, Q RSH 1, P←B;	*P←47, Q←3
	Q←P-Q;			*Q←44
	44S←L12←R12←Q;

*ALU RSH 1 TESTED FIRST SINCE IT NEEDS ONLY THE BOTTOM MPX AND REQUIRES
*THE LEAST TO WORK.
PALUR1:	P←NULL;
	P←(A0) ARSHC 1, CALL[PZT];	*P←ALU RSH 1 FAILED ON 0 THRU ALU, P0=0
	P←(Q←A1) ARSHC 1;
	Q RSH 1, CALL[PQCOMP];	*P←-1 RSH 1 FAILED ON -1 THRU ALU, P0=0
	P←B, B←Q←A1;
	P←(A0) ARSHC 1, Q RSH 1;
	Q←NOT Q, CALL[PQCOMP];	*P←ALU RSH 1 FAILED ON 0 THRU ALU, P0=1

*P←ALU IS TESTED NEXT SINCE IT REQUIRES ONLY THE BOTTOM TWO P MPX'S TO WORK
PALUT:	L7←R7←P←Q←A0, CALL[PQCOMP];	*P←ALU FAILED
	P←Q←P+1, CALL[PQCOMP];	*P←ALU FAILED ON ALU=1
	P←Q←2P, CALL[PQCOMP];	*P←ALU FAILED ON [Q]
	P;
	GOTO[.-2,ALU>0];
	L10←R10←P←Q←A1, CALL[PQCOMP];	*P←A1 FAILED

*IN TESTING OUT THE CYCLER IT IS SUPPOSED TO BE SUFFICIENT TO TEST OUT
*ONE CYCLE COUNT THOROUGHLY BUT OTHER CYCLE COUNTS ONLY ON TWO CASES
*(E.G., CASE 1 = 72 0'S; CASE 2 = 72 1'S).
PCY1T:	P←Q←A0;
	PQ RCY [0], CALL[PQCOMP];	*PQ RCY [0] FAILED ON 0,0
	PQ LCY [1], CALL[PQCOMP];	*PQ LCY [1] FAILED ON 0,0
	PQ RCY [1], CALL[PQCOMP];	*PQ RCY [1] FAILED ON 0,0
	P←Q←A1;
	PQ RCY [0], CALL[PQCOMP];	*PQ RCY [0] FAILED ON -1,-1
	PQ LCY [1], CALL[PQCOMP];	*PQ LCY [1] FAILED ON -1,-1
	PQ RCY [1], CALL[PQCOMP];	*PQ RCY [1] FAILED ON -1,-1
	P←A0;
	PQ RCY [0], CALL[PZT];	*PQ RCY [0] FAILED ON P=0, Q=-1
	P←A1, Q←NULL;
	PQ RCY [0], CALL[NPZT]; *PQ RCY [0] FAILED ON P=-1, Q=0
	P←A1, Q←NULL;
	PQ RCY [1], Q←NOT Q;
	Q RSH 1, CALL[PQCOMP];	*PQ RCY [1] FAILED ON P=-1, Q=0
	P←A1, Q←NULL;
	PQ LCY [1], Q←A1;
	Q LSH 1, CALL[PQCOMP];	*PQ LCY [1] FAILED ON P=-1, Q=0
	P←NULL, Q←A1;
	PQ RCY [1], Q RSH 1;
	Q←NOT Q, CALL[PQCOMP];	*PQ RCY [1] FAILED ON P=0, Q=-1
	P←NULL, Q←A1;
	PQ LCY [1], Q←P+1, CALL[PQCOMP]; *PQ LCY [1] FAILED ON P=0, Q=-1

*TEST PQ RCY [1] ON EACH OF THE 72 PQ VALUES WITH A SINGLE 1 AND 71 0'S.
*R11 HOLDS THE VALUE WHICH SHOULD WIND UP IN P AFTER THE CYCLE.
TPR1:	P←NULL, R11←Q;
	PQ RCY [1], Q←R11;
	Q RCY 1, CALL[PQCOMP];	*PQ RCY [1] FAILED ON A SINGLE 1 BIT
	R11←Q, Q←NULL, GOTO[.-2,Q EVEN];
*NOW THE RESULT SHOULD BE 0 44 TIMES.	R11 HOLDS THE Q ARGUMENT.
*P HAS 1 AT START.
	R11←P, Q←NULL;
	PQ RCY [1], CALL[PZT];	*PQ RCY [1] FAILED ON A SINGLE 1 BIT
	Q←(R11) RCY 1;
	GOTO[.-2,Q EVEN], R11←Q;
*NOW TEST ON EVERY INPUT PQ VALUE WITH A SINGLE 0 AND 71 1'S
	P←B, B←L11←Q←A1;
	Q LSH 1;
	R11←Q;
	PQ RCY [1], Q←R11;
	Q RCY 1, CALL[PQCOMP];	*PQ RCY [1] FAILED ON A SINGLE 0 BIT
	R11←Q, Q←L11, GOTO[.-2,Q ODD];
*FALL THRU WITH P=NOT 1
	PQ RCY [1], CALL[NPZT]; *PQ RCY [1] FAILED
	Q←(R11) RCY 1;
	GOTO[.-2,Q ODD], R11←Q;

*TEST PQ LCY [1] ON EACH PQ ARGUMENT WITH 71 1'S AND A SINGLE 0
TPL1:	Q←A1;
	Q RSH 1;
	P←B, B←Q, Q←A1;	 *P←377777 777777
	PQ LCY [1], R11←P;	*R11←377777 777777
	PQ LCY [1];
	DGOTO[.-1,ALU<0], NOT P, Q←R11;
	CALL[CBRK,ALU#0], Q LCY 1; *PQ LCY [1] FAILED ON SINGLE 0

*START HERE WITH [P] = -1, Q=777777 777776
	R11←Q;
	P←B, B←A1, Q←(R11) RSH 1;
TPL1A:	PQ LCY [1], Q←R11, CALL[PQCOMP]; *PQ LCY [1] FAILED ON -1, Q RCY 1
				*OR ON -2, -1
	Q LCY 1;
	R11←Q;
	Q←A1, GOTO[TPL1A,ALU<0];

*NOW TEST PQ LCY [1] ON A SINGLE 1 WITH 71 0'S
TPL1B:	P←NULL;
	R11←Q←P+1;
	Q RCY 1;
	PQ LCY [1], Q←R11, CALL[PQCOMP];
				*PQ LCY [1] FAILED ON Q RCY 1, 0 OR ON
				*0, 400000 000000
	Q LCY 1;
	R11←Q, Q←NULL;
	DGOTO[.-2,ALU>0], PQ LCY [1], Q←R11;
	CALL[PQCOMP];

	Q LCY 1;
TPL1C:	PQ LCY [1], Q←R11;
	P, Q LCY 1;
	R11←Q, CALL[CBRK,ALU#0];	*PQ LCY [1] FAILED ON 0Q RCY 2
	GOTO[TPL1C,ALU>0];
	GOTO[PCYCT];

*SUBROUTINES FOR PLRT WHICH RCY PQ OR LCY PQ A SPECIFIED NO. OF TIMES
*AND THEN COMPARE TO THE VALUE IN L11
M[W,(PQR#1:	PQ RCY [1], Q RSH 1)]; *REDEFINING W OK HERE
W[44]; W[43]; W[42]; W[41]; W[40]; W[37]; W[36]; W[35]; W[34]; W[33];
W[32]; W[31]; W[30]; W[27]; W[26]; W[25]; W[24]; W[23]; W[22]; W[21];
W[20]; W[17]; W[16]; W[15]; W[14]; W[13]; W[12]; W[11]; W[10]; W[7];
W[6]; W[5]; W[4]; W[3]; W[2]; W[1];
	Q←L11, GOTO[PQCOMP];

PQL3:	PQ LCY [1], Q LSH 1;
PQL2:	PQ LCY [1], Q LSH 1;
PQL1:	PQ LCY [1], Q LSH 1;
	Q←L11, GOTO[PQCOMP];

%HAVING NOW VERIFIED THAT PQ RCY [0], PQ RCY [1], AND PQ LCY [1] WORK,
USE THESE TO VERIFY THAT ALL OTHER P CYCLER FUNCTIONS WORK.	"PLRT"
IS CALLED WITH CYCLER ARGUMENTS IN P AND Q.	EACH LB AND RB CYCLE IS
TESTED ON THE VALUE IN P, PQ RCY AND PQ LCY ARE TESTED ON ALL LEGAL
CYCLER COUNTS, AND 0Q RCY, QQ RCY, AND NOTLUQ RCY ARE TESTED ON A
CYCLE COUNT OF 0.  THE PQ RCY [Y] AND PQ RCY [44-Y] OPERATIONS ARE
TESTED ON VALUES OF Y FROM 0 TO 43, AND 77, 76, AND 75 FOR BOTH
AN ACCURATE RESULT AND CORRECT SETTING OF H AND ON VALUES OF Y FROM
44 TO 74 FOR CORRECT SETING OF H.
%
PLRT:	L7←R7←P;		*L7←R7←ARG1
	L10←R10←Q;		*L10←R10←ARG2
PLBRBT:	P←Q←L7, CALL[PQCOMP];	*P←LB FAILED
	P←Q←R7, CALL[PQCOMP];	*P←RB FAILED
	P←(L7) LSH [3], Q←LB, CALL[QL3];
	CALL[PQCOMP];		*LB LSH [3] FAILED
	P←(L7) LSH [2], Q←LB, CALL[QL2];
	CALL[PQCOMP];		*LB LSH [2] FAILED
	P←(L7) LSH [1], Q←LB, CALL[QL1];
	CALL[PQCOMP];		*LB LSH [1] FAILED
	P←(R7) LSH [1], Q←RB, CALL[QL1];
	CALL[PQCOMP];		*RB LSH [1] FAILED
	P←(R7) LSH [2], Q←RB, CALL[QL2];
	CALL[PQCOMP];		*RB LSH [2] FAILED
	P←(R7) LSH [3], Q←RB, CALL[QL3];
	CALL[PQCOMP];		*RB LSH [3] FAILED
	P←(L7) RSH [1], Q←LB, CALL[Q43];
	CALL[PQCOMP];		*LB RSH [1] FAILED
	P←(L7) RSH [2], Q←LB, CALL[Q42];
	CALL[PQCOMP];		*LB RSH [2] FAILED
	P←(L7) RSH [3], Q←LB, CALL[Q41];
	CALL[PQCOMP];		*LB RSH [3] FAILED
	P←(R7) RSH [1], Q←RB, CALL[Q43];
	CALL[PQCOMP];		*RB RSH [1] FAILED
	P←(R7) RSH [2], Q←RB, CALL[Q42];
	CALL[PQCOMP];		*RB RSH [2] FAILED
	P←(R7) RSH [3], Q←RB, CALL[Q41];
	CALL[PQCOMP];		*RB RSH [3] FAILED
	P←L7, Q←R10;
	PQ LCY [3];
	L11←P, P←R7, CALL[PQL3];	*PQ LCY [3] FAILED ON P=L7, Q=L10.
				*RESULT LEFT IN Q
	P←L7, Q←R10;
	PQ LCY [2];
	L11←P, P←R7, CALL[PQL2]; *PQ LCY [2] FAILED

SET[TT,2];
PQRT:	REPEAT[42, ILC[(P←L7, Q←R10)]
		ILC[PQ RCY [TT]]
		ILC[(L11←P, P←R7, CALL[ADD[IP[PQR1],NOT[TT],2]])]
		SET[TT,ADD[TT,1]]];
	P←L7, Q←R10;
	PQ RCY [45], Q←L7;
	L11←P, P←R10, CALL[PQR1];	*PQ RCY [45] FAILED
	P←L7, Q←R10;
	PQ RCY [46], Q←L7;
	L11←P, P←R10, CALL[PQR2];	*PQ RCY [46] FAILED

*HAVING TESTED FOR ALL CASES OF PQ RCY [N] AND PQ LCY [N] IT IS BELIEVED
*TO BE SUFFICIENT TO TEST FOR A SINGLE CYCLE VALUE USING RCYQQ, RCY0Q,
*AND RCYNOTLUQ
PQFT:	P←L7, Q←R10;
	QQ RCY [0], CALL[PQCOMP];	*QQ RCY FAILED ON F2=RCYQQ
	P←L7, Q←R10;
	QQ RCY [0], CALL[PQCOMP], INHINT;	*QQ RCY FAILED ON F1=RCYQQ
	P←L7, Q←R10;
	0Q RCY [0], CALL[PZT];	*0QRCY FAILED ON F2=RCY0Q
	P←L7, Q←R10;
	0Q RCY [0], CALL[PZT], INHINT;	*0Q RCY FAILED ON F1=RCY0Q
	P←L7, Q←R10;
	NOT(P)Q RCY [0], Q←L7;
	Q←NOT Q, CALL[PQCOMP];	*NOTALUQ RCY FAILED ON [L7] THRU ALU
	P←L7, Q←R10;
	NOT(NOT P)Q RCY [0], Q←L7, CALL[PQCOMP];
				*NOTALUQ RCY [0] FAILED ON NOT[L7] THRU ALU

PQYT:	P←777S, A0;
PQYL0:	Y←P, Q←R10, CLEARF[H], GOTO[PQYT0,ALU<0];
	L14←P-1, P←R7;
	PQ RCY [Y];	*REPEAT FOR Y=777 TO 100
	P←L14, Q←R13, CALL[CBRK,H=0]; *Q←77
	P-Q-1, GOTO[PQYL0];

PQYT0:
*! MAXC1 ONLY
	Y←P, CLEARF[H], Q←L10;
	L14←P-1, P←R7;		*KEEP COUNT FOR Y IN L14.	L14←76
	PQ RCY [Y], CALL[H=1T];
	L11←P, P←R7, CALL[PQL1];	*PQ RCY [Y] FOR [Y]=77 = PQ LCY [1] FAILED
	P←L14;
	Y←P, CLEARF[H], Q←L10;
	L14←P-1, P←R7;		*L14←75
	PQ RCY [Y], CALL[H=1T];
	L11←P, P←R7, CALL[PQL2];	*PQ RCY [Y] FOR [Y]=76 = PQ LCY [2] FAILED
	P←L14;
	Y←P, CLEARF[H], Q←L10;
	L14←P-1, P←R7;		*L14←74
	PQ RCY [Y], CALL[H=1T];
	L11←P, P←R7, CALL[PQL3];	*PQ RCY [Y] FOR [Y]=75 = PQ LCY [3] FAILED
*!
	A0, P←L14;
PQYL:	Y←P, Q←R10, CLEARF[H], GOTO[PQYT1,ALU<0];
	L14←P-1, P←R7;
	PQ RCY [Y];
	P←L14, Q←R12, CALL[CBRK,H=0]; *Q←44
	P-Q-1, P←L14, GOTO[PQYL];

PQYT1:	R14←P←A0;		*NOW KEEP THE COUNT IN R14 INSTEAD OF L14
	Y←P, P←L7, Q←R10, SETF[H];
	L15←P;			*<L15,R15> ← PQ RCY [N] DURING STUFF BELOW
	PQ RCY [Y], R15←Q, Q←L7, CALL[PQCOMP]; *PQ RCY [Y] FAILED ON [Y]=0
	CALL[CBRK,H=1];	 *H LEFT =1 WHEN [Y]<44 ON PQ RCY [Y]

PQYL1:	Q←L15, P←R15;
	PQ RCY [1], Q←R15;
	R15←P, P←L15;
	PQ RCY [1];
	L15←P, P←R14;
	R14←P←P+1, Q←L12;	*Q←44
	Y←P;
	P-Q, P←L7, Q←R10, SETF[H];
	GOTO[PQ44-YT,ALU>=0], PQ RCY [Y];
	CALL[CBRK,H=1];	 *H NOT LEFT 0 BY PQ RCY [0]
	Q←L15, CALL[PQCOMP];	*PQ RCY [Y] FAILED ON VALUE IN Y
	GOTO[PQYL1];

PQ44-YT: P←777S, A0;
PQ44-YL0: Y←P, Q←R10, CLEARF[H], GOTO[PQ44-YL,ALU<0];
	L14←P-1, P←R7;
	PQ RCY [44-Y];
	P←L14, Q←R13, CALL[CBRK,H=0];
	P-Q-1, GOTO[PQ44-YL0];

PQ44-YL: Y←P, Q←R10, CLEARF[H], GOTO[PQ44-YT1,ALU<0];
	L14←P-1, P←R7;
	PQ RCY [44-Y], CALL[H=1T];
	P←L14, Q←R12;		*Q←44
	P-Q-1, P←L14, GOTO[PQ44-YL];

PQ44-YT1: P←R12;		*P←44
	R14←P;			*R14←VALUE FOR Y
	Y←P, P←L7, Q←R10, CLEARF[H];
	L15←P;
	PQ RCY [44-Y], R15←Q, Q←L7, CALL[PQCOMP]; *PQ RCY [44-Y] FAILED
				*ON [Y]=44
	CALL[CBRK,H=1];

PQ44-YL1: Q←L15, P←R15;
	PQ RCY [1], Q←R15;
	R15←P, P←L15;
	PQ RCY [1];
	L15←P, P←R14;
	R14←P←P-1, Q←L12;
	Y←P, RETURN[ALU<0];
	P←L7, Q←R10, SETF[H];
	PQ RCY [44-Y], Q←L15, CALL[PQCOMP]; *PQ RCY [44-Y] FAILED ON [Y]
	CALL[CBRK,H=1];	 *H NOT LEFT 0 BY PQ RCY [44-Y]
	GOTO[PQ44-YL1];

H=1T:	RETURN[H=1];
	BREAK;			*H WASN'T = 1 AFTER PQ RCY [Y] OR PQ RCY [44-Y]
				*WITH [Y] >= 44

PCYCT:	P←NULL, L37←A0;
	R37←Q←P+1, CALL[PLRT];	*TEST ON SINGLE 1
PCYCTL:	Q←L37;
	P←B, B←NOT Q, Q←R37;
	Q←NOT Q, CALL[PLRT];	*TEST ON SINGLE 0
	Q←R37;
	P←B, B←Q, Q←L37;
	PQ RCY [1], Q←P;
	R37←P, P←B, B←Q, Q←L37;
	P←B, B←Q, Q←P;
	PQ RCY [1], Q←R37;
	L37←P;
	DGOTO[PCYCTL,ALU>=0];
	CALL[PLRT];

TASHOVFP: P←NULL, Q←A1, CLEARF[-1S];
	PQ RCY [1], CALL[PZT], ASHOVF;	*ASHOVF FAILED TO FREEZE P0 AT 0
*! MAXC1 ONLY
	P←NOT F, Q←A1, CALL[PQCOMP]; *OVF SHOULD NOT BE SET
*!
*~ MAXC2 ONLY
	P←FLAGS, Q←A0, CALL[PQCOMP]; *OVF SHOULD NOT BE SET
*~
	P←A1, Q←NULL, CLEARF[-1S];
	PQ RCY [1], CALL[NPZT], ASHOVF; *ASHOVF FAILED TO FREEZE P0 AT 1
*! MAXC1 ONLY
	P←NOT F, Q←A1, CALL[PQCOMP]; *OVF SHOULD NOT BE SET
*!
*~ MAXC2 ONLY
	P←FLAGS, Q←A1, CALL[PEQZ]; *OVF SHOULD NOT BE SET
*~
	Q RSH 1, CLEARF[-1S];
	P←Q;
	PQ RCY [0], ASHOVF, CALL[PQCOMP];
*! MAXC1 ONLY
	P←NOT F, CLEARF[-1S], CALL[PQCOMP]; *OVF SHOULD BE SET NOW
*!
*~ MAXC2 ONLY
	P←FLAGS, CLEARF[-1S], CALL[PEQZ]; *OVF SHOULD NOT BE SET NOW
*~

*TEST THE MASK FUNCTIONS ON THE P-REGISTER.	FOR MASK COUNT>=44,
*THE EFFECT SHOULD BE THE SAME AS A MASK COUNT OF 44.
***ASSUME THAT TESTING THE MASK FUNCTIONS ON P←ALU IS A SUFFICIENT TEST.
TXMASK:	X←77S;
	Q←P←A1, XMASK, CALL[PQCOMP]; *XMASK FAILED ON VALUE IN X >=44
	DECX, P←L12, Q←X; *P←44
	P-Q;
	GOTO[.-3,ALU<0], Q←A1;
	Q RSH 1, P←A1, XMASK, CALL[PQCOMP]; *XMASK FAILED ON VALUE IN X<44
	DECX;
	GOTO[.-2,X>=0];

TAMASK:	SET[TT,37];
	P←Q←A1, CALL[Q40];
	REPEAT[40,ILC[(PQ RCY [0], AMASK[TT], CALL[PQCOMP], Q RSH 1)]
		SET[TT, ADD[TT,-1]]];	*AMASK FAILED ON VALUE IN ALUF FIELD

TSAMASK:	SET[TT,77];
	REPEAT[34,ILC[(P←Q←A1, SAMASK[TT], CALL[PQCOMP])]
		SET[TT,ADD[TT,-1]]];
	REPEAT[44,ILC[(P←A1, SAMASK[TT], Q RSH 1, CALL[PQCOMP])]
		SET[TT,ADD[TT,-1]]];

TBAMASK:	SET[TT,77];
	REPEAT[34,ILC[(P←Q←A1, BAMASK[TT])]
		ILC[CALL[PQCOMP]]
		SET[TT,ADD[TT,-1]]];
	REPEAT[44,ILC[(P←A1, BAMASK[TT], Q RSH 1)]
		ILC[CALL[PQCOMP]]
		SET[TT,ADD[TT,-1]]];

*LDPALUH = DON'T LOAD P IF ALU0=H
TLDPALUH: P←NULL, CLEARF[H];
	P←A1, LDPALUH, CALL[NPZT];	*LDPALUH FAILED ON H=0, ALU0=1
	P←A0, LDPALUH, CALL[NPZT];	*LDPALUH FAILED ON H=0, ALU0=0
	Q←A1;
	Q RSH 1;
	P←NULL, R11←AQ, LDPALUH, CALL[NPZT]; *LDPALUH FAILED ON H=0, ALU0=0
	Q←R11;
	P←NULL, NOT Q, LDPALUH, CALL[PZT]; *LDPALUH FAILED ON H=0, ALU0=1
	SETF[H];
	P←A1, LDPALUH, CALL[PZT], Q←R11; *LDPALUH FAILED ON H=1, ALU0=1
	P←NOT Q, LDPALUH, CALL[PZT];	*LDPALUH FAILED ON H=1, ALU0=1
	P←AQ, LDPALUH, CALL[PQCOMP];	*LDPALUH FAILED ON H=1 ALU0=0
	P←NULL, LDPALUH, CALL[PZT];	*LDPALUH FAILED ON H=1, ALU0=0

*TEST NEGY FUNCTION
NEGYT:	P←Y←NULL;
	NEGY;
	Q←Y, CALL[PQCOMP];	*NEGY FAILED ON 0
	Y←Q←L13←P+1;
NEGYL:	NEGY, P←NULL;
	P←P-Q, SAMASK[11], Q←Y, CALL[PQCOMP]; *NEGY FAILED ON (-P AND 777)
	P←L13,BAMASK[11];
	P;
	GOTO[NEGYL,ALU#0], Y←Q←L13←P+1;

*YKPTR← IS SUPPOSED TO LOAD Y FROM 400 + B[41,43]*20
TYKPTR:	P←NULL;
	B←Q←P+1, P←B;
	B←2P+1, P←B, Q LCY 1, DGOTO[YKP1];
	B←2P+1, P←B, Q LCY 1, CALL[QLCY2];
*P←7, Q←20 NOW AT ENTRY TO YKP1
YKPLP:	CALL[PQCOMP], R7←P-1, P←Y, Q LCY 1; *Q HAS CORRECT VALUE
	P←R7, Q←STEMP;
YKP1:	YKPTR←P;
	DGOTO[YKPLP,ALU>=0], Q←P+Q, STEMP←Q; *Q←(20+P)*20 = 400 + 20*P
	Q LCY 1, CALL[QLCY2];
*~ MAXC2 ONLY
	GOTO[BPCT1];

*SUBROUTINE TO TEST BPC FOR TESTS BELOW
BPCCOM:	L7←P, Q←BPC, CALL[PQCOMP];	*P/ SHOULD BE, Q/ BPC WAS
	XSPLIT←Q←BPC, PQ RCY [22], SAMASK[2];
	P←P-1;
	P←P-1, GOTO[BPCC0,ALU<0];
	P←P-1, GOTO[BPCC1,ALU<0];
	P←L7, GOTO[BPCC2,ALU<0];
*BPC[20,21] WAS = 3
	P←(P) U (60 000000S), CALL[PQCOMP];	*BUS WRONG ON XSPLIT←Q←BPC
				*SHOULD HAVE BEEN P, WAS Q
	P←P+1, SAMASK[22], Q←BPC, CALL[PQCOMP];	*XSPLIT←BPC COUNT FAILED
				*SHOULD HAVE BEEN P, WAS Q
BPCCX1:	CALL[CBRK,NEWWORD];
BPCCX:	P←R7;
	R7←P-1, P←L7, RETURN;

*BPC[20,21] WAS = 0
BPCC0:	P←L7;
	P←(P) U (22060 000000S), CALL[PQCOMP];	*BUS WRONG ON XSPLIT←Q←BPC
				*SHOULD HAVE BEEN P, WAS Q
	Q←1 000000S;
	P←P+Q, SAMASK[24], Q←BPC, CALL[PQCOMP];	*XSPLIT←BPC COUNT FAILED
				*SHOULD HAVE BEEN P, WAS Q
	GOTO[BPCCX1];

*BPC[20,21] WAS = 1
BPCC1:	P←L7;
	P←(P) U (11060 000000S), CALL[PQCOMP];	*BUS WRONG ON XSPLIT←Q←BPC
				*SHOULD HAVE BEEN P, WAS Q
	Q←1 000000S;
	P←P+Q, SAMASK[24], Q←BPC, CALL[PQCOMP];	*XSPLIT←BPC COUNT FAILED
				*SHOULD HAVE BEEN P, WAS Q
	GOTO[BPCCX1];

*BPC[20,21] WAS = 2
BPCC2:	P←L7;
	P←(P) U (60 000000S), CALL[PQCOMP];	*BUS WRONG ON XSPLIT←Q←BPC
				*SHOULD HAVE BEEN P, WAS Q
	Q←1 000000S;
	P←P+Q, SAMASK[24], Q←BPC, CALL[PQCOMP];	*XSPLIT←BPC COUNT FAILED
				*SHOULD HAVE BEEN P, WAS Q
	CALL[CBRK,OLDWORD];
	GOTO[BPCCX];

*TESTS OF BPC
BPCT1:	P←A1, SAMASK[5];
	R7←P-1;
	P←BPC←A1, SAMASK[24], CALL[BPCCOM];
	P←BPC←2P, SAMASK[24], CALL[BPCCOM];
	P←BPC←2P+1, SAMASK[24], CALL[BPCCOM];
	GOTO[.-1,ALU>=0];

BPCT2:	P←A1, SAMASK[5];
	R7←P-1;
	P←BPC←A0, CALL[BPCCOM];
	P←BPC←P+1, CALL[BPCCOM];
	P←BPC←2P, SAMASK[24], CALL[BPCCOM];
	GOTO[.-1,ALU>=0];
*~

	GOTO[MCYCLE];		*BREAK IF THIS IS THE LAST DIAGNOSTIC
IM[ILC,ADD[IP[ILC],-1]];	*BACK UP 1 IF MORE DIAGNOSTICS ASSEMBLED