m68k/defconfig: Update defconfigs for v4.3-rc1
[linux-2.6-block.git] / arch / h8300 / lib / modsi3.S
CommitLineData
a71a29de
YS
1#include "libgcc.h"
2
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
12
13 .global __umodsi3
14__umodsi3:
15 bsr __udivsi3
16 mov.l er3,er0
17 rts
18
19 .global __divsi3
20__divsi3:
21 PUSHP S2P
22 jsr divnorm
23 bsr __udivsi3
24
25 ; examine what the sign should be
26exitdiv:
27 btst #3,S2L
28 beq reti
29
30 ; should be -ve
31 neg.l A0P
32
33reti:
34 POPP S2P
35 rts
36
37divnorm:
38 mov.l A0P,A0P ; is the numerator -ve
39 stc ccr,S2L ; keep the sign in bit 3 of S2L
40 bge postive
41
42 neg.l A0P ; negate arg
43
44postive:
45 mov.l A1P,A1P ; is the denominator -ve
46 bge postive2
47
48 neg.l A1P ; negate arg
49 xor.b #0x08,S2L ; toggle the result sign
50
51postive2:
52 rts
53
54;; Basically the same, except that the sign of the divisor determines
55;; the sign.
56modnorm:
57 mov.l A0P,A0P ; is the numerator -ve
58 stc ccr,S2L ; keep the sign in bit 3 of S2L
59 bge mpostive
60
61 neg.l A0P ; negate arg
62
63mpostive:
64 mov.l A1P,A1P ; is the denominator -ve
65 bge mpostive2
66
67 neg.l A1P ; negate arg
68
69mpostive2:
70 rts
71
72 .end