.NLIST .ENABL LC ; Enable lower case. .NLIST CND ; Don't list unsatisfied conditional assemblies. .LIST .TITLE DDIV - Double Precision Divide .IDENT /V01.1/ ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion of the above copyright notice. This software, or ; any other copies thereof, may not be provided or otherwise ; made available to any other person except for use on such ; system and to one who agrees to these license terms. Title ; to and ownership of the software shall at all times remain ; in Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. ; ++ ; FACILITY: ; ; Formatted Ascii Output ; ; ABSTRACT: ; ; The routine in this module performs double precision ; unsigned division. ; ; ENVIRONMENT: ; ; PDP-11 processor; no operating system specific facilities ; are needed. ; ; AUTHOR: ; ; Randy Black, CREATION DATE: 15-Jan-83 ; ; MODIFIED BY: ; ; modifiers name, dd-mmm-yy, VERSION: svv.u-ep ; 01 - modification description ; ; -- .SBTTL Module Declarations ; ; INCLUDE FILES: ; ; No include files referenced ; ; MACROS: ; .MACRO DEF$ name,expr=0,scope=NOGBL .DSABL CRF,LC .IF IDN GLOBAL, name == expr .IFF name = expr .ENDC .ENABL CRF,LC .ENDM DEF$ .MACRO POP$ args .IF B TST (SP)+ .IFF .IRP arg, MOV (SP)+,arg .ENDM .ENDC .ENDM POP$ .MACRO PUSH$ args .IRP arg, .IF IDN arg,#0 CLR -(SP) .IFF MOV arg,-(SP) .ENDC .ENDM .ENDM PUSH$ .MACRO PSECT$ prgsct,attr .LIST BEX .IF NB .PSECT prgsct,attr .IFF .PSECT prgsct .ENDC .NLIST BEX .ENDM PSECT$ ; ; EQUATED SYMBOLS: ; ; ; Miscellaneous Constants ; def$ NIL 0 GLOBAL ; Define 'nil' pointer value. ; ; OWN STORAGE: ; ; No local storage allocated in this module. ; ; EXTERNAL REFERENCES: ; ; No external references made in this module. .SBTTL DDIV - Double Precision Divide ; ++ ; FUNCTIONAL DESCRIPTION: ; ; This routine divides a double precision dividend by a single ; precision divisor yielding a double precision quotient and a ; single precision remainder. All operations are unsigned. ; ; CALLING SEQUENCE: ; ; CALL DDIV ; ; INPUT PARAMETERS: ; ; R0 - single precision divisor ; R1 - hi-order part of double precision dividend ; R2 - lo-order part of double precision dividend ; ; IMPLICIT INPUTS: ; ; ** None ** ; ; OUTPUT PARAMETERS: ; ; R0 - single precision remainder ; R1 - hi-order part of double precision quotient ; R2 - lo-order part of double precision quotient ; ; IMPLICIT OUTPUTS: ; ; ** None ** ; ; COMPLETION CODES: ; ; ** None ** ; ; SIDE EFFECTS: ; ; ** None ** ; ; -- psect$ lib$code, DDIV:: ; Entry point to DDIV routine. push$ R3 ; Save register R3. MOV #32.,R3 ; R3 <- division iteration count. push$ R0 ; Put divisor on stack. CLR R0 ; Set remainder to zero. 10$: ASL R2 ; Shift the entire dividend... ROL R1 ; ... one bit to the left and ... ROL R0 ; ... into the remainder CMP R0,(SP) ; Is remainder GEQ divisor? BLO 20$ ; If LO, - no, skip to iteration control. SUB (SP),R0 ; Otherwise, subtract divisor out INC R2 ; and increment the quotient. 20$: DEC R3 ; Repeat as long as necessary. BGT 10$ ; pop$ ; Purge divisor from stack. pop$ R3 ; Restore register R3. RETURN ; Return to caller. .END