Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 2nd, 2012  |  syntax: None  |  size: 1.35 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. void mulmon_l (CLINT a_l, CLINT b_l, CLINT n_l, USHORT nprime,
  2.          USHORT logB_r, CLINT p_l)
  3. {
  4.   CLINTD t_l;
  5.   clint *tptr_l, *nptr_l, *tiptr_l, *lasttnptr, *lastnptr;
  6.   ULONG carry;
  7.   USHORT mi;
  8.   int i;
  9.  
  10.   mult (a_l, b_l, t_l);
  11.   lasttnptr = t_l + DIGITS_L (n_l);
  12.   lastnptr = MSDPTR_L (n_l);
  13.   for (i = DIGITS_L (t_l) + 1; i <= (DIGITS_L (n_l) << 1); i++)
  14.       t_l[i] = 0;
  15.  
  16.   SETDIGITS_L (t_l, MAX (DIGITS_L (t_l), DIGITS_L (n_l) << 1));
  17.   for (tptr_l = LSDPTR_L (t_l); tptr_l <= lasttnptr; tptr_l++)
  18.     {
  19.       carry = 0;
  20.       mi = (USHORT)((ULONG)nprime * (ULONG)*tptr_l);
  21.  
  22.       for (nptr_l = LSDPTR_L (n_l), tiptr_l = tptr_l;
  23.            nptr_l <= lastnptr; nptr_l++, tiptr_l++)
  24.          {
  25.            *tiptr_l = (USHORT)(carry = (ULONG)mi * (ULONG)*nptr_l +
  26.                 (ULONG)*tiptr_l + (ULONG)(USHORT)(carry >> BITPERDGT));
  27.          }
  28.       for ( ; ((carry >> BITPERDGT) > 0) && tiptr_l <= MSDPTR_L (t_l); tiptr_l++)
  29.         *tiptr_l = (USHORT)(carry = (ULONG)*tiptr_l + (ULONG)(USHORT)(carry >> BITPERDGT));
  30.      if (((carry >> BITPERDGT) > 0))
  31.         {
  32.           *tiptr_l = (USHORT)(carry >> BITPERDGT);
  33.           INCDIGITS_L (t_l);
  34.         }
  35.     }
  36.   tptr_l = t_l + (logB_r);
  37.   SETDIGIT_L (tptr_l, DIGITS_L (t_l) - (logB_r));
  38.   if (GE_L (tptr_l, n_l))
  39.       sub_l (tptr_l, n_l, p_l);
  40.   else
  41.       cpy_l (p_l, tptr_l);
  42. }