revert between 56095 -> 55830 in arch
[AROS.git] / arch / m68k-all / utility / udivmod32.s
blobe8378cd397bab9c7334687a13c889b5d1a1c4393
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: unsigned 32 bit division/modulus functions for Amiga/m68k
6 Lang: english
7 */
9 #include "aros/m68k/asm.h"
11 .text
12 .balign 4
14 .globl AROS_SLIB_ENTRY(UDivMod32,Utility,26)
15 .globl AROS_SLIB_ENTRY(UDivMod32_020,Utility,26)
17 .type AROS_SLIB_ENTRY(UDivMod32,Utility,26),@function
18 .type AROS_SLIB_ENTRY(UDivMod32_020,Utility,26),@function
20 AROS_SLIB_ENTRY(UDivMod32_020,Utility,26):
21 divul.l %d1,%d1:%d0
22 rts
25 This next algorithm is from the ixemul 41.0 source, the file
26 ./ixemul-41.0/gnulib/common.h
29 .balign 4
30 AROS_SLIB_ENTRY(UDivMod32,Utility,26):
31 movem.l %d2-%d3,-(%sp)
32 cmp.l #0xFFFF,%d1
33 bhi.s .Lfull_division
34 move.l %d1,%d3
35 swap %d0
36 move.w %d0,%d3
37 beq.s .Lsmall_division
38 divu %d1,%d3
39 move.w %d3,%d0
40 .Lsmall_division:
41 swap %d0
42 move.w %d0,%d3
43 divu %d1,%d3
44 move.w %d3,%d0
45 swap %d3
46 move.w %d3,%d1
47 movem.l (%sp)+,%d2-%d3
48 rts
50 .Lfull_division:
51 move.l %d1,%d3
52 move.l %d0,%d1
53 clr.w %d1
54 swap %d0
55 swap %d1
56 clr.w %d0
57 moveq #0xF,%d2
58 .Lloop:
59 add.l %d0,%d0
60 addx.l %d1,%d1
61 cmp.l %d1,%d3
62 bhi.s .Lloopend
63 sub.l %d3,%d1
64 addq.w #1,%d0
65 .Lloopend:
66 dbra %d2,.Lloop
67 movem.l (%sp)+,%d2-%d3
68 rts