Diff for /gforth/prim between versions 1.196 and 1.199

version 1.196, 2006/10/13 17:15:27 version 1.199, 2006/10/22 20:45:34
Line 809  n = n1*n2; Line 809  n = n1*n2;
   
 /       ( n1 n2 -- n )          core    slash  /       ( n1 n2 -- n )          core    slash
 n = n1/n2;  n = n1/n2;
 if(FLOORED_DIV && ((n1^n2) < 0) && (n1%n2 != 0)) n--;  if (CHECK_DIVISION && n2 == 0)
     throw(BALL_DIVZERO);
   if (CHECK_DIVISION && n2 == -1 && n1 == CELL_MIN)
     throw(BALL_RESULTRANGE);
   if (FLOORED_DIV && ((n1^n2) < 0) && (n1%n2 != 0))
     n--;
 :  :
  /mod nip ;   /mod nip ;
   
 mod     ( n1 n2 -- n )          core  mod     ( n1 n2 -- n )          core
 n = n1%n2;  n = n1%n2;
   if (CHECK_DIVISION && n2 == 0)
     throw(BALL_DIVZERO);
   if (CHECK_DIVISION && n2 == -1 && n1 == CELL_MIN)
     throw(BALL_RESULTRANGE);
 if(FLOORED_DIV && ((n1^n2) < 0) && n!=0) n += n2;  if(FLOORED_DIV && ((n1^n2) < 0) && n!=0) n += n2;
 :  :
  /mod drop ;   /mod drop ;
Line 822  if(FLOORED_DIV && ((n1^n2) < 0) && n!=0) Line 831  if(FLOORED_DIV && ((n1^n2) < 0) && n!=0)
 /mod    ( n1 n2 -- n3 n4 )              core            slash_mod  /mod    ( n1 n2 -- n3 n4 )              core            slash_mod
 n4 = n1/n2;  n4 = n1/n2;
 n3 = n1%n2; /* !! is this correct? look into C standard! */  n3 = n1%n2; /* !! is this correct? look into C standard! */
   if (CHECK_DIVISION && n2 == 0)
     throw(BALL_DIVZERO);
   if (CHECK_DIVISION && n2 == -1 && n1 == CELL_MIN)
     throw(BALL_RESULTRANGE);
 if (FLOORED_DIV && ((n1^n2) < 0) && n3!=0) {  if (FLOORED_DIV && ((n1^n2) < 0) && n3!=0) {
   n4--;    n4--;
   n3+=n2;    n3+=n2;
Line 842  n4=DHI(r); Line 855  n4=DHI(r);
 n5=DLO(r);  n5=DLO(r);
 #else  #else
 /* assumes that the processor uses either floored or symmetric division */  /* assumes that the processor uses either floored or symmetric division */
 n5 = d/n3;  DCell d5 = d/n3;
 n4 = d%n3;  n4 = d%n3;
   if (CHECK_DIVISION && n3 == 0)
     throw(BALL_DIVZERO);
 if (FLOORED_DIV && ((DHI(d)^n3)<0) && n4!=0) {  if (FLOORED_DIV && ((DHI(d)^n3)<0) && n4!=0) {
   n5--;    d5--;
   n4+=n3;    n4+=n3;
 }  }
   n5 = d5;
   if (d5 != n5)
     throw(BALL_RESULTRANGE);
 #endif  #endif
 :  :
  >r m* r> fm/mod ;   >r m* r> fm/mod ;
Line 864  DCell r = fmdiv(d,n3); Line 882  DCell r = fmdiv(d,n3);
 n4=DLO(r);  n4=DLO(r);
 #else  #else
 /* assumes that the processor uses either floored or symmetric division */  /* assumes that the processor uses either floored or symmetric division */
 n4 = d/n3;  DCell d4 = d/n3;
 if (FLOORED_DIV && ((DHI(d)^n3)<0) && (d%n3)!=0) n4--;  if (CHECK_DIVISION && n3 == 0)
     throw(BALL_DIVZERO);
   if (FLOORED_DIV && ((DHI(d)^n3)<0) && (d%n3)!=0)
     d4--;
   n4 = d4;
   if (d4 != n4)
     throw(BALL_RESULTRANGE);
 #endif  #endif
 :  :
  */mod nip ;   */mod nip ;
Line 893  fm/mod ( d1 n1 -- n2 n3 )  core  f_m_sla Line 917  fm/mod ( d1 n1 -- n2 n3 )  core  f_m_sla
 #ifdef ASM_SM_SLASH_REM  #ifdef ASM_SM_SLASH_REM
 ASM_SM_SLASH_REM(d1.lo, d1.hi, n1, n2, n3);  ASM_SM_SLASH_REM(d1.lo, d1.hi, n1, n2, n3);
 if (((DHI(d1)^n1)<0) && n2!=0) {  if (((DHI(d1)^n1)<0) && n2!=0) {
     if (n3 == CELL_MIN)
       throw(BALL_RESULTRANGE);
   n3--;    n3--;
   n2+=n1;    n2+=n1;
 }  }
Line 905  n3=DLO(r); Line 931  n3=DLO(r);
 #ifdef ASM_SM_SLASH_REM4  #ifdef ASM_SM_SLASH_REM4
 ASM_SM_SLASH_REM4(d1, n1, n2, n3);  ASM_SM_SLASH_REM4(d1, n1, n2, n3);
 if (((DHI(d1)^n1)<0) && n2!=0) {  if (((DHI(d1)^n1)<0) && n2!=0) {
     if (n3 == CELL_MIN)
       throw(BALL_RESULTRANGE);
   n3--;    n3--;
   n2+=n1;    n2+=n1;
 }  }
 #else /* !defined(ASM_SM_SLASH_REM4) */  #else /* !defined(ASM_SM_SLASH_REM4) */
 /* assumes that the processor uses either floored or symmetric division */  /* assumes that the processor uses either floored or symmetric division */
 n3 = d1/n1;  DCell d3 = d1/n1;
 n2 = d1%n1;  n2 = d1%n1;
   if (CHECK_DIVISION && n1 == 0)
     throw(BALL_DIVZERO);
 /* note that this 1%-3>0 is optimized by the compiler */  /* note that this 1%-3>0 is optimized by the compiler */
 if (1%-3>0 && ((DHI(d1)^n1)<0) && n2!=0) {  if (1%-3>0 && ((DHI(d1)^n1)<0) && n2!=0) {
   n3--;    d3--;
   n2+=n1;    n2+=n1;
 }  }
   n3 = d3;
   if (d3 != n3)
     throw(BALL_RESULTRANGE);
 #endif /* !defined(ASM_SM_SLASH_REM4) */  #endif /* !defined(ASM_SM_SLASH_REM4) */
 #endif  #endif
 :  :
Line 940  n3=DLO(r); Line 973  n3=DLO(r);
 ASM_SM_SLASH_REM4(d1, n1, n2, n3);  ASM_SM_SLASH_REM4(d1, n1, n2, n3);
 #else /* !defined(ASM_SM_SLASH_REM4) */  #else /* !defined(ASM_SM_SLASH_REM4) */
 /* assumes that the processor uses either floored or symmetric division */  /* assumes that the processor uses either floored or symmetric division */
 n3 = d1/n1;  DCell d3 = d1/n1;
 n2 = d1%n1;  n2 = d1%n1;
   if (CHECK_DIVISION && n1 == 0)
     throw(BALL_DIVZERO);
 /* note that this 1%-3<0 is optimized by the compiler */  /* note that this 1%-3<0 is optimized by the compiler */
 if (1%-3<0 && ((DHI(d1)^n1)<0) && n2!=0) {  if (1%-3<0 && ((DHI(d1)^n1)<0) && n2!=0) {
   n3++;    d3++;
   n2-=n1;    n2-=n1;
 }  }
   n3 = d3;
   if (d3 != n3)
     throw(BALL_RESULTRANGE);
 #endif /* !defined(ASM_SM_SLASH_REM4) */  #endif /* !defined(ASM_SM_SLASH_REM4) */
 #endif  #endif
 :  :
Line 996  u3=DLO(r); Line 1034  u3=DLO(r);
 #ifdef ASM_UM_SLASH_MOD4  #ifdef ASM_UM_SLASH_MOD4
 ASM_UM_SLASH_MOD4(ud, u1, u2, u3);  ASM_UM_SLASH_MOD4(ud, u1, u2, u3);
 #else /* !defined(ASM_UM_SLASH_MOD4) */  #else /* !defined(ASM_UM_SLASH_MOD4) */
 u3 = ud/u1;  UDCell ud3 = ud/u1;
 u2 = ud%u1;  u2 = ud%u1;
   if (CHECK_DIVISION && u1 == 0)
     throw(BALL_DIVZERO);
   u3 = ud3;
   if (ud3 != u3)
     throw(BALL_RESULTRANGE);
 #endif /* !defined(ASM_UM_SLASH_MOD4) */  #endif /* !defined(ASM_UM_SLASH_MOD4) */
 #endif  #endif
 :  :

Removed from v.1.196  
changed lines
  Added in v.1.199


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>