;--------------------------------------- ; A straight-forward version of multiplication ; reg. usage: R0-R4, DR, J2-J3 ; 32 instructions (with HALT) ; Timing: 54-57 (10 x 20); 28-102 (limits) ; --------------------------------------- ;------------- read original data READ R0,DD READ R1,DD ;------------- get sign info COPY R0,R2 COPY R1,R3 SHIFT R2, 5 SHIFT R2, 6 SHIFT R3, 5 SHIFT R3, 6 SUB R3,R2 ;-- R3 freed SHIFT R0,-1 SHIFT R0, 1 SHIFT R1,-1 SHIFT R1, 1 ;------------- set up loop DATA #SKIP COPY DR,J3 DATA #LOOP COPY DR,J2 #LOOP SET R3, 1 AND R1,R3 JPIF R3,EZ,J3 ADD R0,R4 #SKIP SHIFT R0,-1 SHIFT R1, 1 JPIF R1,NZ,J2 ;------------- negate R4 based on R2 DATA #DONE COPY DR,J3 JPIF R2,EZ,J3 ZERO R3 SUB R4,R3 COPY R3,R4 #DONE WRITE R4,DD HALT ; --------------------------------------- ; C00 C10 902 913 524 525 534 535 732 508 500 518 510 315 9ED 311 ; 9EC 231 813 E3B 605 508 510 E1E 31E 9ED E2B 130 753 935 D50 000 ; --------------------------------------- ;--------------------------------------- ; Multiplication based on PC arithmetricks ; reg. usage: R0-R4, DR, J2-J3 ; 31 instructions (with HALT) ; Timing: 52-54 (10 x 20); 26-99 (limits) ; --------------------------------------- ; ---------- read original data READ R0,DD READ R1,DD ; ---------- get sign info COPY R0,R2 COPY R1,R3 SHIFT R2, 5 SHIFT R2, 6 SHIFT R3, 5 SHIFT R3, 6 SUB R3,R2 ; -- R3 freed SHIFT R0,-1 SHIFT R0, 1 SHIFT R1,-1 SHIFT R1, 1 ; ----------- set up loop DATA #SKIP COPY DR,J3 COPY PC,J2 SET R3, 1 AND R1,R3 JPIF R3,EZ,J3 ADD R0,R4 #SKIP SHIFT R0,-1 SHIFT R1, 1 JPIF R1,NZ,J2 SHIFT R2,-1 ADD R2,PC WRITE R4,DD HALT ZERO R3 SUB R4,R3 WRITE R3,DD HALT ; --------------------------------------- ; C00 C10 902 913 524 525 534 535 732 508 500 518 510 314 9ED 9FC ; 231 813 E3B 604 508 510 E1E 528 62F D40 000 130 743 D30 000 ; --------------------------------------- ; Can replace the relevant portion here to save 1 in length ; at cost of 1 per run (but also saves one register) ; Could eliminate another J register (at some run-time cost) ; ----------- set up loop COPY PC,J2 SET R3, 1 AND R1,R3 ADD R3,PC INC PC, 1 ADD R0,R4 ADD R0,R4