Google
 

Trailing-Edge - PDP-10 Archives - klad_sources - klad.sources/dakalm.mac
There are no other files named dakalm.mac in the archive.
SUBTTL	DIAGNOSTIC SECTION

EXIT:	DROPDV		;CLOSE LOGICAL OUTPUT FILE
	EXIT

PGMNAM:	ASCIZ/
PDP-10  KI10 BASIC INSTRUCTION DIAGNOSTIC (12) [DAKAL]
/

START:	PGMINT
	MOVE	[ASCIZ/AL/]
	MOVEM	TLET		;INITIALIZE TEST LETTER

STARTA:	JRST	F00		;GO PERFORM DIAGNOSTIC
SUBTTL	MAIN TESTING

	ADR=3000
F00:	AC=14
	E=<AC-2>&17
	N1=525252525252
	N2=252525252525
	SAVEAC	(1,1)
	WW=^D36
	XX=0

	REPEAT	^D36,<
	ADR=ADR+1
	WW=WW-1
	XX=XX+XX
	IFE	XX,<XX=1>

;MULTIPLY A FLOATING 1 BY 1010...101010
	V1=N1
	V2=N1*XX
	IFL	XX,<V3=N2+1>
	IFG	XX,<V3=<<-1B<WW>>!<N1_<-WW>>>>
	MOP1	(\ADR,V1,0,XX,V3,V2)>
	AC=14
	E=<AC-2>&17
	SAVEAC	(1,1)

	WW=^D36

	XX=0

	REPEAT	^D35,<	;LAST CASE DIFFERENT
	ADR=ADR+1
	WW=WW-1
	XX=XX+XX
	IFE	XX,<XX=1>

;MULTIPLY 0101...0101 BY A FLOATING 1
	V1=N2
	V2=N2*XX
	IFG	XX,<V3=<N2_<-WW>>>
	IFL	XX,<V3=N1+1>
	MOP1	(\ADR,XX,0,V1,V3,V2)>
	ADR=ADR+1
;MULTIPLY A 1010...1010 BY A 400000,,0
	XX=400000000000
	V1=252525252525

	MOP1	(\ADR,XX,0,V1,V1,0)
	AC=13
	E=<AC-2>&17
	SAVEAC	(1,1)
	WW=^D36
	XX=0

	REPEAT	^D36,<
	ADR=ADR+1
	WW=WW-1
	XX=XX+XX
	IFE	XX,<XX=1>

;MULTIPLY A FLOATING 1 BY 0101...0101
	V1=N2
	V2=N2*XX
	IFG	XX,<V3=<N2_<-WW>>>
	IFL	XX,<V3=N1+1>
	MOP1	(\ADR,V1,0,XX,V3,V2)>
	AC=12
	E=<AC-2>&17
	SAVEAC	(1,1)
	XX=0

	REPEAT	^D36,<
	ADR=ADR+1
	XX=XX+XX
	IFE	XX,<XX=1>

;MULTIPLY A FLOATING 1 BY ITSELF FOR A SQUARE PRODUCT
	V1=XX*XX
	IFG	XX,<V2=<<<XX_-22>*<XX_-22>>_1>>
	IFL	XX,<V2=XX*XX>
	MOP1	(\ADR,XX,-1,XX,V2,V1)>
	AC=11
	E=<AC-2>&17
	SAVEAC	(1,1)
	XX=0

	REPEAT	^D36,<
	ADR=ADR+1
	XX=XX+XX+1
	IFE	<XX-1>,<XX=-2>

;MULTIPLY A FLOATING 0 BY ITSELF FOR A SQUARE PRODUCT
	V1=XX*XX
	IFE	<XX&1B1>,<V2A=1>
	IFN	<XX&1B1>,<V2A=0>
	IFL	XX,<V2=<<<<<-<XX+1>>_-22>*<<-<XX+1>>_-22>>_1>+V2A>>
	IFG	XX,<V2=XX-1>
	MOP1	(\ADR,XX,-1,XX,V2,V1)>
	AC=10
	E=<AC-2>&17
	SAVEAC	(1,1)
	XX=0
	YY=0

	REPEAT	^D36,<
	ADR=ADR+1
	XX=XX+XX
	YY=YY+YY+1
	IFE	XX,<XX=1>
	IFE	<YY-1>,<YY=-2>

;MULTIPLY A FLOATING 1 BY A FLOATING 0
	V1=XX*YY
	IFE	<XX_-22>,<V2A=-1>
	IFN	<XX_-22>,<V2A=<<<<YY_-22>+<YY_22>>*<XX_-21>>+<XX_-21>-1>>
	IFG	XX,<V2=V2A>
	IFL	XX,<V2=XX+1>
	MOP1	(\ADR,YY,0,XX,V2,V1)>
	AC=7
	E=<AC-2>&17
	SAVEAC	(1,1)
	XX=0
	YY=0

	REPEAT	^D35,<	;LAST CASE DIFFERENT
	ADR=ADR+1
	XX=XX+XX
	YY=YY+YY+1
	IFE	XX,<XX=1>
	IFE	<YY-1>,<YY=-2>

;MULTIPLY A FLOATING 0 BY A FLOATING 1
	V1=XX*YY
	IFE	<XX_-22>,<V2A=-1>
	IFN	<XX_-22>,<V2A=<<<<YY_-22>+<YY_22>>*<XX_-21>>+<XX_-21>-1>>
	IFG	XX,<V2=V2A>
	IFL	XX,<V2=XX+1>
	MOP1	(\ADR,XX,0,YY,V2,V1)>
	ADR=ADR+1
;MULTIPLY A 400000,,0 BY A 377777,,-1
	YY=377777777777
	XX=400000000000

	MOP1	(\ADR,XX,0,YY,YY,0)
;MULTIPLIER = 2,4
;MULTIPLICAND = 377777 777777

	AC=14
	SAVEAC	(1,1)

SN=300
	XX=-1
	YY=2
	ZZ=1

F300:	REPEAT	^D2,<
SN=SN+1
	XX=XX+2
	YY=YY-2
	IFE	YY,<YY=377777777776>
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	HRLOI	AC-1,377777	;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY ZZ X 377777777777
	CAME	AC,[XX]		;TEST HIGH PROD
	ER3	AC,SN
	CAME	AC+1,[YY]	;TEST LOW PROD
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST MQ FINAL SHIFT
;MULTIPLIER = 200000 000000
;MULTIPLICAND = 5,7

	AC=7
	SAVEAC	(1,1)

SN=500
	XX=1
	ZZ=3

		;TEST MQSHRT FAILING
F500:	REPEAT	^D2,<
SN=SN+1
	XX=XX+1
	ZZ=ZZ+2
	MOVSI	AC-2,200000	;SETUP FOR COMPARISON
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MUL 200000 000000 X ZZ
	CAME	AC+1,AC-2	;TEST LOW PROD
	ER4	AC+1,SN
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	CAME	AC,AC-2		;TEST HIGH PROD
	ER3	AC,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 10,20
;MULTIPLICAND = 377777 777777

	AC=11
	SAVEAC	(1,1)

SN=700
	XX=-1
	ZZ=4

		;TEST ARSHRT FAILING
F700:	REPEAT	^D2,<
SN=SN+1
	XX=XX+10
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	HRLOI	AC-1,377777	;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MUL. ZZ X 377777 777777
	CAME	AC+1,[ZZ*377777777777]		;TEST LOW PROD
	ER4	AC+1,SN		;ARSHRT ASSERTED
	CAME	AC,[XX]		;TEST HIGH PROD = PLIER
	ER3	AC,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 0
;MULTIPLICAND = -15,-13

	AC=10
	SAVEAC	(1,1)

SN=1000
	ZZ=-17

		;TEST MQSHRT FAILING
F1000:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+2
	SETZ	AC,		;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY 0 X -ZZ
	SKIPE	AC+1		;TEST LOW PROD
	ER4	AC+1,SN
	SKIPE	AC		;TEST HIGH PROD
	ER3	AC,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
PAGE
;MULTIPLIER = -2,-4
;MULTIPLICAND = 0

	AC=7
	SAVEAC	(1,1)

SN=1100
	XX=0
	ZZ=-1

F1100:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	IFE	XX,<XX=-1>
	HRROI	AC,ZZ		;SETUP MULTIPLIER
	SETZ	AC-1,		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY ZZ X 0
	SKIPE	AC+1		;TEST LOW PROD
	ER4	AC+1,SN
	SKIPE	AC		;TEST HIGH PROD
	ER3	AC,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 2,4
;MULTIPLICAND = 5

	AC=14
	SAVEAC	(1,1)

SN=1400
	XX=5
	ZZ=1

	F1400:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	HRRZI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	MOVEI	AC-1,5		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY ZZ X 5
	CAME	AC+1,AC-2	;TEST LOW PROD
	ER4	AC+1,SN
	SETO	AC-2,		;SET FOR COMPARISON
	SKIPE	AC				;TEST HIGH PROD
	ER3	AC,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 200000 000000,100000 000000
;MULTIPLICAND = 25

	AC=11
	SAVEAC	(1,1)

SN=2000
	XX=377777
	YY=24
	ZZ=0

F2000:	REPEAT	^D2,<
SN=SN+1
	XX=XX/2
	YY=YY/2
	ZZ=ZZ/2
	IFE	ZZ,<ZZ=200000>
	MOVSI	AC-2,ZZ		;SETUP FOR COMPARISON
	MOVSI	AC,ZZ		;SETUP MULTIPLIER
	MOVEI	AC-1,25		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY ZZ X 25
	CAME	AC+1,AC-2	;TEST LOW PROD
	ER4	AC+1,SN
	MOVEI	AC-2,YY		;SET FOR COMPARISON
	CAME	AC,AC-2		;TEST HIGH PROD
	ER3	AC,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;INPUT ONE'S-
;MULTIPLIER = 400000 000000
;MULTIPLICAND = -20,-40

	AC=6
	SAVEAC	(1,1)

SN=2200
	ZZ=-10
	XX=10

F2200:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	XX=XX+XX
	MOVSI	AC,400000	;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MUL.400000 000000 X ZZ
	CAME	AC,[ZZ]		;TEST HI PRODUCT
	ER3	AC,SN
	CAME	<AC+1>&17,[1B0]	;TEST LO PROD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D7	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 10,20
;MULTIPLICAND = 4

	AC=5
	SAVEAC	(1,1)

SN=2400
	XX=20
	ZZ=4
F2400:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	MOVEI	AC-1,4		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY ZZ X 4
	CAME	AC+1,AC-2	;TEST LOW PROD
	ER4	AC+1,SN
	SKIPE	AC		;TEST HIGH PRODUCT
	ER3	AC,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 1,2
;MULTIPLICAND = 200000 000000,100000 000000

	AC=14
	SAVEAC	(1,1)

SN=3300
	XX=0
	ZZ=0

F3300:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ/2
	IFE	XX,<XX=1>
	IFE	ZZ,<ZZ=200000>
	MOVSI	AC-2,200000	;SETUP FOR COMPARISON
	SETO	AC+1,		;INITIALIZE AC+1
	MOVEI	AC,XX		;SETUP MULTIPLIER
	MOVSI	AC-1,ZZ		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY TWO VARIABLES
	SKIPE	AC		;TEST HIGH PROD
	ER3	AC,SN
	CAME	AC+1,AC-2	;TEST LOW PRODUCT
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;MUL
;MULTIPLIER = 400000 000000
;MULTIPLICAND = -1,-2

	AC=12
	SAVEAC

SN=4000
	XX=0
	ZZ=0

F4000:	REPEAT	^D2,<
SN=SN+1
	XX=XX+1
	ZZ=ZZ-1
	MOVSI	AC,400000	;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	MUL	AC,AC-1		;MULTIPLY TWO NEGATIVES
	CAME	AC,[ZZ]		;TEST HI PROD
	ER3	AC,SN
	CAME	<AC+1>&17,[1B0]	;TEST LO PROD
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST MUL-IMMEDIATE MODE
;TEST THE ABILITY TO MULTIPLY WITH
;EFFECTIVE ADDRESS AS MULTIPLICAND
;MULTIPLIER = 1
;MULTIPLICAND = E

SN=4200
	AC=11

		;TEST IMMEDIATE MODE
F4200:	REPEAT	^D2,<
SN=SN+1
	AC=AC-1
	SAVEAC	(1,1)		;SAVE AC FOR ITERATION
	MOVEI	AC-2,AC-1	;SETUP FOR COMPARISON
	MOVEI	AC,1		;SETUP MULTIPLIER
	HRROI	AC-1,-1		;SETUP AC-1
	MULI	AC,AC-1		;MULTIPLY 1 X E
	CAME	AC+1,AC-2	;TEST LOW PROD
	ER4	AC+1,SN		;MULTIPLIED BY C(E) VICE E
	SKIPE	AC		;TEST HIGH PROD
	ER3	AC,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST MUL-MEMORY MODE
;TEST SC(E), PRODUCT HIGH ORDER PART
;TEST ABILITY TO ASSERT SAC INH
;TEST ABILITY TO INHIBIT SAC2-PRODUCT LOW
;ORDER PART IS LOST
;MULTIPLIER = 200000 000000
;MULTIPLICAND = 2,4

	AC=7
	SAVEAC

SN=4300
	ZZ=1

		;TEST SCE
F4300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVSI	AC-2,200000	;SETUP FOR COMPARISON
	SETZM	AC+1		;SETUP AC+1
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	MULM	AC,AC-1		;MUL 200000 000000 X ZZ
	CAME	AC,AC-2		;TEST AC
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	SKIPE	AC+1		;TEST AC+1
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	CAIE	AC-1,ZZ/2	;TEST PRODUCT
	ER5	AC-1,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
PAGE
SN=4400
	ZZ=1

		;TEST SAC INH
F4400:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	MULM	AC,AC-1		;MUL 200000 000000 X ZZ
	TLNN	AC,200000	;TEST FOR ORIGINAL CONTENTS
	ER3	AC,SN
	JUMPL	AC+2,.-5	;LOOP ON ERROR SWITCH
>
PAGE
SN=4500
	ZZ=1

		;TEST SAC2 ASSERTED
F4500:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	SETZ	AC+1,		;CLEAR AC+1
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	MULM	AC,AC-1		;MUL 200000 000000 X ZZ
	SKIPE	AC+1		;TEST FOR ORIGINAL CONTENTS
	ER4	AC+1,SN
	JUMPL	AC+2,.-6	;LOOP ON ERROR SWITCH
>
;TEST MUL-BOTH MODE
;TEST ABILITY TO STORE PRODUCT HIGH ORDER
;PART IN AC,E
;TEST ABILITY TO STORE PRODUCT LOW ORDER
;PART IN AC+1
;MULTIPLIER = 200000 000000
;MULTIPLICAND = 5,7

	AC=6
	SAVEAC	(1,1)

SN=4600
	XX=1
	ZZ=3

F4600:	REPEAT	^D2,<
SN=SN+1
	XX=XX+1
	ZZ=ZZ+2
	MOVSI	AC-2,200000	;SETUP FOR COMPARISON
	SETZM	AC+1		;SETUP FOR COMPARISON
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	MULB	AC,AC-1		;MUL 200000 000000 X ZZ
	CAME	AC,AC-1		;TEST C(AC) = C (E)
	ER3	AC,SN		;SCE FAILED
	CAME	AC+1,AC-2	;TEST LOW PROD
	ER4	AC+1,SN
	CAIE	AC-1,XX		;TEST LOW PROD
	ER5	AC-1,SN
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;TEST AROV SET-MUL
;MULTIPLIER = 400000 000000
;MULTIPLICAND = 400000 000000
;PRODUCT = 400000 000000 400000 000000
;AROV IS SET

F4710:	JRSTF	@[.+1]		;CLEAR ALL FLAGS
	MOVSI	AC,400000	;SETUP MULTIPLIER
	MOVSI	AC-2,400000	;SETUP MULTIPLICAND
	MUL	AC,AC-2
	JSP	AC-3,.+1	;SAVE FLAGS
	CAME	AC,[1B0]	;TEST HIGH PRODUCT
	ER3	AC,4711
	CAME	AC+1,[1B0]	;TEST LOW PRODUCT
	ER4	AC+1,4711
	JOV	.+2		;TEST AROV
	ER13	AC-3,4711	;FAIL IF AROV NOT SET
	JUMPL	AC+2,F4710	;LOOP ON ERROR SWITCH

;TEST AROV SET-MULB
;MULTIPLIER = 400000 000000
;MULTIPLICAND = 400000 000000
;PRODUCT = 400000 000000 400000 000000
;AROV IS SET

F4720:	JRSTF	@[.+1]		;CLEAR ALL FLAGS
	MOVSI	AC,400000	;SETUP MULTIPLIER
	MOVSI	AC-2,400000	;SETUP MULTIPLICAND
	MULB	AC,AC-2
	JSP	AC-3,.+1	;SAVE FLAGS
	CAME	AC,[1B0]	;TEST HIGH PRODUCT
	ER3	AC,4721
	CAME	AC+1,[1B0]	;TEST LOW PRODUCT
	ER4	AC+1,4721
	CAME	AC-2,[1B0]	;TEST HIGH PRODUCT
	ER5	AC-2,4721
	JOV	.+2		;TEST AROV
	ER13	AC-3,4721	;FAIL IF AROV NOT SET
	JUMPL	AC+2,F4720	;LOOP ON ERROR SWITCH
SUBTTL	DIAGNOSTIC SECTION - INTEGER MPY TEST

;MULTIPLIER =400000 000000
;MULTIPLICAND = 2,4

	AC=10
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=5000
	ZZ=1

	F5000:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVSI	AC,400000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	IMUL	AC,AC-1		;MUL 400000 000000 X ZZ
	SKIPE	AC		;TEST PROD = 0
	ER3	AC,SN
	JUMPL	AC+2,.-5	;LOOP ON ERROR SWITCH
>
;TEST AROV SET
;TEST ABILITY TO SET AROV FLAG
;NUMBERS OF LIKE SIGNS ARE MULTIPLIED
;AND TESTED FOR OVERFLOW/OVERFLOW NOT
;NUMBERS OF UNLIKE SIGNS ARE MULTIPLIED
;AND TESTED FOR OVERFLOW NOT

	AC=14
	SAVEAC	(1,1)

SN=5100
	XX=200000
	ZZ=1

		;TEST 2 POSITS-OVERFLOW NOT
F5100:	REPEAT	^D2,<
SN=SN+1
	XX=XX+200000
	ZZ=ZZ+1
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	MOVEI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	IMUL	AC,AC-1		;MUL 000000 200000 X ZZ
	JSP	AC+1,.+1
	CAIE	AC,XX
	ER3	AC,SN
	JOV	.+2		;TEST FOR SET COND
	JRST	.+2		;FLAG IS NOT SET
	ER13	AC+1,SN		;FLAG IS SET
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
PAGE
SN=5200
	XX=40000
	ZZ=1

		;TEST 2 POSITS-OVERFLOW
F5200:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+1
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP MULTIPLICAND
	MOVSI	AC-2,XX&200000
	IMUL	AC,AC-1		;MUL 200000 000000 X ZZ
	JSP	AC+1,.+1
	CAME	AC,AC-2
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2		;TEST FOR SET CONDITION
	ER13	AC+1,SN		;FLAG DID NOT SET
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
SN=5300
	XX=1
	ZZ=0

		;TEST 2 NEGATS-OVERFLOW NOT
F5300:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ-1
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	HRROI	AC,-2		;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	IMUL	AC,AC-1		;MULTIPLY -2 X ZZ
	JSP	AC+1,.+1
	CAIE	AC,XX
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2		;TEST FOR SET NOT CONDITION
	JRST	,.+2		;FLAG NOT SET
	ER13	AC+1,SN		;FLAG IS SET
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
PAGE
SN=5400
	ZZ=-1

		;TEST 2 NEGATS-OVERFLOW
F5400:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ-1
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	MOVSI	AC,400000	;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	IMUL	AC,AC-1		;MUL 400000 000000 X ZZ
	JSP	AC+1,.+1
	CAME	AC,[1B0]	;TEST PROD
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2		;TEST FOR SET CONDITION
	ER13	AC+1,SN		;FLAG DID NOT SET
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
SN=5500
	XX=1000000
	ZZ=-1

		;TEST UNLIKE,OVERFLOW NOT
F5500:	REPEAT	^D2,<
SN=SN+1
	XX=XX/2
	ZZ=ZZ-1
	JRSTF	@[.+1]		;CLR ALL FLAGS,EXEC NEXT INST
	MOVEI	AC,200000	;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	HRROI	AC-2,XX
	IMUL	AC,AC-1		;MUL 000000 200000 X ZZ
	JSP	AC+1,.+1
	CAME	AC,AC-2
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2		;TEST FOR SET NOT COND
	JRST	,.+2		;FLAG NOT SET
	ER13	AC+1,SN		;FLAG IS SET
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;PLIER = -1
;PLICAND = 1,2

	AC=11
	SAVEAC	(1,1)

SN=5600
	XX=1000000
	ZZ=0

F5600:	REPEAT	^D2,<
SN=SN+1
	XX=XX-1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=1>
	JRSTF	@[.+1]		;CLR ALL FLAGS,EXEC NEXT INST
	SETO	AC,		;SETUP MULTIPLIER
	HRROI	AC-1,ZZ		;SETUP MULTIPLICAND
	IMUL	AC,AC-1		;MULTIPLY -1 X ZZ
	JSP	AC+1,.+1
	CAIE	AC,XX
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2
	JRST	,.+2
	ER13	AC+1,SN
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
PAGE
;MULTIPLIER = -1
;PLICAND = 200000 000000,200000 000010

	AC=13
	SAVEAC	(1,1)

SN=5700
	XX=600010
	ZZ=177770

F5700:	REPEAT	^D2,<
SN=SN+1
	XX=XX-10
	ZZ=ZZ+10
	JRSTF	@[.+1]		;CLR ALL FLAGS,EXEC NEXT INST
	SETO	AC,		;SETUP MULTIPLIER
	MOVSI	AC-1,ZZ		;SETUP MULTIPLICAND
	MOVSI	AC-2,XX
	IMUL	AC,AC-1		;MULTIPLY -1 X ZZ
	JSP	AC+1,.+1
	CAME	AC,AC-2
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2
	ER13	AC+1,SN
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;MULTIPLIER = 0,1
;MULTIPLICAND = 400000 000000

	AC=12
	SAVEAC	(1,1)

SN=6000
	XX=100000
	ZZ=-1

F6000:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+1
	JRSTF	@[.+1]		;CLR ALL FLAGS,EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	MOVSI	AC-1,400000	;SETUP MULTIPLICAND
	MOVSI	AC-2,XX&400000
	IMUL	AC,AC-1		;MUL ZZ X 400000 000000
	JSP	AC+1,.+1
	CAME	AC,AC-2
	ER3	AC,SN		;C(AC) FAILED
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2		;BOTH CLEARS ASSERTED
	ER13	AC+1,SN		;EITHER CLEAR FAILED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
PAGE
F6010:	JRSTF	@[.+1]		;CLEAR ALL FLAGS
	MOVSI	AC,200000	;SETUP MULTIPLIER
	MOVEI	AC-1,2		;SETUP MULTIPLICAND
	IMULB	AC,AC-1	
	JSP	AC+1,.+1	;SAVE FLAGS
	CAIE	AC,0
	ER3	AC,6011		;C(AC) FAILED
	CAIE	AC-1,0
	ER5	AC-1,6011	;C(E) FAILED
	JOV	.+2
	ER13	AC+1,6011	;AROV DID NOT SET
	JUMPL	AC+2,F6010	;LOOP ON ERROR SWITCH
;TEST IMUL-IMMEDIATE MODE
;TEST ABILITY TO MULTIPLY WITH THE
;EFFECTIVE ADDRESS AS THE MULTIPLICAND
;THE PROD WILL EQUAL THE EFFECTIVE
;ADDRESS
;A FAILURE INDICATES MULTIPLYING
;BY C(E) VICE E

	AC=10
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=6100
	ZZ=1

		;TEST IMMEDIATE MODE
F6100:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC-2,AC-1	;SETUP FOR COMPARISON
	MOVEI	AC,1		;SETUP MULTIPLIER
	MOVEI	AC-1,ZZ		;SETUP AC-1
	IMULI	AC,AC-1		;EFFECTIVE ADDRESS=7
	CAME	AC,AC-2		;TEST PROD = ZZ
	ER3	AC,SN		;MULTIPLIED BY C(E) VICE E
	JUMPL	AC+2,.-6	;LOOP ON ERROR SWITCH
>
;TEST IMUL-MEMORY MODE

	AC=7
	SAVEAC	(1,1)

SN=6300
	ZZ=1

F6300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC-2,ZZ		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	MOVEI	AC-1,7		;SETUP MULTIPLICAND
	IMULM	AC,AC-1		;MULTIPLY ZZ X 7
	CAME	AC,AC-2		;TEST FOR PRODUCT IN AC
	ER3	AC,SN
	CAIE	AC-1,ZZ*7	;TEST FOR PROD IN E
	ER5	AC-1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST IMUL-BOTH MODE
;TEST ABILITY TO STORE PRODUCT IN AC,E
;AC, AC-1 ARE COMPARED FOLLOWING
;MULTIPLY
;AN ERROR WILL OCCUR IF AC DIFFERS FROM
;AC-1
	AC=6
	SAVEAC	(1,1)
SN=6500
	ZZ=4
		;TEST STORING AC,E
F6500:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP MULTIPLIER
	MOVEI	AC-1,2		;SETUP MULTIPLICAND
	IMULB	AC,AC-1		;MULTIPLY ZZ X 2
	CAME	AC,AC-1		;COMPARE AC,AC-1
	ER3	AC,SN
	JUMPL	AC+2,.-5	;LOOP ON ERROR SWITCH
>

SUBTTL	DIAGNOSTIC SECTION - INTEGER DIVIDE TEST

;TEST FETCH,STORE AND DECODE
;TEST ABILITY TO FETCH CONTENTS OF E
;TEST ABILITY TO STORE AC,AC+1
;DVND = 000000 777777,000000 777776
;DVSR = 000000 777777,000000 777776
;DVND = 000000 3400000
;DVSR = 2

	AC=7
	SAVEAC	(1,1)

SN=6600
	ZZ=0

		;TEST SAC,SAC2 FAILING
F6600:	REPEAT	^D2,<
SN=SN+1
	ZZ=<ZZ+ZZ>&777777
	IFE	ZZ,<ZZ=777777>
	JRSTF	@[.+1]		;CLR ALL FLGS,EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC+1,ZZ		;SETUP DVSR
	IDIV	AC,AC+1		;DIVIDE ZZ BY ZZ
	JSP	AC-3,.+1
	JOV	.+2		;TEST FOR OVFL
	JRST	.+2
	ER13	AC-3,SN
	CAIE	AC,1		;TEST AC FOR QUOTIENT = 1
	ER3	AC,SN
	CAIE	AC+1,0		;TEST AC+1 FOR REMAINDER = 0
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D13	;LOOP ON ERROR SWITCH
	JRSTF	@[.+1]		;CLEAR ALL FLAGS
>
PAGE
				;TEST FCE FAILING
F6700:	MOVEI	AC-2,160000	;SETUP FOR COMPARISON
	MOVEI	AC,340000	;SETUP DVND
	MOVEI	AC+1,2		;SETUP DVSR
	IDIV	AC,AC+1		;DIV 000000 340000 BY 2
	CAME	AC,AC-2		;TEST QUOT = 000000 020000
	ER3	AC,6701
	JUMPL	AC+2,F6700	;LOOP ON ERROR SWITCH
;DVND = 4,10
;DVSR = 2
;FAILURE RESULTS IN A QUOT = 0,
;A REMD = DVND (SIGN IS NEGATIVE)

	AC=7
	SAVEAC	(1,1)

SN=7000
	ZZ=2
F7000:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 2
	SKIPE	AC+1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST AROV SET
;DVND = 4,10
;DVSR = 0 (DIVIDE CHECK CONDITION)

	AC=14
	SAVEAC	(1,1)

SN=7100
	ZZ=2

		;TEST OVERFLOW COND
F7100:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	JRSTF	@[.+1]		;CLR ALL FLGS,EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC+1,ZZ
	SETZ	AC-1,		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY 0
	JSP	AC-3,.+1
	CAIE	AC,ZZ
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	CAIE	AC+1,ZZ
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	JOV	.+2		;TEST FOR OVERFLOW
	ER13	AC-3,.+1	;AROV FAILED TO SET
	TLNN	AC-3,DCK
	ER13	AC-3,SN		;DCK NOT SET
	JUMPL	AC+2,.-^D14	;LOOP ON ERROR SWITCH
>
PAGE
;DVND = 4,10
;DVSR = 4,10

	AC=11
	SAVEAC	(1,1)

SN=7400
	ZZ=2

F7400:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	JRSTF	@[.+1]		;CLR ALL FLGS, EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,ZZ		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY ZZ
	JSP	AC-2,.+1
	CAIE	AC,1
	ER3	AC,SN		;C(AC) FAILED
	CAIE	AC+1,0
	ER4	AC+1,SN		;C(AC+1) FAILED
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2
	ER13	AC-2,SN
	JUMPL	AC+2,.-^D12
>
;DVND = 2,4
;DVSR = 400000 000000

	AC=7
	SAVEAC	(1,1)

SN=7500
	ZZ=1

F7500:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	JRSTF	@[.+1]		;CLR ALL FLGS, EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP DVND
	MOVSI	AC-1,400000	;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY (-N)
	JSP	AC-2,.+1
	CAIE	AC,0
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	CAIE	AC+1,ZZ
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2
	ER13	AC-2,SN
	JUMPL	AC+2,.-^D12
>
PAGE
;DVND = 7,13
;DVSR = 2

	AC=6
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=7600
	ZZ=3

F7600:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+4
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY 2
	CAIE	AC,ZZ/2		;TEST QUOT
	ER3	AC,SN
	CAIE	AC+1,1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;DVND = 2,4
;DVSR = 2,4

	AC=5
	SAVEAC	(1,1)

SN=7700
	XX=0
	ZZ=1

F7700:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	IFE	XX,<XX=1>
	SETOM	AC+1		;INITIALIZE REMAINDER
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,ZZ		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY (ZZ)
	CAIE	AC,1		;TEST QUOT
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;DVND = 177777 777777,0777777 777777
;DVSR = 1

	AC=4
	SAVEAC	(1,1)

SN=10000
	ZZ=377777

F10000:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ/2
	HRLOI	AC-2,ZZ		;SETUP FOR COMPARISON
	HRLOI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,1		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 1
	CAME	AC,AC-2		;TEST QUOTIENT
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMAINDER
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST ABILITY TO SWAP REMD
;AND QUOT
;DVND = 5,13
;DVSR - 3
;FAILURE RESULTS IN A QUOT
;EQUAL TO THE REMD

	AC=14
	SAVEAC	(1,1)

SN=10300
	ZZ=-1

F10300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+6
	MOVEI	AC-2,2
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,3		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 3
	CAIE	AC,ZZ/3		;TEST QUOT
	ER3	AC,SN
	CAME	AC+1,AC-2	;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;DVND = 2,4
;DVSR = 1
;DVND = 377777 777777,177777 777777
;DVSR = 1

	AC=13
	SAVEAC	(1,1)

SN=10400
	ZZ=1

F10400:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,1		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 1
	CAIE	AC,ZZ		;TEST QUOT
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
PAGE
SN=10500
	ZZ=0

F10500:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ/2
	IFE	ZZ,<ZZ=377777>
	HRLOI	AC-2,ZZ		;SETUP FOR COMPARISON
	HRLOI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,1		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 1
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;DVND = 100
;DVSR = 2,4
;FAILURE RESULTS IN A QUOT = 252525 252525

	AC=4
	SAVEAC	(1,1)

SN=11300
	ZZ=1

F11300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC,100		;SETUP DVND
	MOVEI	AC-1,ZZ		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE 100 BY (ZZ)
	CAIE	AC,100/ZZ	;TEST QUOT
	ER3	AC,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;DVND = 4,10
;DVSR = -2
;FAILURE OF EITHER RESULTS IN A QUOT
;= 2'S COMP ACTUAL,A REMD = 0

	AC=11
	SAVEAC	(1,1)

SN=11400
	XX=-1
	ZZ=2

F11400:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	HRROI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP DVND
	HRROI	AC-1,-2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY -2
	SKIPE	AC+1		;TEST REMD = 0
	ER4	AC+1,SN
	CAME	AC,AC-2		;TEST QUOTIENT
	ER3	AC,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;DVND = 377777 777777,177777 777777
;DVSR = 2

	AC=12
	SAVEAC	(1,1)

SN=12000
	XX=377777
	ZZ=0

F12000:	REPEAT	^D2,<
SN=SN+1
	XX=XX/2
	ZZ=ZZ/2
	IFE	ZZ,<ZZ=377777>
	HRLOI	AC-2,XX		;SETUP FOR COMPARISON
	HRLOI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY 2
	CAIE	AC+1,1
	ER4	AC+1,SN
	CAME	AC,AC-2		;TEST QUOT = 1/2 DVND
	ER3	AC,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;DVND = 4,10
;DVSR = 400000 000000

SN=12300
	ZZ=2

F12300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP DVND
	MOVSI	AC-1,400000	;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (ZZ) BY (-N)
	SKIPE	AC		;TEST QUOT
	ER3	AC,SN
	CAIE	AC+1,ZZ		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;DVND = -40,-20
;DVSR = 2

	AC=6
	SAVEAC	(1,1)

SN=12600
	ZZ=-100

F12600:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ/2
	HRROI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 2
	CAME	AC,[ZZ/2]	;TEST QUOT = 0
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;DVND = -100,-40
;DVSR = 2

	AC=4
	SAVEAC	(1,1)

SN=13000
	ZZ=-200

F13000:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ/2
	HRROI	AC-2,ZZ/2	;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (-ZZ) BY 2
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;FAILURE RESULTS IN A QUOT AND
;REMD WHICH ARE THE TWO'S
;COMPLEMENT OF ACTUAL
;DVND = -7,-17
;DVSR = 4

	AC=14
	SAVEAC	(1,1)

SN=13200
	ZZ=1

F13200:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ-10
	HRROI	AC-2,ZZ/4	;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,4		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (-ZZ) BY 4
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN
	HRROI	AC-2,-3		;SETUP FOR COMPARISON
	CAME	AC+1,AC-2	;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;DVND = -77,-37
;DVSR = 2

	AC=13
	SAVEAC	(1,1)

SN=13300
	ZZ=-177

F13300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ/2
	HRROI	AC-2,-1		;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (-ZZ) BY 2
	CAME	AC+1,AC-2	;TEST REMD
	ER4	AC+1,SN
	HRROI	AC-2,ZZ/2	;SETUP FOR COMPARISON
	CAME	AC,AC-2		;TEST QUOTIENT
	ER3	AC,AC-2
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;DVND = -4,-10
;DVSR = 2

	AC=12
	SAVEAC	(1,1)

SN=13500
	ZZ=-2

F13500:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	HRROI	AC-2,ZZ/2	;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (-ZZ) BY 2
	CAME	AC,AC-2		;TEST QUOTIENT
	ER3	AC,SN
	SKIPE	AC+1		;TEST REMAINDER
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST IDIV- TWO NEGATIVES
;TEST ABILITY TO DIVIDE TWO
;NEGATIVE NUMBERS
;TEST EXERCISES MAJORITY
;OF IDIV LOGIC GATES
;DVND = -2,-4
;DVSR = -2,-4

	AC=7
	SAVEAC	(1,1)

SN=14000
	ZZ=-1

		;DIVIDE TWO NEGATIVES
F14000:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	HRROI	AC,ZZ		;SETUP DVND
	HRROI	AC-1,ZZ		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE (-ZZ) BY (-ZZ)
	CAIE	AC,1		;TEST QUOT (POSITIVE)
	ER3	AC,SN		;INCORRECT SIGN
	SKIPE	AC+1		;TEST REMAINDER
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST IDIV -IMMEDIATE MODE
;TEST ABILITY TO DIVIDE BY E VICE C(E)
;DVND = 2,4
;DVSR = E (C(E)=0)

SN=14100
	AC=12
	ZZ=1

		;TEST IDIV-IMM MODE
F14100:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	AC=AC-1
	SAVEAC	(1,1)		;SAVE ERROR AC
	JRSTF	@[.+1]		;CLR ALL FLGS, EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP DVND
	SETZ	AC-1,		;SETUP OVFL CONDITION
	IDIVI	AC,AC-1		;DIVIDE (ZZ) BY E
	JSP	AC-1,.+1
	CAIE	AC,0
	ER3	AC,SN		;C(AC) FAILED
	CAIE	AC+1,ZZ
	ER4	AC+1,SN		;C(AC+1) FAILED
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2		;DIVIDED (ZZ) BY E
	ER13	AC-1,SN		;DIVIDED (ZZ) BY C(E)
	JUMPL	AC+2,.-^D14	;LOOP ON ERROR SWITCH
>
PAGE
;TEST IDIV-MEMORY MODE
;DVND = 10,20
;DVSR = 2

	AC=14
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=14200
	ZZ=4

		;TEST IDIV-MEMORY MODE
F14200:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC+1,ZZ		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIVM	AC,AC-1		;DIVIDE (ZZ) BY 2
	CAME	AC,AC+1
	ER3	AC,SN
	CAIE	AC-1,ZZ/2	;TEST SCE
	ER5	AC-1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST IDIV-BOTH MODE
;TEST ABILITY TO STORE QUOT
;IN AC AND E
;TEST ABILITY TO STORE REMD
;IN AC+1

	AC=13
	SAVEAC	(1,1)

SN=14300
	ZZ=1

		;TEST IDIV-BOTH MODE
F14300:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+2
	SETZ	AC+1,		;CLEAR AC+1
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIVB	AC,AC-1		;DIVIDE (ZZ) BY 2
	CAME	AC,AC-1		;TEST QUOT (C(AC)=C(E))
	ER3	AC,SN		;STORE QUOTIENT FAILED
	CAIE	AC+1,1		;TEST REMD(=1)
	ER4	AC+1,SN		;STORE REMAINDER FAILED
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
PAGE
;TEST IDIV
;DVND = 400000000000
;DVSR = 2
;QUOT = 600000000000
;REMND = 0

	AC=13
	SAVEAC	(1,1)

	ZZ=400000
	XX=600000

F14400:	SETO	AC+1,		;INITIALIZE REMAINDER STORAGE
	MOVSI	AC-2,XX		;SET UP COMPARISON FOR QUOTIENT
	SETZ	AC-3,		;SET UP COMPARISON FOR REMAINDER
	MOVSI	AC,ZZ		;SET UP DIVIDEND
	MOVEI	AC-1,2		;SET UP DIVISOR
	IDIV	AC,AC-1		;DIVIDE 400000000000 BY 2
	CAME	AC,AC-2		;TEST QUOTIENT
	ER3	AC,14401	;STORE QUOTIENT FAILED
	CAME	AC+1,AC-3	;TEST REMAINDER
	ER4	AC+1,14401	;STORE REMAINDER FAILED
	JUMPL	AC+2,F14400	;LOOP ON ERROR SWITCH
;TEST IDIVB (DIVIDE CHECK)

F14410:	JRSTF	@[.+1]		;CLEAR ALL FLAGS
	MOVEI	AC,4		;SETUP DIVIDEND
	MOVEI	AC+1,4		;SETUP REMAINDER
	SETZ	AC-1,		;SETUP DIVISOR
	IDIVB	AC,AC-1
	JSP	AC-2,.+1	;SAVE FLAGS
	CAIE	AC,4
	ER3	AC,14411	;C(AC) WAS CLOBBERED
	CAIE	AC+1,4
	ER4	AC+1,14411	;C(AC+1) WAS CLOBBERED
	CAIE	AC-1,0	
	ER5	AC-1,14411	;C(E) WAS CLOBBERED
	JOV	.+2
	ER13	AC-2,14411	;ARCV FAILED TO SET
	TLNN	AC-2,DCK
	ER13	AC-2,14411	;'DCK' FAILED TO SET
	JUMPL	AC+2,F14410	;LOOP ON ERROR SWITCH
SUBTTL	DIAGNOSTIC SECTION - FRACTIONAL DIVIDE TEST

;TEST FAC2 AND DECODE
;TEST OF ABILITY TO ASSERT IRDIV
;TEST ABILITY TO FETCH C(AC+1)

	AC=13
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=14500
	XX=4000000001
	ZZ=2

		;TEST FAC2 FAILING(IRDIV)
F14500:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX-1
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP HIGH DVND
	MOVEI	AC+1,200	;SETUP LOW DVND
	MOVEI	AC-1,200	;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE (N) BY 200
	CAME	AC,[XX]		;TEST BIT 35(1) (ODD QUOT)
	ER3	AC,SN
	SKIPE	<AC+1>&17	;TEST REMD = 0
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;HIGH DVND = 2,4
;LOW DVND = 0
;DVSR = 2,4

	AC=6
	SAVEAC	(1,1)

SN=14600
	ZZ=1

F14600:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	MOVEI	AC,ZZ		;SETUP HIGH DVND
	SETZ	AC+1,		;SETUP LOW DVND
	MOVEI	AC-1,ZZ		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE ZZ BY ZZ
	JSP	AC-2,.+1
	JOV	.+2		;TEST AROV FLAG
	ER13	AC-2,SN
	TLNN	AC-2,DCK
	ER13	AC-2,SN		;DCK FAILED TO SET
	CAIE	AC,ZZ		;EXAMINE QUOTIENT
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	SKIPE	<AC+1>&17	;EXAMINE REMAINDER
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	JUMPL	AC+2,.-^D14	;LOOP ON ERROR SWITCH
>
PAGE
;=2
;HIGH DVND = 4
;LOW DVND = 4
;DVSR = 10,20

	AC=5
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=14700
	ZZ=4

F14700:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC-2,4		;SETUP FOR COMPARISON
	MOVEI	AC,4		;SETUP HIGH DVND
	MOVEI	AC+1,4		;SETUP LOW DVND
	MOVEI	AC-1,ZZ		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE (N) BY ZZ
	CAME	AC+1,AC-2	;TEST REMD = 2
	ER4	AC+1,SN
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;HIGH DVND = -1
;LOW DVND = -4,-10
;DVSR = 2

	AC=13
	SAVEAC	(1,1)

SN=15000
	XX=-1
	ZZ=-2

F15000:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	HRROI	AC-2,XX		;SETUP FOR COMPARISON
	SETO	AC,		;SETUP HIGH DVND
	HRROI	AC+1,ZZ		;SETUP LOW DVND
	MOVEI	AC-1,2		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE ZZ BY 2
	SKIPE	AC+1		;TEST REMD = 0
	ER4	AC+1,SN
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;HIGH DVND = -1
;LOW DVND = 2,4
;DVSR = -2,-4

	AC=14
	SAVEAC	(1,1)

SN=15100
	XX=-1
	YY=377777
	ZZ=1

F15100:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	YY=YY/2
	ZZ=ZZ+ZZ
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	SETO	AC,		;SETUP HIGH DVND
	MOVEI	AC+1,ZZ		;SETUP LOW DVND
	HRROI	AC-1,XX		;SETUP DVSR
	HRLOI	AC-3,YY
	DIV	AC,AC-1		;DIVIDE (-N) BY (XX)
	JSP	AC-2,.+1
	CAME	AC,<AC-3>&17
	ER3	AC,SN		;C(AC) FAILED
	CAIE	AC+1,0
	ER4	AC+1,SN		;C(AC+1) FAILED
	JOV	.+2		;TEST AROV FLAG
	JRST	,.+2
	ER13	AC-2,SN		;AROV SET
	TLNE	AC-2,DCK
	ER13	AC-2,SN		;DCK SET
	JUMPL	AC+2,.-^D16	;LOOP ON ERROR SWITCH
>
;HIGH  DVND = -2,-4
;LOW DVND = -1
;DVSR = 2,4

	AC=12
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=15200
	XX=1
	YY=1B0
	ZZ=-1

F15200:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	YY=YY_-1
	ZZ=ZZ+ZZ
	HRROI	AC,ZZ		;SETUP HIGH DVND
	SETO	AC+1,		;SETUP LOW DVND
	MOVEI	AC-1,XX		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE (-N) BY (XX)
	CAME	AC,[1B0+YY]	;TEST FOR ODD NUMBER QUOTIENT
	ER3	AC,SN
	CAME	AC+1,[-1]	;TEST REMD
	ER4	AC+1,SN
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;OPERANDS SELECTED SHOULD RESULT
;IN OVERFLOW
;HIGH DVND = -100,-40
;LOW DVND = 0
;DVSR = 100,40

	AC=6
	SAVEAC	(1,1)

SN=15600
	WW=-200
	XX=200
	ZZ=-200

F15600:	REPEAT	^D2,<
SN=SN+1
	WW=WW/2
	XX=XX/2
	ZZ=ZZ/2
	JRSTF	@[.+1]		;CLR ALL FLAGS, EXEC NEXT INST
	HRROI	AC-2,WW		;SETUP AC-2 FOR COMPARISON
	HRROI	AC,ZZ		;SETUP HIGH DVND
	SETZ	AC+1,		;SETUP LOW DVND
	MOVEI	AC-1,XX		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE (-N) BY (N)
	JSP	AC-3,.+1
	JOV	.+2		;TEST FOR OVERFLOW
	ER13	AC-3,SN
	TLNN	AC-3,DCK
	ER13	AC-3,SN		;DCK NOT SET
	CAME	AC,AC-2		;TEST FOR UNIQUE QUOTIENT
	ER3	AC,SN
	CAIE	AC+1,0
	ER4	AC+1,SN		;C(AC+1) FAILED
	JUMPL	AC+2,.-^D16	;LOOP ON ERROR SWITCH
>
;OPERANDS SELECTED SHOULD RESULT IN OVERFLOW
;HIGH DVND = -2,-4
;LOW DVND = 0
;DVSR = 2

	AC=5
	SAVEAC	(1,1)

SN=15700
	XX=-1
	ZZ=-1

F15700:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	JRSTF	@[.+1]		;CLR ALL FLGS, EXEC NEXT INST
	HRROI	AC,ZZ		;SETUP HIGH DVND
	SETZ	AC+1,		;SETUP LOW DVND
	MOVEI	AC-1,2		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE (-N) BY 2
	JSP	AC-2,.+1
	JOV	.+2		;TEST FOR OVERFLOW
	ER13	AC-2,SN
	CAME	AC,[XX]		;TEST QUOT
	ER3	AC,SN
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
;OPERANDS SELECTED WILL NOT OVERFLOW
;HIGH DVND = -1,-2
;LOW DVND = -1
;DVSR = -1,-2

	AC=14
	SAVEAC	(1,1)

SN=16100
	ZZ=0

F16100:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=-1>
	JRSTF	@[.+1]		;CLR ALL FLGS, EXEC NEXT INST
	HRROI	AC,ZZ		;SETUP HIGH DVND
	SETO	AC+1,		;SETUP LOW DVND
	HRROI	AC-1,ZZ		;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE (-N) BY (-N)
	JSP	AC-3,.+1
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2
	ER13	AC-3,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;TEST DIV-IMMEDIATE MODE
;TEST ABILITY TO DIVIDE BY E
;VICE C(E)
;TEST ABILITY TO INHIBIT ASSERTION
;OF IRMDFCE

SN=16200
	AC=7
	ZZ=17

		;TEST DIV-IMM MODE
F16200:	REPEAT	^D2,<
SN=SN+1
	AC=AC-1
	ZZ=ZZ-1
	SAVEAC	(1,1)		;SAVE ERROR AC
	JRSTF	@[.+1]		;CLR ALL FLGS, EXEC NEXT INST
	MOVEI	AC,4		;SETUP HIGH DVND
	SETZ	AC+1,		;SETUP LOW DVND
	MOVEI	AC-1,2		;SETUP OVERFLOW CONDITION
	DIVI	AC,ZZ		;DIVIDE (N) BY E
	JSP	AC-3,.+1
	JOV	.+2		;TEST FOR OVERFLOW
	JRST	,.+2		;DIVIDED BY E
	ER13	AC-3,SN		;DIVIDED BY C(E)
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;TEST DIV-MEMORY MODE
;TEST ABILITY TO ASSERT IRMDSCE
;TEST ABILITY TO ASSERT IRMDSACINH

	AC=5
	SAVEAC	(1,1)
	JRSTF	@[.+1]		;CLEAR ALL FLAGS

SN=16300
	XX=10000
	ZZ=2

		;TEST DIV-MEM MODE
F16300:	REPEAT	^D2,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	MOVSI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP HIGH DVND
	MOVEI	AC+1,ZZ		;SETUP LOW DVND
	MOVEI	AC-1,100	;SETUP DVSR
	DIVM	AC,AC-1		;DIVIDE (+N) BY 100
	CAME	AC-1,AC-2	;TEST SCE
	ER5	AC-1,SN
	CAME	AC,AC+1		;TEST SAC INH
	ER3	AC,SN
	JUMPL	AC+2,.-^D9	;LOOP ON ERROR SWITCH
>
;TEST DIV-BOTH MODE
;TEST ABILITY TO STORE QUOT
;IN AC,E
;TEST ABILITY TO STORE REMD
;IN AC+1

	AC=14
	SAVEAC	(1,1)

SN=16400
	ZZ=2

		;TEST DIV-BOTH MODE
F16400:	REPEAT	^D2,<
SN=SN+1
	ZZ=ZZ+ZZ
	MOVEI	AC,ZZ		;SETUP HIGH DVND
	MOVEI	AC+1,100	;SETUP LOW DVND
	MOVEI	AC-1,100	;SETUP DVSR
	DIVB	AC,AC-1		;DIVIDE (+N) BY 100
	CAME	AC,AC-1		;TEST STORE QUOTIENT
	ER3	AC,SN		;STORE QUOTIENT FAILED
	SKIPE	AC+1		;TEST STORE REMAINDER
	ER4	AC+1,SN		;STORE REMAINDER FAILED
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
PAGE
;TEST DIVB (DIVIDE CHECK)

F16410:	JRSTF	@[.+1]		;CLEAR ALL FLAGS
	MOVEI	AC,4		;SETUP HIGH DIVIDEND
	MOVEI	AC+1,1		;SETUP LOW DIVIDEND
	MOVEI	AC-1,1		;SETUP DIVISOR
	DIVB	AC,AC-1
	JSP	AC-2,.+1	;SAME FLAGS
	CAIE	AC,4
	ER3	AC,16411	;C(AC) WAS CLOBBERED
	CAIE	AC+1,1
	ER4	AC+1,16411	;C(AC+1) WAS CLOBBERED
	CAIE	AC-1,1
	ER5	AC-1,16411	;C(E) WAS CLOBBERED
	JOV	.+2
	ER13	AC-2,16411	;AROV FAILED TO SET
	TLNN	AC-2,DCK	;DCK FAILED TO SET
	ER13	AC-2,16411
	JUMPL	AC+2,F16410

SUBTTL	DIAGNOSTIC SECTION - GENERAL MPY/DIV TEST

;TEST MUL DIRECT - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;0500000000000 BY A DECREASING MULTIPLIER
;PLIER=200000000000, 100000000000 (1/2, 1/4) ETC
;PLICAND=050000000000
;HIGH PROD=024000000000, 012000000000 ETC
;LOW PROD=0

	AC=13
	SAVEAC	(1,1)

SN=17100
	XX=050000
	ZZ=0

F17100:	REPEAT	^D10,<
SN=SN+1
	XX=XX/2
	ZZ=ZZ/2
	IFE	ZZ,<ZZ=200000>
	MOVSI	AC-2,XX		;SETUP FOR COMPARISON
	MOVSI	AC,ZZ		;SETUP PLIER
	MOVSI	AC-1,050000	;SETUP PLICAND
	MUL	AC,AC-1		;MULTIPLY ZZ X 050000000000
	SKIPE	AC+1		;TEST LOW PROD=0
	ER4	AC+1,SN
	CAME	AC,AC-2		;TEST HIGH PROD=XX
	ER3	AC,SN		;MUL FAILED
	CAME	AC-1,[050000,,0];WAS C(E) MODIFIED ?
	ER5	AC-1,SN		;C(E) WAS CLOBBERED
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
;TEST MUL IMMEDIATE - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;E BY AND DECREASING MULTIPLIER
;PLIER=200000000000, 100000000000 (1/2, 1/4) ETC
;PLICAND=E (005001)
;HIGH PROD=2400,1200,500,240,120
;LOW PROD=PLIER

	AC=12
	SAVEAC	(1,1)

SN=17200
	XX=005000
	ZZ=0

F17200:	REPEAT	^D5,<
SN=SN+1
	XX=XX/2
	ZZ=ZZ/2
	IFE	ZZ,<ZZ=200000>
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVSI	AC,ZZ		;SETUP PLIER
	MULI	AC,005001	;MULTIPLY E BY ZZ
	CAME	AC,AC-2		;TEST HIGH PROD=XX
	ER3	AC,SN		;HIGH PROD ERROR
	MOVSI	AC-2,ZZ		;SETUP FOR COMPARISON
	CAME	AC+1,AC-2	;TEST LOW PROD=PLIER
	ER4	AC+1,SN		;LOW PROD ERROR
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST MUL MEMORY - TWO NEGATIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;AN INCREASING NEGATIVE NUMBER BY -1
;PLIER=-1
;PLICAND=-1,-2,-4,-10,-20
;HIGH PROD=0

	AC=11
	SAVEAC	(1,1)

SN=17300
	ZZ=0

F17300:	REPEAT	^D5,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=-1>
	SETO	AC,		;SETUP PLIER
	HRROI	AC-1,ZZ		;SETUP PLICAND
	MULM	AC,AC-1		;MULTIPLY ZZ BY -1
	SKIPE	AC-1		;TEST HIGH PROD = 0
	ER5	AC,SN		;MULM FAILED
	JUMPL	AC+2,.-5	;LOOP ON ERROR SWITCH
>
;TEST MUL BOTH - TWO NEGATIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;-1 BY AN INCREASING NEGATIVE NUMBER
;PLIER=-1,-2,-4,-10,-20
;PLICAND=-1
;HIGH PROD=0
;LOW PROD=1,2,4,10,20

	AC=10
	SAVEAC	(1,1)

SN=17400
	XX=0
	ZZ=0

F17400:	REPEAT	^D5,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	IFE	XX,<XX=1>
	IFE	ZZ,<ZZ=-1>
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP PLIER
	SETO	AC-1,		;SETUP PLICAND
	MULB	AC,AC-1		;MULTIPLY -1 BY ZZ
	SKIPE	AC		;TEST HIGH PROD=0
	ER3	AC,SN
	SKIPE	AC-1		;TEST C(AC) = C(E)
	ER5	AC-1,SN
	CAME	AC+1,AC-2	;TEST LOW PROD=XX
	ER4	AC+1,SN		;MULB FAILED
	JUMPL	AC+2,.-^D10	;LOOP ON ERR SWITCH
>
;TEST MUL MEMORY - TWO NEGATIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;-5001 BY AN INCREASING NEGATIVE PLIER
;PLIER=600000000000, 700000000000 ETC.
;PLICAND=-5001
;HIGH PROD=2400,1200,500,240,120

	AC=7
	SAVEAC	(1,1)

SN=17500
	XX=005000
	ZZ=0

F17500:	REPEAT	^D5,<
SN=SN+1
	XX=XX/2
	ZZ=ZZ/2
	IFE	ZZ,<ZZ=-200000>
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVSI	AC,ZZ		;SETUP PLIER
	HRROI	AC-1,-5001	;SETUP PLICAND
	MOVE	AC-3,<AC+1>&17	;SAVE C(AC+1)
	MULM	AC,AC-1		;MULTIPLY ZZ X -5001
	CAME	AC-1,AC-2	;TEST HIGH PROD = XX
	ER5	AC-1,SN		;MULM FAILED
	CAME	AC,[ZZ,,0]	;WAS C(AC) MODIFIED ?
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	CAME	AC+1,<AC-3>&17	;WAS C(AC+1) MODIFIED ?
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>

;TEST IMUL DIRECT - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;A NUMBER BY ITSELF
;PLIER=2,4,10,20,40
;PLICAND=2,4,10,20,40
;PROD=4,20,100,400,2000

	AC=6
	SAVEAC	(1,1)

SN=17600
	XX=1
	ZZ=1

F17600:	REPEAT	^D5,<
SN=SN+1
	XX=XX*4
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=-200000>
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP PLIER
	MOVEI	AC-1,ZZ		;SETUP PLICAND
	IMUL	AC,AC-1		;MULTIPLY ZZ BY ZZ
	CAME	AC,AC-2		;TEST PROD=XX
	ER3	AC,SN		;IMUL FAILED
	CAIE	AC-1,ZZ		;WAS C(E) MODIFIED ?
	ER5	AC-1,SN		;C(E) WAS CLOBBERED
	JUMPL	AC+2,.-^D8	;LOOP ON ERROR SWITCH
>
;TEST IMUL IMMEDIATE - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;3 X E
;PLIER=3
;PLICAND=E
;PROD=6,11,14,17,22

	AC=5
	SAVEAC	(1,1)

SN=17700
	XX=3
	ZZ=1

F17700:	REPEAT	^D5,<
SN=SN+1
	XX=XX+3
	ZZ=ZZ+1
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,3		;SETUP PLIER
	IMULI	AC,ZZ		;MULTIPLY 3 X E
	CAME	AC,AC-2		;TEST PROD = XX
	ER3	AC,SN		;IMULI FAILED
	JUMPL	AC+2,.-5	;LOOP ON ERROR SWITCH
>
;TEST IMUL MEMORY - TWO NEGATIVES
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;A NEGATIVE NUMBER BY ITSELF
;PLIER=-2,-4,-10,-20,-40
;PLICAND=-2,-4,-10,-20,-40
;PROD=4,20,100,400,2000

	AC=4
	SAVEAC	(1,1)

SN=20000
	XX=1
	ZZ=-1

F20000:	REPEAT	^D5,<
SN=SN+1
	XX=XX*4
	ZZ=ZZ+ZZ
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP PLIER
	HRROI	AC-1,ZZ		;SETUP PLICAND
	MOVE	AC-3,<AC+1>&17	;SAVE C(AC+1)
	IMULM	AC,AC-1		;MULTIPLY ZZ BY ZZ
	CAME	AC-1,AC-2	;TEST PROD=XX
	ER5	AC-1,SN		;IMULM FAILED
	CAME	AC,[-1,,ZZ]	;WAS C(AC) MODIFIED ?
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	CAME	AC+1,<AC-3>&17	;WAS C(AC+1) MODIFIED ?
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;TEST IMUL BOTH - MULTIPLY BY 0
;TESTING IS ACCOMPLISHED BY MULTIPLYING
;A NEGATIVE NUMBER BY 0
;PLIER=0
;PLICAND=-1,-2,-4,-10,-20
;PROD=0

	AC=5
	SAVEAC	(1,1)

SN=20100
	ZZ=0

F20100:	REPEAT	^D5,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=-1>
	SETZ	AC,		;SETUP PLIER
	HRROI	AC-1,ZZ		;SETUP PLICAND
	IMULB	AC,AC-1		;MULTIPLY ZZ BY 0
	SKIPE	AC		;TEST PROD=0
	ER3	AC,SN
	SKIPE	AC-1		;TEST C(AC) = C(E)
	ER5	AC-1,SN		;IMULB FAILED
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST IDIV DIRECT - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY
;DIVIDING A NUMBER BY ITSELF
;DVND=1,2,4, ETC
;DVSR=1,2,4, ETC
;AN ERROR WILL OCCUR IF QUOT
;DIFFERS FROM 1
;AN ERROR WILL OCCUR IF REMD
;DIFFERS FROM 0

	AC=5
	SAVEAC	(1,1)

SN=20200
	ZZ=0

F20200:	REPEAT	^D18,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=1>
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,ZZ		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY ZZ
	CAIE	AC,1		;TEST QUOT=1
	ER3	AC,SN
	JUMPE	AC+1,.+2	;TEST REMD=0
	ER4	AC+1,SN		;IDIV FAILED
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
SN=20300
	ZZ=0

F20300:	REPEAT	^D17,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=1>
	MOVSI	AC,ZZ		;SETUP DVND
	MOVSI	AC-1,ZZ		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY ZZ
	CAIE	AC,1		;TEST QUOT=1
	ER3	AC,SN
	JUMPE	AC+1,.+2	;TEST REMD=0
	ER4	AC+1,SN		;IDIV FAILED
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST IDIV DIRECT - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY
;DIVIDING AN EVEN NUMBER BY 1
;DVND=1,2,4 ETC
;DVSR=1
;AN ERROR WILL OCCUR IF QUOT
;DIFFERS FROM DVND
;AN ERROR WILL OCCUR IF REMD
;DIFFERS FROM 0

	AC=13
	SAVEAC	(1,1)

SN=20400
	ZZ=0

F20400:	REPEAT	^D18,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=1>
	MOVEI	AC-2,ZZ		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,1		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 1
	CAME	AC,AC-2		;TEST QUOT=DVND
	ER3	AC,SN
	JUMPE	AC+1,.+2	;TEST REMD=0
	ER4	AC+1,SN		;IDIV FAILED
	CAIE	AC-1,1		;WAS C(E) MODIFIED ?
	ER5	AC-1,SN		;C(E) WAS CLOBBERED
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
SN=20500
	ZZ=0

F20500:	REPEAT	^D17,<
SN=SN+1
	ZZ=ZZ+ZZ
	IFE	ZZ,<ZZ=1>
	MOVSI	AC-2,ZZ		;SETUP FOR COMPARISON
	MOVSI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,1		;SETUP DVSR
	IDIV	AC,AC-1		;DIVIDE ZZ BY 1
	CAME	AC,AC-2		;TEST QUOT=DVND
	ER3	AC,SN
	JUMPE	AC+1,.+2	;TEST REMD=0
	ER4	AC+1,SN		;IDIV FAILED
	CAIE	AC-1,1		;WAS C(E) MODIFIED ?
	ER5	AC-1,SN		;C(E) WAS CLOBBERED
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
;TEST IDIV IMMEDIATE - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY DIVIDING
;AN ODD NUMBER BY E
;DVND=3,5,7,11 ETC
;DVSR=E (2)
;QUOT=1,2,4, ETC
;REMD=1

	AC=14
	SAVEAC	(1,1)

SN=20600
	XX=0
	ZZ=1

F20600:	REPEAT	^D10,<
SN=SN+1
	XX=XX+1
	ZZ=ZZ+2
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP DVND
	IDIVI	AC,2		;DIVIDE ZZ BY 2
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN
	CAIE	AC+1,1		;TEST REMD=1
	ER4	AC+1,SN		;IDIVI FAILED
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST IDIV MEMORY - TWO NEGATIVES
;TESTING IS ACCOMPLISHED BY DIVIDING
;A NEGATIVE NUMBER BY -1
;DVND=-1,-2,-4,-10,-20
;DVSR=-1
;QUOT=1,2,4,10,20
;REMD=0

	AC=12
	SAVEAC	(1,1)

SN=20700
	XX=0
	ZZ=0

F20700:	REPEAT	^D5,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	IFE	XX,<XX=1>
	IFE	ZZ,<ZZ=-1>
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP DVND
	SETO	AC-1,		;SETUP DVSR
	MOVE	AC-3,<AC+1>&17	;SAVE C(AC+1)
	IDIVM	AC,AC-1		;DIVIDE ZZ BY -1
	CAME	AC-1,AC-2	;TEST QUOT
	ER5	AC-1,SN		;IDIVM FAILED
	CAME	AC,[-1,,ZZ]	;WAS C(AC) MODIFIED ?
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	CAME	AC+1,<AC-3>&17	;WAS C(AC+1) ALTERED ?
	ER4	AC+1,SN		;C(AC+1] WAS CLOBBERED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;TEST IDIV BOTH - TWO POSITIVES
;TESTING IS ACCOMPLISHED BY DIVIDING
;AN INCREASING ODD NUMBER BY 2
;DVND=15,17,21,23,25
;DVSR=2
;QUOT=6,7,10,11,12
;REMD=1

	AC=11
	SAVEAC	(1,1)

SN=21000
	XX=5
	ZZ=13

F21000:	REPEAT	^D5,<
SN=SN+1
	XX=XX+1
	ZZ=ZZ+2
	MOVEI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP DVND
	MOVEI	AC-1,2		;SETUP DVSR
	IDIVB	AC,AC-1		;DIVIDE ZZ BY 2
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN		;QUOT ERROR
	CAME	AC,AC-1		;C(AC) = C(E)
	ER5	AC-1,SN
	CAIE	AC+1,1		;TEST REMD=1
	ER4	AC+1,SN		;IDIVB FAILED
	JUMPL	AC+2,.-^D10	;LOOP ON ERROR SWITCH
>
;TEST DIV DIRECT - TWO POSITIVES
;HIGH DVND=4,10,20,40,100
;LOW DVND=0
;DVSR=2000
;QUOT=001000000000, 00200000000 ETC
;REMD=0

	AC=10
	SAVEAC	(1,1)

SN=21100
	XX=000400
	ZZ=2

F21100:	REPEAT	^D5,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	MOVSI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP HIGH DVND
	SETZ	AC+1,		;SETUP LOW DVND
	MOVEI	AC-1,2000	;SETUP DVSR
	DIV	AC,AC-1		;DIVIDE ZZ BY 2000
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN
	JUMPE	AC+1,.+2	;TEST REMD
	ER4	AC+1,SN		;DIV FAILED
	CAIE	AC-1,2000	;WAS C(E) MODIFIED ?
	ER5	AC-1,SN		;C(E) WAS CLOBBERED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;TEST DIV IMMEDIATE - TWO POSITIVES
;HIGH DVND=0
;LOW DVND=3,4,5,6,7
;DVSR=E (2,3,4,5,6)
;QUOT=1
;REMD=1

	AC=7
	SAVEAC	(1,1)

SN=21200
	XX=1
	ZZ=2
F21200:	REPEAT	^D5,<
SN=SN+1
	XX=XX+1
	ZZ=ZZ+1
	SETZ	AC,		;SETUP HIGH DVND
	MOVEI	AC+1,ZZ		;SETUP LOW DVND
	DIVI	AC,XX		;SETUP DVSR
	CAIE	AC,1		;TEST QUOT=1
	ER3	AC,SN
	CAIE	AC+1,1		;TEST QUOT=REMD
	ER4	AC+1,SN		;DIVI FAILED
	JUMPL	AC+2,.-7	;LOOP ON ERROR SWITCH
>
;TEST DIV MEMORY - TWO NEGATIVES
;HI DVND = -2,-4,-10,-20,-40
;LO DVND=0
;DVSR=-200
;QUOT=00400000000, 010000000000 ETC
;REMD=0

	AC=6
	SAVEAC	(1,1)

SN=21300
	XX=002000
	ZZ=-1

F21300:	REPEAT	^D5,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	MOVSI	AC-2,XX		;SETUP FOR COMPARISON
	HRROI	AC,ZZ		;SETUP HIGH DVND
	SETZ	AC+1,		;SETUP LOW DVND
	HRROI	AC-1,-200	;SETUP DVSR
	DIVM	AC,AC-1		;DIVIDE ZZ BY -200
	CAME	AC-1,AC-2	;TEST QUOT
	ER5	AC-1,SN		;DIVM FAILED
	CAME	AC,[-1,,ZZ]	;WAS C(AC) MODIFIED ?
	ER3	AC,SN		;C(AC) WAS CLOBBERED
	SKIPE	<AC+1>&17	;WAS C(AC+1) MODIFIED ?
	ER4	AC+1,SN		;C(AC+1) WAS CLOBBERED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>
;TEST DIV BOTH - TWO POSITIVES
;HIGH DVND 2,4,10,20,40
;LOW DVND 2,4,10,20,40
;DVSR=200
;QUOT=00400000000, 010000000000 ETC
;REMD=2,4,10,20,40

	AC=5
	SAVEAC	(1,1)

SN=21400
	XX=002000
	ZZ=1

F21400:	REPEAT	^D5,<
SN=SN+1
	XX=XX+XX
	ZZ=ZZ+ZZ
	MOVSI	AC-2,XX		;SETUP FOR COMPARISON
	MOVEI	AC,ZZ		;SETUP HIGH DVND
	MOVEI	AC+1,ZZ		;SETUP LOW DVND
	MOVEI	AC-1,200	;SETUP DVSR
	DIVB	AC,AC-1		;DIVIDE ZZ BY 200
	CAME	AC,AC-2		;TEST QUOT
	ER3	AC,SN		;QUOT ERROR
	CAME	AC-1,AC-2	;TEST C(AC) = C(E)
	ER5	AC-1,SN
	CAIE	AC+1,ZZ		;TEST REMD
	ER4	AC+1,SN		;DIVB FAILED
	JUMPL	AC+2,.-^D11	;LOOP ON ERROR SWITCH
>

LAST1:	JRST	BEGEND		;REPEAT DIAGNOSTIC