.TITLE DMUL .IDENT /V01/ .ENABLE LC ; ; This module multiplies a positive double-precision number by a single- ; precision multiplier, checkin for overflow during the operation. ; ; Author: V01 25-Jan-80 Phil Stephensen-Payne ; ; Calling Sequence: ; ; This module is only callable from MACRO-11 as: ; ; CALL DMUL ; ; Where: ; R0, on input = High-order word of Multiplicand ; R1, on input = Low-order word of Multiplicand ; R2, on input = Multiplier ; R0, on output = High-order word of result ; R1, on output = Low-order word of result ; R2, on output is unchanged ; ; Errors returned: ; ; C-bit is clear if the operation was successful ; C-bit is set if the result overflowed a doubleword ; DMUL:: JSR R5,$SAVRG ; Save the volatile registers MOV R0,R3 ;SAVE MULTIPLICAND MOV R1,R4 ; MOV #16.,R5 ;SET BIT COUNT CLR R0 ;INITIALISE RESULT CLR R1 ; ; 10$: ASL R1 ;MULTIPLY BY 2 ROL R0 ; BMI 40$ ;IF MI OVERFLOW - ERROR ROL R2 ;CHECK NEXT BIT IN MULTIPLIER BCC 20$ ;IF CC NOT SET - JUST DO MULTIPLY ADD R4,R1 ;SET - ADD MULTIPLICAND FIRST ADC R0 ;ADD CARRY BMI 40$ ;IF MI OVERFLOW - ERROR ADD R3,R0 ;ADD SECOND HALF OF MULTIPLICAND BMI 40$ ;IF MI OVERFLOW - ERROR ; 20$: SOB R5,10$ ;TRY NEXT BIT ; 30$: CLC ;SIGNAL SUCCESS BR 50$ ;EXIT ; 40$: CLR R0 ;CLEAR ANSWER CLR R1 ; SEC ;SIGNAL FAILURE ; 50$: RETURN .END