Fix IO memory access .. SB128 driver makes noises in VMWare - CMI is untested (Curren...
[AROS.git] / arch / m68k-all / utility / sdivmod32.s
blob751f03728df76cb385480b9b768d7a34e9378805
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: signed 32 bit division/modulus functions for Amiga/m68k
6 Lang: english
7 */
9 #include "aros/m68k/asm.h"
11 .text
12 .globl AROS_SLIB_ENTRY(SDivMod32,Utility,25)
13 .globl AROS_SLIB_ENTRY(SDivMod32_020,Utility,25)
15 /* Needed for SDivMod32 */
16 .globl AROS_SLIB_ENTRY(UDivMod32,Utility,26)
18 .type AROS_SLIB_ENTRY(SDivMod32,Utility,25),@function
19 .type AROS_SLIB_ENTRY(SDivMod32_020,Utility,25),@function
21 .balign 4
22 AROS_SLIB_ENTRY(SDivMod32_020,Utility,25):
23 divsl.l %d1,%d1:%d0
24 rts
26 /* All we do is remember the sign and get UDivMod32 to do all the work,
27 this is actually a bit harder than just changing both, doing the
28 division and then changing the other...
30 If both are positive, do nothing,
31 if one is negative, change both,
32 if both are negative, change remainder
35 .balign 4
36 AROS_SLIB_ENTRY(SDivMod32,Utility,25):
37 tst.l %d0
38 bpl.s nispos
39 neg.l %d0
40 tst.l %d1
41 bpl.s nisneg
42 neg.l %d1
43 bsr.s AROS_SLIB_ENTRY(UDivMod32,Utility,26)
44 neg.l %d1
45 rts
46 nisneg:
47 bsr.s AROS_SLIB_ENTRY(UDivMod32,Utility,26)
48 neg.l %d1
49 neg.l %d0
50 rts
51 nispos:
52 tst.l %d1
53 bpl.s AROS_SLIB_ENTRY(UDivMod32,Utility,26)
54 neg.l %d1
55 bsr.s AROS_SLIB_ENTRY(UDivMod32,Utility,26)
56 neg.l %d0
57 rts