added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / .unmaintained / m68k-native / utility / sdivmod32.s
blob75bb2019ac68de831598b21c6836aa49f87c6409
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 "machine.i"
11 .globl AROS_SLIB_ENTRY(SDivMod32,Utility)
12 .globl AROS_SLIB_ENTRY(SDivMod32_020,Utility)
14 /* Needed for SDivMod32 */
15 .globl AROS_SLIB_ENTRY(UDivMod32,Utility)
17 .type AROS_SLIB_ENTRY(SDivMod32,Utility),@function
18 .type AROS_SLIB_ENTRY(SDivMod32_020,Utility),@function
20 .balign 4
21 AROS_SLIB_ENTRY(SDivMod32_020,Utility):
22 divsl.l d1,d1:d0
23 rts
25 /* All we do is remember the sign and get UDivMod32 to do all the work,
26 this is actually a bit harder than just changing both, doing the
27 division and then changing the other...
29 If both are positive, do nothing,
30 if one is negative, change both,
31 if both are negative, change remainder
34 .balign 4
35 AROS_SLIB_ENTRY(SDivMod32,Utility):
36 tst.l d0
37 bpl.s nispos
38 neg.l d0
39 tst.l d1
40 bpl.s nisneg
41 neg.l d1
42 bsr.s AROS_SLIB_ENTRY(UDivMod32,Utility)
43 neg.l d1
44 rts
45 nisneg:
46 bsr.s AROS_SLIB_ENTRY(UDivMod32,Utility)
47 neg.l d1
48 neg.l d0
49 rts
50 nispos:
51 tst.l d1
52 bpl.s AROS_SLIB_ENTRY(UDivMod32,Utility)
53 neg.l d1
54 bsr.s AROS_SLIB_ENTRY(UDivMod32,Utility)
55 neg.l d0
56 rts