aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Law <law@gcc.gnu.org>1996-04-11 14:10:57 -0600
committerJeff Law <law@gcc.gnu.org>1996-04-11 14:10:57 -0600
commit2570cc939ae64643f7be153a6fe550f6ddd14569 (patch)
treeef5a1f1a1dbfdef2696066fc5c46b1386f4e0d32
parentcea60f06c0c2d85000369cc0a446c8dd44bbbc9d (diff)
downloadgcc-2570cc939ae64643f7be153a6fe550f6ddd14569.zip
gcc-2570cc939ae64643f7be153a6fe550f6ddd14569.tar.gz
gcc-2570cc939ae64643f7be153a6fe550f6ddd14569.tar.bz2
lib1funcs.asm (modnorm): New function(s).
* lib1funcs.asm (modnorm): New function(s). Like divnorm, but gets the sign bit right for modulo operations. (__modhi3, modsi3): Use modnorm. From-SVN: r11701
-rw-r--r--gcc/config/h8300/lib1funcs.asm72
1 files changed, 70 insertions, 2 deletions
diff --git a/gcc/config/h8300/lib1funcs.asm b/gcc/config/h8300/lib1funcs.asm
index 8746e00..c52bcff 100644
--- a/gcc/config/h8300/lib1funcs.asm
+++ b/gcc/config/h8300/lib1funcs.asm
@@ -190,6 +190,22 @@ _lab1: or A1H,A1H ; look at dividend
adds #1,A1
xor #0x1,A2L; and toggle sign of result
_lab2: rts
+;; Basically the same, except that the sign of the divisor determines
+;; the sign.
+modnorm:
+ mov.b #0x0,A2L
+ or A0H,A0H ; is divisor > 0
+ bge _lab7
+ not A0H ; no - then make it +ve
+ not A0L
+ adds #1,A0
+ xor #0x1,A2L ; and remember that in A2L
+_lab7: or A1H,A1H ; look at dividend
+ bge _lab8
+ not A1H ; it is -ve, make it positive
+ not A1L
+ adds #1,A1
+_lab8: rts
; A0=A0/A1 signed
@@ -208,7 +224,7 @@ _lab4: rts
.global ___modhi3
___modhi3:
- bsr divnorm
+ bsr modnorm
bsr ___udivhi3
mov A3,A0
bra negans
@@ -338,6 +354,39 @@ postive:
postive2:
rts
+;; Basically the same, except that the sign of the divisor determines
+;; the sign.
+modnorm:
+ mov.b #0,S2L ; keep the sign in S2
+ mov.b A0H,A0H ; is the numerator -ve
+ bge mpostive
+
+ ; negate arg
+ not A0H
+ not A1H
+ not A0L
+ not A1L
+
+ add #1,A1L
+ addx #0,A1H
+ addx #0,A0H
+ addx #0,A0L
+
+ mov.b #1,S2L ; the sign will be -ve
+mpostive:
+ mov.b A2H,A2H ; is the denominator -ve
+ bge mpostive2
+ not A2L
+ not A2H
+ not A3L
+ not A3H
+ add.b #1,A3L
+ addx #0,A3H
+ addx #0,A2L
+ addx #0,A2H
+mpostive2:
+ rts
+
#else /* __H8300H__ */
divnorm:
@@ -358,6 +407,25 @@ postive:
postive2:
rts
+;; Basically the same, except that the sign of the divisor determines
+;; the sign.
+modnorm:
+ mov.b #0,S2L ; keep the sign in S2
+ mov.l A0P,A0P ; is the numerator -ve
+ bge mpostive
+
+ neg.l A0P ; negate arg
+ mov.b #1,S2L ; the sign will be -ve
+
+mpostive:
+ mov.l A1P,A1P ; is the denominator -ve
+ bge mpostive2
+
+ neg.l A1P ; negate arg
+
+mpostive2:
+ rts
+
#endif
; numerator in A0/A1
@@ -368,7 +436,7 @@ ___modsi3:
PUSHP S0P
PUSHP S1P
- bsr divnorm
+ bsr modnorm
bsr divmodsi4
#ifdef __H8300__
mov S0,A0