diff options
author | Yoshinori Sato <ysato@users.sourceforge.jp> | 2015-01-28 02:48:15 +0900 |
---|---|---|
committer | Yoshinori Sato <ysato@users.sourceforge.jp> | 2015-06-23 13:35:54 +0900 |
commit | a71a29de4c2f95563220a472f265f0bd74701d52 (patch) | |
tree | 2e0b84cdc079ce9dc038d7bf3f86ebdd0315cb2e /arch/h8300/lib/moddivsi3.S | |
parent | bbeb79acb3b44f727f6267e1f6db9b3fdf791c24 (diff) | |
download | linux-stable-a71a29de4c2f95563220a472f265f0bd74701d52.tar.gz linux-stable-a71a29de4c2f95563220a472f265f0bd74701d52.tar.bz2 linux-stable-a71a29de4c2f95563220a472f265f0bd74701d52.zip |
h8300: library functions
Signed-off-by: Yoshinori Sato <ysato@users.sourceforge.jp>
Diffstat (limited to 'arch/h8300/lib/moddivsi3.S')
-rw-r--r-- | arch/h8300/lib/moddivsi3.S | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/arch/h8300/lib/moddivsi3.S b/arch/h8300/lib/moddivsi3.S new file mode 100644 index 000000000000..c803129e877f --- /dev/null +++ b/arch/h8300/lib/moddivsi3.S @@ -0,0 +1,72 @@ +#include "libgcc.h" + +; numerator in A0/A1 +; denominator in A2/A3 + .global __modsi3 +__modsi3: + PUSHP S2P + bsr modnorm + bsr __divsi3 + mov.l er3,er0 + bra exitdiv + + .global __umodsi3 +__umodsi3: + bsr __udivsi3:16 + mov.l er3,er0 + rts + + .global __divsi3 +__divsi3: + PUSHP S2P + bsr divnorm + bsr __udivsi3:16 + + ; examine what the sign should be +exitdiv: + btst #3,S2L + beq reti + + ; should be -ve + neg.l A0P + +reti: + POPP S2P + rts + +divnorm: + mov.l A0P,A0P ; is the numerator -ve + stc ccr,S2L ; keep the sign in bit 3 of S2L + bge postive + + neg.l A0P ; negate arg + +postive: + mov.l A1P,A1P ; is the denominator -ve + bge postive2 + + neg.l A1P ; negate arg + xor.b #0x08,S2L ; toggle the result sign + +postive2: + rts + +;; Basically the same, except that the sign of the divisor determines +;; the sign. +modnorm: + mov.l A0P,A0P ; is the numerator -ve + stc ccr,S2L ; keep the sign in bit 3 of S2L + bge mpostive + + neg.l A0P ; negate arg + +mpostive: + mov.l A1P,A1P ; is the denominator -ve + bge mpostive2 + + neg.l A1P ; negate arg + +mpostive2: + rts + + .end |