         /part 24
/test mul, div

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
	so  /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



























                
                                                                                                  

