MovE 3 i Transfer multiplicands to working registers Mov 4 j Clr 2 Clear cumulative sum Clr 1 Clear sign flag FindSReg 3 Move to significant end of first mult. R2 Find most significant bit `0 0 0 R :L0:; 0 1 1 R 1' If it is 1, the number is negative FindStart Neg 3 so negate it Inc 1 and toggle sign flag Goto :L1: :L0: FindStart :L1: FindSReg 4 Same for second mult. R2 `0 0 0 R :L2:; 0 1 1 R 1' FindStart Neg 4 Inc 1 Goto :L3: :L2: FindStart :L3: FindReg 4 Move to least significant end of first mult. L2 Move to actual bit :L4: L Write 1 Leave mark R `0 0 0 L 1; 0 1 1 L :L6:' Decide whether we need to add in this time L FindStart We don't -- just shift second mult. :L5: Shl 3 Goto :L7: :L6: FindStart Bit is 1 -- add in shifted mult. to cum. sum Add 2 3 Goto :L5: and jump to shifting code :L7: Rto 2 1 ... (4 times) Find start of first mult. Rto 2 1 `0 0 0 R 1; 0 1 0 L :L8:' If that was the last bit then go to :L8: Rto 2 1 If not then find mark L Write 0 Erase it L3 Move to next bit of first mult. Goto :L4: and loop round :L8: FindStart FindReg 1 Find sign flag L2 `0 0 0 L 1; 0 1 1 L :L9:' If we must negate the result FindStart Goto :L10: :L9: L3 Neg 2 then do so :L10: Clr 5 Set up register 5 with 15 Not 5 :L11: Shr 2 Loop 5 :L11: Shift the result right 15 times (divide by 2^15) MovD i 2 Copy the result from working reg. to dest. reg.