Staging: rtl8192u: ieee80211: fixed position of else statements
[linux-2.6/btrfs-unstable.git] / arch / h8300 / lib / modsi3.S
blob68b1dfc32824e00db913419f2334cbad0a4cd750
1 #include "libgcc.h"
3 ; numerator in A0/A1
4 ; denominator in A2/A3
5         .global __modsi3
6 __modsi3:
7         PUSHP   S2P
8         bsr     modnorm
9         bsr     __divsi3
10         mov.l   er3,er0
11         bra     exitdiv
13         .global __umodsi3
14 __umodsi3:
15         bsr     __udivsi3
16         mov.l   er3,er0
17         rts
19         .global __divsi3
20 __divsi3:
21         PUSHP   S2P
22         jsr     divnorm
23         bsr     __udivsi3
25         ; examine what the sign should be
26 exitdiv:
27         btst    #3,S2L
28         beq     reti
30         ; should be -ve
31         neg.l   A0P
33 reti:
34         POPP    S2P
35         rts
37 divnorm:
38         mov.l   A0P,A0P         ; is the numerator -ve
39         stc     ccr,S2L         ; keep the sign in bit 3 of S2L
40         bge     postive
42         neg.l   A0P             ; negate arg
44 postive:
45         mov.l   A1P,A1P         ; is the denominator -ve
46         bge     postive2
48         neg.l   A1P             ; negate arg
49         xor.b   #0x08,S2L       ; toggle the result sign
51 postive2:
52         rts
54 ;; Basically the same, except that the sign of the divisor determines
55 ;; the sign.
56 modnorm:
57         mov.l   A0P,A0P         ; is the numerator -ve
58         stc     ccr,S2L         ; keep the sign in bit 3 of S2L
59         bge     mpostive
61         neg.l   A0P             ; negate arg
63 mpostive:
64         mov.l   A1P,A1P         ; is the denominator -ve
65         bge     mpostive2
67         neg.l   A1P             ; negate arg
69 mpostive2:
70         rts
72         .end