4 ; Various routines of a division-related nature (MDW/TMA)
6 ; © 1994-1998 Straylight
9 ;----- Licensing note -------------------------------------------------------
11 ; This file is part of Straylight's Sapphire library.
13 ; Sapphire is free software; you can redistribute it and/or modify
14 ; it under the terms of the GNU General Public License as published by
15 ; the Free Software Foundation; either version 2, or (at your option)
18 ; Sapphire is distributed in the hope that it will be useful,
19 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ; GNU General Public License for more details.
23 ; You should have received a copy of the GNU General Public License
24 ; along with Sapphire. If not, write to the Free Software Foundation,
25 ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
27 ;----- Overview -------------------------------------------------------------
37 [ :LNOT::DEF:divide__dfn
42 ; On entry: R0 == dividend
45 ; On exit: R0 == quotient
48 ; Use: A standard divide routine. Fairly speedy, hopefully.
49 ; The results are always such that
51 ; |quotient| <= |(divisor/dividend)|,
53 ; |remainder| < |divisor|
57 ; quotient * divisor + remainder == dividend
61 ; --- div_unsigned ---
63 ; On entry: R0 == dividend
66 ; On exit: R0 == quotient
69 ; Use: As for divide, except that it considers its operands to be
76 ; On entry: R0 == integer to divide
78 ; On exit: R0 == quotient after division by 10
79 ; R1 == remainder after division by 10
81 ; Use: Divides an integer very quickly by 10.
83 ; [Generated by Straylight divc]
89 ; On entry: R0 == dividend
92 ; On exit: R0 == quotient, rounded to nearest integer
95 ; Use: Calculates a rounded-to-nearest quotient, rather than one
96 ; rounded towards zero, which is what divide returns you.
98 ; The remainder is fiddled during this process, so that the
101 ; quotient * divisor + remainder == dividend
105 ; |remainder| < |divisor|
107 ; still hold (so the remainder's sign may well change).
113 ; On entry: R0,R1 == dividend (high word in R1)
116 ; On exit: R0 == quotient
119 ; Use: Divides a 64-bit unsigned value by a 32-bit unsigned value
120 ; yielding 32-bit unsigned quotient and remainder. If there
121 ; are more than 32 bits of quotient, the return values are
128 ;----- That's all, folks ----------------------------------------------------