* device/include/pic/pic14regs.h: reverted accidental wipe of the file
[fw/sdcc] / device / lib / _modslong.c
index dc5038cbb4bc331215f0205f0b9a769fb0e83fe9..975168ede16bcdb646dae952dade06cbaf135853 100644 (file)
@@ -36,7 +36,7 @@ unsigned long _modulong (unsigned long a, unsigned long b);
 #if !defined(SDCC_USE_XSTACK) && !defined(_SDCC_NO_ASM_LIB_FUNCS)
 #  if defined(SDCC_mcs51)
 #    if defined(SDCC_MODEL_SMALL)
-#      if defined(SDCC_STACK_AUTO)
+#      if defined(SDCC_STACK_AUTO) && !defined(SDCC_PARMS_IN_BANK1)
 #        define _MODSLONG_ASM_SMALL_AUTO
 #      else
 #        define _MODSLONG_ASM_SMALL
@@ -58,14 +58,19 @@ _modslong_dummy (void) _naked
                #define a3      r1
 
                .globl __modslong
-
+#if defined(SDCC_PARMS_IN_BANK1)
+               #define b0      (b1_0)
+               #define b1      (b1_1)
+               #define b2      (b1_2)
+               #define b3      (b1_3)
+#else
                // _modslong_PARM_2 shares the same memory with _modulong_PARM_2
                // and is defined in _modulong.c
                #define b0      (__modslong_PARM_2)
                #define b1      (__modslong_PARM_2 + 1)
                #define b2      (__modslong_PARM_2 + 2)
                #define b3      (__modslong_PARM_2 + 3)
-
+#endif
        __modslong:
                                        ; a3 in acc
                                        ; b3 in (__modslong_PARM_2 + 3)
@@ -96,8 +101,6 @@ _modslong_dummy (void) _naked
                mov     a,b3
                jnb     acc.7,b_not_negative
 
-               cpl     F0
-
                clr     a               ; b = -b;
                clr     c
                subb    a,b0
@@ -207,8 +210,6 @@ _modslong_dummy (void) _naked
 
                jnb     acc.7,b_not_negative
 
-               cpl     F0
-
                clr     a               ; b = -b;
                clr     c
                subb    a,b0
@@ -258,7 +259,7 @@ _modslong (long a, long b)
 
   r = _modulong((a < 0 ? -a : a),
                 (b < 0 ? -b : b));
-  if ( (a < 0) ^ (b < 0))
+  if (a < 0)
     return -r;
   else
     return r;