        
instruction test     19 may 67


/test program 1
/clear locations 0000 through 7766, and read-in mode simulator

readin
7766/

zro,	dzm 0
	idx zro
	isp tmp
	jmp zro

/read-in mode simulator

rim,	rpb	/this is location 7772
	dio tmp
	spi i
	rpb
tmp,	770010	/-7767 for memory killer
	jmp rim

start zro
                
                                
2
/part 2
/test hlt, jmp, szs

readin
0/

	2	/program number
stt,	hlt	/only test for hlt
	jmp 3000	/start of jump test
	hlt	/if jmp fails

ss,

define ztest a
	szs i a
	szs a
	hlt
terminate

	ztest 10	/test szs and szs i
	ztest 20	/with all switches off
	ztest 30
	ztest 40
	ztest 50
	ztest 60
	ztest 70	/all switches

	jmp stt 1	/resume jump test

define ntest a
	szs a
	szs i a
	hlt
terminate

a,

	ntest 10	/test szs and szs i
	ntest 20	/with all switches on
	ntest 30
	ntest 40
	ntest 50
	ntest 60
	ntest 70	/all switches

	jmp a	/iterate test

3000/

	jmp 4777	/part of jump test
	hlt	/if jmp fails

4777/

	jmp 6000	/diddle program counter
	hlt	/if jmp fails

6000/








	jmp ss	/leave jump test, test switches
	hlt	/if jmp fails

foo,

start stt
                
                                
3
/part 3
/test cla, cma, sma, spa, skp, skp i, and lat partly
/test word should be 777777

readin
0/

	3	/program number
stt,	szs 10	/if on,
	hlt	/halt after read-in

	skp i	/test unconditional skip
	hlt	/if fails
	skp	/test no skip
	jmp a	/ok
	hlt	/failed

a,	lat	/all ones to ac
	cla	/test cla and sza jointly
	sza
	hlt	/failed

	lat	/all ones to ac
	cma	/test cma
	sza
	hlt
	spa	/test spa
	hlt
	sma i	/test sma negation
	hlt
	cma	/now 777777
	sza i	/test sza negation
	hlt
	spa i	/test spa negation
	hlt
	sma	/test sma true
	hlt

/end of tests

	szs 20	/if switch on, reiterate
	jmp stt 2	/by returning
	jmp 7772	/otherwise, read in next tape

start stt
                
                                
4
/part 4
/test xor, sas, sad

readin
0/

	4	/program number
stt,	szs 10	/if switch on,
	hlt	/halt after read-in

	clc	/ones to ac
	xor ons	/check -0 xor -0
	sza
	hlt	/error
	xor zrs	/0 xor 0
	sza
	hlt	/error
	xor ons	/0 xor -0
	cma	/should be -0
	sza
	hlt	/error
	cma
	xor zrs	/-0 xor 0
	cma
	sza
	hlt	/error

/start of sad and sas tests

	sas zrs	/ac is 0
	hlt	/error
	sza
	hlt	/error, ac was changed
	sad ons	/ac is 0
	hlt
	sza	/if ac was changed
	hlt	/error
	cma	/now ac is 777777
	sas zrs
	skp i	/ok, skip halt
	hlt	/error
	cma
	sza
	hlt	/error, ac was changed
	cma
	sad ons	/should be same
	skp i	/ok
	hlt	/error
	cma
	sza
	hlt	/error, ac was changed

/end of tests

	szs 20	/if switch 2 on,
	jmp stt 2	/iterate
	jmp 7772	/read in next test program

ons,	777777
zrs,	000000
start stt
                
                                
5
/part 5
/test dip, dap, dac, lac

readin
0/

	5	/program number
stt,	szs 10	/if sw 1 on,
	hlt	/halt after read-in

define junk
	dip rgs
	dap rgs
	sas rgs
	hlt
	dac tmp
	sas tmp
	hlt
terminate

/begin tests of dip, dap, and dac

	cla	/first, test with zeroes
	junk	/true blue

	cma	/now test with all ones
	junk	/into all 0s

	junk	/all 1s into all 1s

	cma	/all 0s
	junk	/into all 1s

/begin test of lac

	lac zrs	/load from word of zeroes
	sza	/if ac not 0,
	hlt	/then error
	lac ons	/load 1s into 0s
	sas ons
	hlt	/error
	lac ons	/1s into 1s
	sas ons
	hlt	/error
	lac zrs	/0s into 1s
	sza
	hlt	/error

/end of tests, part 5

	szs 20	/if sw 2 up,
	jmp stt 2	/iterate
	jmp 7772	/read in next test

zrs,	000000
ons,	777777
rgs,	0
tmp,	0

start stt
                
                                
6
/part 6
/test dzm, idx

readin
0/

	6	/program number
stt,	szs 10	/if sw 1 up,
	hlt	/halt after read-in

/begin test of dzm

	clc	/word of 1s
	dac tmp
	dzm tmp	/zero test word of 1s
	lac tmp
	sza
	hlt	/error
	dzm tmp	/zero test word of 0s
	lac tmp
	sza
	hlt	/error

/begin test of idx

	clc	/-0
	dac tmp
	idx tmp	/should now be 1
	spa
	hlt	/big error
	sza i
	hlt	/error
	cma
	dac tmp	/now should be -1
	idx tmp
	sza
	hlt	/error

/now some lengthy hack

define ptest a
	lac tb1 a
	dac tmp
	idx tmp
	spa
	hlt
terminate

define ntest a
	lac tb2 a
	dac tmp
	idx tmp
	sma
	hlt
terminate

/begin idx test of special bits

	ptest 0
	ptest 1
	ptest 2




	ptest 3
	ptest 4
	ptest 5
	ptest 6
	ptest 7
	ptest 10
	ptest 11
	ptest 12
	ptest 13
	ptest 14
	ptest 15
	ptest 16

	ntest 0
	ntest 1
	ntest 2

/end of tests

	szs 20	/if sw2 up
	jmp stt 2	/iterate
	jmp 7772	/read in next test program

/random storage and constants

tmp,	0

tb1,

377776	377775	377773	377767	377757	377737
377677	377577	377377	376777	375777	373777
367777	357777	337777

tb2,

677777	577777	377777

foo,

start stt
                
                                
7
/part 7
/test isp

readin
0/

	7	/program number
stt,	szs 10	/if sw1 up,
	hlt	/halt after read-in

	lac tn1	/377777
	dac ct1
	dac t1
	lac tn2	/777776
	dac ct2
	dac t2

/start of isp test

define idsas a,b
	idx a
	sas b
	hlt
terminate

lp,	isp t2	/777776 to 0
	hlt	/error
	idsas ct2,t2	/check result against idx
	sad tn1	/leave loop when ct2 is 377777
	jmp lst	/through this exit
	isp t1	/should never be positive
	skp i
	hlt	/error
	idsas ct1,t1
	jmp lp

lst,	isp t1	/t1 should be 777776 before this
	hlt	/error
	sza
	hlt	/error
	isp t2	/377777 to 400000
	skp i
	hlt	/error
	idsas ct2,t2

/end of isp test

	szs 20	/if sw2 up,
	jmp stt 2
	jmp 7772	/read in next test

ct1,	0
ct2,	0
t1,	0
t2,	0
tn1,	377777	/test number 1
tn2,	777776	/test number 2

foo,

start stt
                
                                
10
/part 10
readin
/test and, ior

0/

	10	/program number
stt,	szs 10	/if sw1 up,
	hlt	/halt after read-in

/begin tests of and and ior

define amac a,b,c
	lac a
	and b
	c
	hlt
terminate

	amac t2,t2,sas t2	/1s and 1s
	amac t1,t2,sza	/0s and 1s
	amac t1,t1,sza	/0s and 0s
	amac t2,t1,sza	/1s and 0s

define imac a,b,c
	lac a
	ior b
	c
	hlt
terminate

	imac t1,t1,sza	/0s or 0s
	imac t1,t2,sas t2	/0s or 1s
	imac t2,t2,sas t2	/1s or 1s
	imac t2,t1,sas t2	/1s or 0s

/end of tests for part 10

	szs 20	/if sw2 up,
	jmp stt 2
	jmp 7772

t1,	000000
t2,	777777

foo,

start stt
                
                                
11
/part 11
/test lio, dio, spi

readin
0/

	11	/program number
stt,	szs 10	/if sw1 up
	hlt	/halt after read-in

/begin tests

define loop
	lio t1
	dio t2
	sas t2
	hlt
	spa
	jmp b
terminate

	dzm t1
	cla	/initialize

a,	loop	/test until t1 is 400000

	spi	/test spi instruction
	hlt	/error
	idx t1
	jmp a

b,	spi i	/io now negative
	hlt	/error
	idx t1

	loop	/test until t1 is 0

/end of tests for part 11

	szs 20	/iterate if sw2 up
	jmp stt 2
	jmp 7772	/get next program

/random

t1,	0
t2,	0

foo,

start stt
                
                                
12
/part 12
/test add, szo, sub

readin
0/

	12	/program number
stt,	szs 10	/if up
	hlt	/halt after read-in

/begin test of szo

	szo	/turn off overflow flip-flop
	szo i	/check that szo i doesnt skip
	szo	/should skip
	hlt	/error
	szo i	/should not skip
	skp i
	hlt	/error

/start of add test

	cla
	add zro	/test add of 0s
	sza
	hlt	/error
	add pmx	/377777
	sas pmx
	hlt
	add zro
	sas pmx
	hlt	/error

	cla
	add nmx	/400000
	sas nmx
	hlt	/error
	add zro
	sas nmx
	hlt	/error
	szo	/should be no overflow
	hlt	/error
	add pmx	/-nmx
	sza
	hlt	/error

	lac zoz	/252525
	add zoz	/set overflow, check carry
	sas ozo	/525252
	hlt	/error
	szo i	/overflow should be on
	hlt	/error

	lac ab	/125252
	add ab	/check carry for even ac bits
	sas ac	/252524
	hlt	/error

	lac ons
	add zro
	sza	/-0 should clear
	hlt	/error



	szo
	hlt	/error
	cma
	add ad	/000001
	sas ad
	hlt	/error
	szo	/should be off
	hlt	/error

		lac ozo	/525252
	add ons	/-0
	sas ozo
	hlt	/error

	lac zoz	/252525
	add ons
	sas zoz
	hlt	/error

	szo	/still should be off
	hlt	/error

/end of add test

	cla	/initialize
	dac tmp	/for sub test
	cma

/begin test of sub

lp,	sub mon	/-1
	dac qem
	idx tmp
	sas qem
	hlt	/error

	sas zro	/loop for 777777 times
	jmp lp

/end of sub test

	szs 20	/if up,
	jmp stt 2
	jmp 7772	/read in next test

ons,	777777
zro,	000000
pmx,	377777
nmx,	400000
zoz,	252525
ozo,	525252
ab,	125252
ac,	252524
ad,	000001
mon,	777776
tmp,	000000
qem,	000000

start stt
                
                                
13
/part 13
/test law, cli

readin
0/

	13	/program number
stt,	szs 10	/if sw1 up
	hlt	/halt after read-in

/begin test of law

	clc	/all ones to ac

	law 0
	sza
	hlt	/error

	law 7777
	sas ck
	hlt	/error

	law i 0	/test law with complement
	cma
	sza
	hlt	/error

	law i 7777
	sas dk
	hlt	/error

/start cli test

	clc
	dac tmp
	lio tmp	/load io with all ones

	cli	/check cli with all 1s
	dio tmp
	lac tmp
	sza
	hlt	/error

	cli	/check cli with all 0s
	dio tmp
	lac tmp
	sza
	hlt	/error

/end of tests

	szs 20
	jmp stt 2
	jmp 7772

tmp,	0
ck,	7777
dk,	770000

start stt
                
                                
14
/part 14
/test clf, stf, szf

readin
0/

	14	/program number
stt,	szs 10	/if sw1 up,
	hlt	/halt after read-in

/begin tests

	clf 7	/clear all flags
	szf 7
	hlt	/error

	lac e	/initialize all instructions
	dap a 1	/for flag 1
	lac f
	dap a 2
	dap c 1
	dap c 2

	lac cde	/set up count loop
	dac abc	/for stf test

xa,	law a 1	/set up time delay
a,	jmp cnt 1

	stf 1	/start test with flag 1
	szf i 1
	hlt	/error

	idx a 1	/next flag
	idx a 2
	isp abc
	jmp xa

	law b	/introduce another time delay
	jmp cnt 1

b,	clf 7	/clear all flags
	szf 7
	hlt	/error

	law b 5	/another time delay
	jmp cnt 1

	stf 7	/set all flags
	szf i 7
	hlt	/error

/clf tests

	lac cde	/set up loop for 6 flags
	dac abc

xc,	law c 1	/time delay
c,	jmp cnt 1







	clf 1	/start test with flag 1
	szf 1
	hlt	/error

	idx c 1	/next flag
	idx c 2
	isp abc
	jmp xc

/end of tests for part 14

	szs 20	/if up
	jmp stt 2	/program iterates
	jmp 7766	/clear memory for next test

/random junk

cnt,	000000	/routine to introduce time delay
	dap cnt 6
	lac mxx
	dac cnt
	isp cnt
	jmp cnt 4
	jmp .

e,	11
f,	1
mxx,	700000
abc,	0
cde,	777771

/memory killer routine

7765/

	770013
zro,	dzm 0
	idx zro
	isp 7765
	jmp zro

foo,

start stt
                
                                
15
/part 15
/test jsp, jda, cal

readin
0/

	15	/program number
stt,	szs 10	/if sw1 up
	hlt	/halt after read-in

	szo	/clear overflow
	szo i
	jmp tt1	/first jsp test

/beginning of tests

16/

tt1,	lac num	/initialize ac to 777757
jp1,	jsp ck1	/go to first jsp test

32/

tt4,	lac num 3	/000040
	dac ck4		/jda address

	szo	/clear overflow
	szo i

	lac num 4	/771737
jd1,	jda ck4		/first jda test

/following is for cal test

100/

	0	/stores ac after cal
	and msk
	dac tmp
	law ca1 1
	sas tmp	/see if pc was properly saved
	hlt	/cal error
	lac 100	/check to see if ac saved
	sas ons
	hlt	/error

/end of part 15

	szs 20
	jmp stt 2
	jmp 7772	/read in next test

/test numbers, constants, and temporary storage

ons,	777777
ofl,	400000
tmp,	0
msk,	007777
num,	777757	776020	771677	000040
	771737	006040	006000	771777






/now a few macros

define jpmac m,n
ck'm,	and msk
	dac tmp
	law jp'm 1
	sas tmp
	hlt
	jmp tt'n
terminate

define jdmac m,n,p,q
ck'm,	0
	and msk
	dac tmp
	law jd'n 1
	sas tmp
	hlt
	lac ck'm
	sas num p
	hlt
	jmp tt'q
terminate

737/	jdmac 4,1,4,5

757/	jpmac 1,2

1000/	jdmac 6,3,7,7

1100/	jpmac 3,4

1731/

tt5,	lac tt5	/turn on the
	add tt5	/overflow flip-flop

	lac num 4	/771737
	dac ck5		/address of 2nd jda

	lac num 5	/006040
jd2,	jda ck5		/second jda test

1755/

tt2,	lac num 1	/776020
jp2,	jsp ck2

3000/

tt7,	clc	/word of ones
ca1,	cal	/test of cal

5772/
tt6,	szo	/clears overflow
	szo i

	lac num 6	/006000
	dac ck6		/address of third jda

	lac num 7	/771777
jd3,	jda ck6		/third jda test





6020/	jpmac 2,3

6040/	jdmac 5,2,5,6

6076/

tt3,	lac num 2	/771677
jp3,	jsp ck3		/third jsp test

/end of program for part 15

foo,

start stt
                
                                
16
/part 16
/test nop, xct, and deferred addressing

readin
0/

	16	/program number
stt,	szs 10	/if sw1 up,
	hlt	/halt after read-in

/begin tests

	nop	/if computer halts, nop failed

	xct ins	/if this fails,
	hlt	/computer halts

t1,	dzm i t2	/beginning of indirect address chain
t2,	dzm i t3
t3,	dzm i t4
t4,	dzm i t5
t5,	dzm t6

t6,	777777

ins,	jmp nxt	/executed by xct

nxt,	cla	/clear ac and check indirect addressing
	lac i t1
	sas t6
	hlt	/error

/end of part 16

	szs 20	/if up
	jmp stt 2	/program iterates
	jmp 7772	/next test

foo,

start stt
                
                                
17
/part 17
/test ral, ril, rar, rir, rcl, rcr

readin
0/

	17	/program number
stt,	szs 10	/if up
	hlt	/halt after read-in

/start of ral 1s and ril 1s tests.

	lac al1	/set up
	dac lsh
	lac il1
	dac lsh 1
	law tst 1
	dap lsh 2

	lio tst

lpl,	dio tmp	/set ac equal to io
	lac tmp

lsh,	ral .	/rotate one.  different bit each time

	ril .	/different bit each time

	sas .	/test ac rotation
	hlt	/error

	dio tmp	/test io rotation
	sas tmp
	hlt	/ril error

	lac lsh
	and msk	/change the address in ral instruction
	add lsh
	sad lsl
	jmp spr	/jmp out of loop
	dac lsh	/otherwise, set up next ral

	lac lsh 1
	and msk	/set up next ril also
	add lsh 1
	dac lsh 1

	idx lsh 2	/set sas instruction
	jmp lpl		/return to loop

/start of rar and rir tests

spr,	lac ar1	/set up loop for right rotation
	dac rsh
	lac ir1
	dac rsh 1
	law tst 10
	dap rsh 2

	lio tst 11

lpr,	dio tmp	/set ac equal to io
	lac tmp



rsh,	rar .	/one right, different bit each time

	rir .	/different bit each time

	sas .	/check ac rotation
	hlt	/rar error

	dio tmp	/check io rotation
	sas tmp
	hlt	/rir error

	lac rsh	/move the addresses of rar and rir
	and msk
	add rsh
	sad lsr
	jmp nxt	/done with loop
	dac rsh	/not done, set up next rar

	lac rsh 1
	and msk	/set up next rir
	add rsh 1
	dac rsh 1

	lac rsh 2
	sub one	/update sas instruction
	dac rsh 2

	jmp lpr	/return to loop

/start of 9-bit rotation test

nxt,	lac tst	/load ac and io
	lio tst	/with test number

	ral 9s
	ril 9s

	sas tst 11	/check correct ac rotation
	hlt		/error

	dio tmp		/check correct io rotation
	sas tmp
	hlt		/error

	rar 9s
	rir 9s

	sas tst		/check correct ac rotation right
	hlt		/error

	dio tmp		/test io rotation
	sas tmp
	hlt		/error

	lac tst 11
	rcl 9s	/9-bit combined rotation
	sas ttc	/check correct ac contents
	hlt	/error

	lac ttc 1
	dio tmp	/check correct io contents
	sas tmp
	hlt	/error





	lac ttc	/set up combined right 9s
	rcr 9s
	sas tst 11	/check correct ac contents
	hlt

	lac tst
	dio tmp
	sas tmp	/check correct io contents
	hlt

/start of 0 bit rotation tests

	ral
	ril

	sas tst	/check no rotation
	hlt	/error

	dio tmp
	sas tmp	/check no rotation of io
	hlt

	rar
	rir

	sas tst	/check no ac rotation
	hlt

	dio tmp
	sas tmp	/check no io rotation
	hlt

	rcl

	sas tst	/check for correct ac
	hlt

	dio tmp
	sas tmp	/check correct io contents
	hlt

	rcr

	sas tst	/check correct ac
	hlt

	dio tmp
	sas tmp	/check correct io
	hlt













/start of rcl 9s high speed test

	law flp	/set up loop
	dap fls	/for fast rotation

	lac num	/set up count
	dac cnt	/of loops

fls,	lio .	/load with test number

fsl,	dio tmp	/set ac to io
	lac tmp

	repeat 4, rcl 9s

	sas i fls
	hlt	/error, ac changed

	dio tmp
	sas tmp
	hlt	/error, io changed

	isp cnt	/leave loop after executing
	jmp fsl	/777 times

	lac num	/set up count
	dac cnt	/for high-speed rcr 9s test

fsr,	dio tmp	/set ac to io
	lac tmp

	repeat 4, rcr 9s

	sas i fls
	hlt	/error, ac changed

	dio tmp
	sas tmp
	hlt	/error, io changed

	isp cnt	/leave loop after executing
	jmp fsr	/777 times

	lac num	/start of rcl 9s-rcr 9s high speed test
	dac cnt	/set up loop count

rvs,	dio tmp	/set ac to io
	lac tmp

	repeat 4, rcr 9s	rcl 9s

	sas i fls	/check for correct ac
	hlt		/error

	dio tmp		/check correct io
	sas tmp
	hlt		/error

	isp cnt	/leave loop after execution
	jmp rvs	/777 times









	idx fls	/set up next test number
	sas fin	/if not finished
	jmp fls	/return for another fast loop

/end of part 17

	szs 20	/if sw2 up
	jmp stt 2	/program iterates
	jmp 7772	/read in next test

/constants, test numbers, and temporary storage

al1,	661001
il1,	662001
ar1,	671001
ir1,	672001
tmp,	0
flp,	000000
	777777
one,	000001
	777776
	525252
	525254
num,	777000
cnt,	0
msk,	000777
lsl,	662000
lsr,	672000
fin,	lio flp 6
tst,	777070
	776161
	774343
	770707
	761617
	743437
	707077
	616177
	434377
	070777
	777777
ttc,	777777
	070070

foo,

start stt
                
                                
20
/part 20
/test sal, sil, sar, sir, scl, scr

readin
0/

	20	/program number
stt,	szs 10	/if sw1 up,
	hlt	/halt after read-in

/begin tests

	lac tst	/load ac and io
	lio tst	/with 377777

	sal 9s	/move ac left
	sal 8s	/17 bits

	sil 9s	/same with io
	sil 8s

	sza	/ac should now be 0
	hlt	/error

	dio tmp	/same with io
	sas tmp
	hlt	/error

/tests of sar and sir

	lac tst	/377777
	lio tst

	sar 9s
	sar 8s
	sir 9s
	sir 8s

	sza	/ac and io should both be 0
	hlt	/error

	dio tmp
	sas tmp
	hlt	/error

	lac tst 5	/400000
	lio tst 5

	sar 9s
	sar 8s
	sir 9s
	sir 8s

	cma	/ac should be all 1s
	sza
	hlt	/error

	cma
	dio tmp
	sas tmp	/same with io
	hlt	/error







/begin tests of scl and scr

	lac tst	/377777
	lio tst

	scl 1s	/combined shift

	sas tst 1
	hlt	/error

	dio tmp	/io should be 777776
	lac tst 2
	sas tmp
	hlt	/error

	lac tst	/scr test now
	lio tst

	scr 1s

	sas tst 3	/177777
	hlt		/error

	dio tmp
	lac tst 4
	sas tmp
	hlt	/error

/end of part 20

	szs 20	/if up
	jmp stt 2	/iterate
	jmp 7772	/read in next test

/random junk

tst,	377777
	377776
	777776
	177777
	577777
	400000
tmp,	0

foo,

start stt
                
                                
21
/part 21
/test adm

readin
0/

	21	/program number
stt,	szs 10	/if sw1 up
	hlt	/halt after read-in

/begin test of adm
/similar to test of add

	clo	/clear overflow flip-flop
	skp i	/clo should never skip
	hlt	/big error

	cla	/check add of 0s to 0s
	dac tmp
	adm tmp
	sas tmp	/ac should be same as storage
	hlt
	sza
	hlt	/error

	lac pmx	/check add of 377777 to 000000
	adm tmp
	sas tmp
	hlt	/error
	sas pmx
	hlt	/error

	cla	/check add of 000000 to 377777
	adm tmp
	sas tmp
	hlt	/error
	sas pmx
	hlt	/error

	dzm tmp	/check add of 400000 to 000000
	lac nmx
	adm tmp
	sas tmp
	hlt	/error
	sas nmx
	hlt	/error

	cla	/check add of 000000 to 400000
	adm tmp
	sas tmp
	hlt	/error
	sas nmx
	hlt	/error

	szo	/overflow should be 0 up to now
	hlt	/overflow error

	lac pmx	/add 377777 to 400000
	adm tmp
	sas tmp
	hlt	/error






	sza	/result should be plus 0
	hlt	/error

	lac zoz	/252525
	dac tmp
	adm tmp
	sas tmp
	hlt	/error
	sas ozo	/525252
	hlt	/error

	szo i	/overflow should be on now
	hlt	/overflow error

	lac ab	/125252
	dac tmp
	adm tmp
	sas tmp
	hlt	/error
	sas ac	/252524
	hlt	/error

	lac ons	/777777
	dac tmp
	cla
	adm tmp	/check clear of -0
	sas tmp
	hlt	/error
	sza
	hlt	/error

	szo	/overflow should be off
	hlt	/error

	cma	/-0
	dac tmp
	lac ad	/1
	adm tmp
	sas tmp
	hlt	/error
	sas ad
	hlt	/error

	szo	/overflow should be off
	hlt	/error

	lac ozo	/525252
	dac tmp
	lac ons	/-0
	adm tmp
	sas tmp
	hlt	/error
	sas ozo
	hlt	/error

	lac zoz	/252525
	dac tmp
	lac ons	/-0
	adm tmp
	sas tmp





	hlt	/error
	sas zoz
	hlt	/error

	szo	/overflow should be off
	hlt	/error

/end of adm test

	szs 20	/if sense switch 2 up,
	jmp stt 2	/iterate program
	jmp 7772	/read in next test program

/storage and constants

ons,	777777
zro,	000000
pmx,	377777
nmx,	400000
zoz,	252525
ozo,	525252
ab,	125252
ac,	252524
ad,	000001
tmp,	0

/end of program

foo,

start stt
                
                                
22
/part 22
/test lia, lai, swp, and sni
/also zero memory for jdp test of part 23

readin
0/

	22	/program number
stt,	szs 10	/if up,
	hlt	/halt after read-in

/start of tests
/test lia and lai

	cla>>05<<cli	/clear ac and io simultaneously
	lia	/test lia of 0s to 0s
	dio tmp
	sas tmp
	hlt	/ac must be same as io
	sza
	hlt	/error, lia changes ac

	lai	/test lai of 0s to 0s
	dio tmp
	sas tmp	/ac should equal io
	hlt	/error
	sza
	hlt	/error

	lio ons	/777777
	lia	/test lia of 0s into 1s
	dio tmp
	sas tmp
	hlt
	sza
	hlt	/error

	cma
	lai	/test lai of 0s into 1s
	dio tmp
	sas tmp
	hlt	/error
	sza
	hlt	/error

	cma
	lia	/test lia of 1s into 0s
	dio tmp
	sas tmp
	hlt	/error
	sas ons
	hlt	/error

	cla
	lai	/test lai of 1s into 0s
	dio tmp
	sas tmp
	hlt	/error
	sas ons
	hlt	/error







	lia	/test lia of 1s into 1s
	dio tmp
	sas tmp
	hlt	/error
	sas ons
	hlt	/error

	lai	/test lai of 1s into 1s
	dio tmp
	sas tmp
	hlt	/error
	sas ons
	hlt	/error

/test of swap

	cla>>05<<cli	/clears ac and io simultaneously
	swp	/swap ac and io
	sza
	hlt	/error
	lai
	sza
	hlt	/error

	cma
	swp	/test swap of 1s for 0s
	sza
	hlt	/error
	lai	sas ons
	hlt	/error

	cla
	swp	/test swap of 0s for 1s
	sas ons
	hlt	/error
	lai
	sza
	hlt	/error

	cla>>05<<cma>>05<<lia	/should load ac and io with 1s
	swp	/test swap of 1s for 1s
	sas ons
	hlt	/error
	lai
	sas ons
	hlt	/error

/test sni--skip on non-zero io

	lio ons	/777777
	sni	/should skip
	hlt	/error in sni
	sni i	/should not skip
	skp i	/ok
	hlt	/error










	cli	/0s to io
	sni	/should not skip
	skp i	/ok
	hlt	/error
	sni i	/should skip
	hlt	/error

/end of tests for part 22

	szs 20		/if up
	jmp stt 2	/program iterates
	jmp 7766		/zero memory for next program

/random constants

ons,	777777
tmp,	0

/section to  zero memory

7765/

	770012	/this is -7765
zrm,	dzm 0
	idx zrm
	isp 7765
	jmp zrm

/rim loader just above this

/end of program

foo,

start stt
                
                                
23
/part 23
/test jdp and lap
/memory zeroed by part 22.
/best test of wild jump

0/
readin

define	lap	jsp .+1	termin

	23	/program number
stt,	szs 10	/if switch 1 up
	hlt	/halt after read-in

/begin tests

	cla	/test lap with zeroed ac first
	dac 3000	/also zero pc location for jdp
	lap	/first test of lap
	add thr	/add 3.  coincides with jdp test
	dac tmp	/save

jd1,	jdp 3000	/first test of jdp
	hlt	/error, jump failed

3000/

	0	/location for pc and garbage
	sas tmp	/be sure ac was not changed
	hlt	/error
	sas 3000	/ac and 3000 should agree
	hlt	/error
	law jd1 1
	xor 3000
	and msk	/get rid of garbage
	sza
	hlt	/error, pc not correctly saved

	clc	/777777 to ac
	dac 4777	/test save of pc into ones
	lap	/second lap test
	add thr	/thr is 3
	dac tmp

jd2,	jdp 4777	/second test of jdp
	hlt	/error, jump failed

4777/

	0	/location for pc and garbage
	sas tmp	/be sure ac was not changed
	hlt	/error
	sas 4777
	hlt	/error
	law jd2 1
	xor 4777
	and msk	/mask out garbage
	sza
	hlt	/error

	lap	/third test of lap
	add fiv	/5
	dac tmp	/save for test





	dac 6000	/location for pc for next jdp
	cla	/this time, clear ac

jd3,	jdp 6000	/third and final jdp test
	hlt	/in case of error

6000/

	0	/location for pc and garbage
	sza	/if ac was changed,
	hlt	/big error--halt
	lac 6000	/get saved pc
	sas tmp	/should agree with last lap plus 5
	hlt	/error
	law jd3 1
	xor 6000
	and msk	/remove garbage
	sza
	hlt	/error

/end of jdp tests

	szs 20		/if switch 2 up,
	jmp stt 2	/jump back for iteration
	jmp 7772		/read in next test

/random constants

thr,	3
fiv,	5
msk,	7777
tmp,	0

/end of program

foo,

start stt
                
                                
24
/part 24
/test mul, div
readin

0/

	24	/program number
stt,	szs 10	/if switch 1 up,
	hlt	/halt after read-in

/begin test of mul--multiply
/test zero-result multiplication

	cla>>05<<cli	/simultaneously clear ac and io
	jdp mt1	/go to first mul test routine
	cla>>05<<cli>>05<<cma	/-0 to ac, 0 to io
	jdp mt1
	cla>>05<<cli>>05<<cma>>05<<swp	/0 to ac, -0 to io
	jdp mt1
	cla>>05<<cma>>05<<lia	/-0 to ac and io
	jdp mt1

	lac pmx	/377777
	cli
	jdp mt1	/test 0x377777
	lac pmx
	lio ons
	jdp mt1	/-0 times 377777
	cla
	lio pmx
	jdp mt1	/commutative?
	lac ons
	lio pmx
	jdp mt1

	lac nmx	/400000
	cli
	jdp mt1	/0 times 400000
	lac nmx
	lio ons
	jdp mt1
	cla
	lio nmx
	jdp mt1
	lac ons
	lio nmx
	jdp mt1	/final zero product test

/test multiplication with 1 and -1
/test mul with +1

	lac zoz	/252525
	dac tmp
	lio pon	/000001
	jdp mt2	/go to econd mul routine
	lio zoz	/should be commutative
	lac pon
	jdp mt2









                
                                	lac ozo	/525252
	dac tmp
	lio pon	/000001
	jdp mt2
	lio ozo	/commutative
	lac pon
	jdp mt2	/last +1 test

/test mul with -1

	lac ozo	/-252525
	dac tmp
	cma	/252525
	lio mon	/-1
	jdp mt2	/-1x252525
lio zoz	/252525
	lac mon	/-1
	jdp mt2

	lac zoz	/-525252
	dac tmp
	cma	/525252
	lio mon	/-1
	jdp mt2
	lio ozo	/525252
	lac mon	/-1
	jdp mt2	/last -1 test

/random multiply tests

	lac zoz	/252525
	mul two	/000002
	scr 1s	/remove sign from io 17
	sza	/ac should be 0
	hlt	/error
	swp	/to ac
	sas ozo	/525252
	hlt	/error

	mul two	/2x525252
	scr 1s
	sas ons	/ac should be -0
	hlt	/error
	swp
	sas zoz	/252525
	hlt	/error

	lac two	/2
	mul zoz	/252525
	scr 1s
	sza	/ac should be 0
	hlt	/error
	swp
	sas ozo	/525252
	hlt	/error

	lac two	/2
	mul ozo	/525252
	scr 1s
	sas ons	/ac should be -0
                
                                	hlt	/error

	swp	/io to ac
	sas zoz	/252525
	hlt	/error

	lac pmx	/377777
	mul two	/2
	scr 1s
	sza	/ac should now be 0
	hlt	/error
	swp
	sas mon	/777776
	hlt	/error

	lac nmx	/400000
	mul two	/2
	scr 1s
	sas ons	/ac should now be -0
	hlt	/error
	swp
	sas pon	/1
	hlt	/error

	lac pmx	/377777
	mul pmx	/by self
	sas tt1	/377776
	hlt	/error
	lai
	sas two	/2
	hlt	/error

	lac pmx	/377777
	mul nmx	/-377777
	cma	/should be complement of above test
	sas tt1	/377776
	hlt	/error
	lai
	cma
	sas two	/2
	hlt	/error

	lac nmx	/-377777
	mul nmx	/-377777
	sas tt1
	hlt	/same as 377777x377777
	lai
	sas two
	hlt	/error

/end of multiply tests
                
                                /begin test of div--divide instruction

	cla>>05<<cli	/clear ac and io
	div pon	/1
	hlt	/error, div failed to skip
	sza	/ac and io should be 0
	hlt	/error
	sni i
	hlt	/error
	lio two	/1.ls.1s
	div pon	/1
	hlt	/failed to skip
	sni i	/remainder is 0
	hlt	/error
	sas pon	/quotient is 1
	hlt	/error
	ior two	/make it 3
	cli>>05<<swp	/dividend of 1
	div pon
	hlt	/error
	sas pon	/io bit 17 should have been ignored
	hlt	/error
	sni i	/no remainder
	hlt	/error
	swp	/0 to ac, 1 to io
	div pon
	hlt	/error, no skip
	sza	/io bit 17 should be ignored
	hlt	/error
	sni i
	hlt	/error

	lio two	/dividend of 1
	div two
	hlt	/error, no skip
	sza	/quotient should be 0
	hlt	/error
	lai
	sas pon	/remainder should be 1
	hlt	/error

	cla
	lio two	/dividend of 1
	div mtw	/-2
	hlt	/error
	sza	/quotient is0
	hlt	/error
	lai
	sas pon	/note sign of remainder is sign of quo.
	hlt	/error

	cla>>05<<cma>>05<<lia	/-0 to ac and io
	div pon
	hlt	/error
	sza	/results should be plus 0
	hlt	/error
	sni i
	hlt	/error
                
                                	lio ozo	/dividend is zoz
	div zoz
	hlt	/error
	sni i	/remainder is 0
	hlt	/error
	sas pon	/quotient is 1
	hlt	/error

	cla
	lio ozo	/dividend is 252525
	div ozo	/-252525
	hlt	/error
	sni i	/remainder of 0
	hlt	/error
	sas mon	/777776
	hlt	/error

	cla
	lio zoz	/dividend is 125252
	div zoz	/252525
	hlt	/error
	sza	/quotient is 0
	hlt	/error
	lai
	sas ab	/125252
	hlt	/error in remainder

	lac pmx	/377777
	mul pon	/dividend of 377777
	div pmx	/377777
	hlt	/error
	sni i
	hlt	/error
	sas pon
	hlt	/error

	lac pmx
	mul pon
	div nmx	/pmx
	hlt	/error
	sni i	/remainder of 0
	hlt	/error
	sas mon	/-1
	hlt	/error

	lac zoz	/252525
	mul pon	/dividend of 25525
	div two	/2
	hlt	/error
	sas ab	/125252
	hlt	/error
	lai
	sas pon	/remainder of 1
	hlt	/error

	lac zoz	/252525
	mul mon	/-1
	div two	/2
	hlt	/error
	cma	/complement of last test
                
                                	sas ab	/125252
	hlt	/error
	lai
	sas mon	/-1
	hlt	/error





























































                
                                /test divide failure

	cla>>05<<cli	/clear ac and io
	div zro
	skp i	/this should fail to divide
	hlt	/error, should not skip
	sza	/ac and io should be unchanged
	hlt	/error
	sni i
	hlt	/error
	div ons	/-0
	skp i
	hlt	/error
	sza
	hlt	/error
	sni i
	hlt	/eror
	cma>>05<<lia	/-0 to ac and io
	div zro
	skp i
	hlt	/error
	sza	/ac shud be changed to +0
	hlt	/error
	lai	/but io should still
	sas ons	/be -0
	hlt	/error

	div ons	/-0
	skp i
	hlt	/error
	sza	/agan, ac should be changed to +0
	hlt	/error
	lai
	sas ons	/again, io should be unchanged
	hlt	/error

	cli
	lac pon	/1 to ac
	div pon	/should fail to divide
	skp i
	hlt	/error
	sas pon	/ac and io should be unchanged
	hlt	/error
	sni i
	hlt	/error

	lac mon	/-1
	div pon	/should fail
	skp i
	hlt	/error
	sas mon
	hlt	/error
	sni i
	hlt	/error
                
                                /end of part 24

	szs 20		/if up
	jmp stt 2	/program iterates
	jmp zm		/otherwise, zero memory

/multiply routines

mt1,	0	/called by jdp
	dio mpr
	mul mpr
	sza	hlt	/error
	sni i
	hlt	/error
	jmp i mt1	/return

mt2,	0	/called by jdp
	dio mpr
	mul mpr
	scr 1s
	spa
	cma
	sza
	hlt	/error
	lai
	sas tmp
	hlt	/error
	jmp i mt2	/return

/random constants and storage

zro,	0
ons,	777777
pon,	1
mon,	777776
pmx,	377777
nmx,	400000
zoz,	252525
ozo,	525252
mpr,	0
tmp,	0
ab,	125252
two,	2
mtw,	777775
tt1,	377776

                
                                /zm, routine to zero memory in cores 1 and 2
/this is setup for part 25--extend mode test

7742/

ct1,	-7742	/count
ct2,	-2	/for 2 cores
ptr,	10000	/pointer to core 1
zm,	eem	/must be in extend mode
dz,	dzm i ptr
	idx ptr
	isp ct1
	jmp dz

rim,	rpb	/read-in mode simulator
	lai
	dap ptr
	spi	/if negative,
	jmp jp	/must be a jump
	rpb	/positive
	dio i ptr
	jmp rim

jp,	law i 7742	/restore count
	dac ct1
	dzm ptr	/core 0
	isp ct2	/count for 2 cores
	jmp dz	/one more left
	lai	/done, set address
	dap ptr
	jmp i ptr	/go to next test

7772/

/end of program

foo,

start stt
                
                                25a

25
/part 25a
/test extend mode
/program for core 1


readin
0/	25	/program number

100/	lac i e1	/initial entry from core 0
	sas t1	/if not same,
	hlt	/error
	lac i e2
	sas t2
	hlt	/error
	lac i e3
	sas t3
	hlt	/error
	add i e4	/777000+000777
	sza
	hlt	/error

	lem	/leave extend mode
	jmp i i1	/see that you stay in core 1
	hlt	/error if jump fails

/constants for core 0

200/

t1,	000000
t2,	777777
t3,	777000
t4,	000777

/extend mode pointers

e1,	201	/core 0
e2,	200
e3,	203
e4,	202
e5,	i 6000	/core 1
e6,	3000	/core 0

/indirect pointers for non-extend mode

i1,	i i2
i2,	i i3
i3,	i i4
i4,	4777	/in same core

3000/	hlt	/halt for incorrect jump

4777/	eem	/re-enter extend mode
	jmp i e5	/extended address in same core
	hlt	/in case jump fails

6000/	law 3000	/points to halt for incorrect jump
	jmp i e6	/return to core 0
	hlt	/in case of jump failure

/end of core 1 program
start 100
                
                                25b
/part 25b
/test extend mode
/program for core 0
/computer halts with main console
/in following condition...
/pc=000001   ma=000000   mb=000025   ac=000777
/            io=777000   pf=all on

readin
0/

	25	/program number
stt,	szs 10	/if sw 1 up,
	hlt	/halt after read-in

/begin tests

	eem	/enter extend mode
	lac i e1	/location of 0s in core 1
	sas t1	/if not 0,
	hlt	/error
	lac i e2
	sas t2
	hlt	/error
	lac i e3	/777000
	sas t3	/if not same,
	hlt	/error
	add i e4	/000777
	sza
	hlt	/error

	lem	/leave extend mode
	jmp i i1	/see that i bit specifies indirection
	hlt	/in case jump fails

/entry to core 1

100/	jmp i .	/go to 100 in core 1
	hlt	/in case jump failed

/constants for core 1

200/

t2,	777777
t1,	000000
t4,	000777
t3,	777000

/extend mode pointers

e1,	i 200	/core 1
e2,	i 201
e3,	i 202
e4,	i 203
e5,	6000	/core 0
e6,	100	/core 0








/indirect pointers for non-extend mode

i1,	i i2
i2,	i i3
i3,	i i4
i4,	4777

/random constant

tst,	3000

3000/	sas tst	/entry from core 1
	hlt	/error

/end of program

	szs 20	/if sw 2 up,
	jmp stt 2	/program iterates

	jmp 7772

/random jump routines in and out of extend mode

4777/	eem	/enter extend mode
	jmp i e5	/extended address in same core
	hlt	/in case jump failed

6000/	xct i e6	/execute entry to core 1
	hlt	/failed to jump

/end of program
/end of instruction test

foo,

start stt
                
                                
26
/part 26
/test cmi

readin
0/
	26
stt,	szs 10
	hlt
	cli>>05<<cmi>>05<<lai
	sas ons
	hlt	/failled to complement a +0
	cmi
	sni i
	hlt	/failled to complement a -0
	lio ozo	/525252
	cmi>>05<<lai
	sas zoz
	hlt	/not 252525
	cmi>>05<<lai
	sas ozo
	hlt

	cli>>05<<cmi>>05<<cla
	rcl 9s
	xct
	jmp 7772

zoz,	252525
ozo,	525252
ons,	777777
	start stt
                
                             h
