config: fix build with external compiler by passing the sysroot where needed
[AROS.git] / arch / .unmaintained / m68k-linux / utility / udivmod32.s
blob63c40d939b8014aa9545889e34e9a575955c82d6
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 "machine.i"
11 .text
12 .balign 16
13 .globl AROS_SLIB_ENTRY(UDivMod32,Utility)
14 .globl AROS_SLIB_ENTRY(UDivMod32_020,Utility)
16 .type AROS_SLIB_ENTRY(UDivMod32,Utility),@function
17 .type AROS_SLIB_ENTRY(UDivMod32_020,Utility),@function
19 AROS_SLIB_ENTRY(UDivMod32_020,Utility):
20 divul.l %d1,%d1:%d0
21 rts
24 This next algorithm is from the ixemul 41.0 source, the file
25 ./ixemul-41.0/gnulib/common.h
28 AROS_SLIB_ENTRY(UDivMod32,Utility):
29 movem.l %d2-%d3,-(%sp)
30 cmp.l #0xFFFF,%d1
31 jbhi .full_division
32 move.l %d1,%d3
33 swap %d0
34 move.w %d0,%d3
35 jbeq .small_division
36 divu %d1,%d3
37 move.w %d3,%d0
38 .small_division:
39 swap %d0
40 move.w %d0,%d3
41 divu %d1,%d3
42 move.w %d3,%d0
43 swap %d3
44 move.w %d3,%d1
45 movem.l (%sp)+,%d2-%d3
46 rts
48 .full_division:
49 move.l %d1,%d3
50 move.l %d0,%d1
51 clr.w %d1
52 swap %d0
53 swap %d1
54 clr.w %d0
55 moveq.l #0xF,%d2
56 .loop:
57 add.l %d0,%d0
58 addx.l %d1,%d1
59 cmp.l %d1,%d3
60 jbhi .loopend
61 sub.l %d3,%d1
62 addq.w #1,%d0
63 .loopend:
64 dbra %d2,.loop
65 movem.l (%sp)+,%d2-%d3
66 rts