# Operands WORD_174 WORD_186 # Multiplication routine # Restrictions: # Positive numbers only (31 shifts max since operands are twos-complement) # No overflow checking multiply WORD_2147483648 # For use in setting sign for left shifts. IM_0 # For magnitude of left/right shifts. LDSP+0 # Sets up stack location to build/store result. #----- testbit # LDSP+3 # LDSP+2 # SHIFT # Check Nth bit of second operand. IM_1 # AND # TEST # #----- BRZ>skipadd # LDSP+4 # LDSP+3 # LDSP+3 # OR # Shift and add first operand to result if indicated. SHIFT # ADD # skipadd # #----- LDSP+1 # IM_1 # Increment counter for shift magnitude ADD # STSP+1 # #----- IM_30 # NOT # IM_1 # ADD # Test for completion of multiplication subroutine (31 shifts). LDSP+2 # ADD # TEST # BRZ>cleanup # If finished, cleanup and return from subroutine with result on TOS. #----- IM_0 # TEST # If not finished, repeat this process on the next bit. BRZ>testbit # #----- cleanup # STSP+0 # STSP+0 # STSP+0 # Remove all subroutine temporaries from stack and return result on TOS. STSP+0 # HALT #