Cryptography Reference
In-Depth Information
if (i == -1)
{
cpy_l (rem_l, r_l);
SETZERO_L (quot_l);
return E_CLINT_OK ;
}
else if (i == 0)
{
SETONE_L (quot_l);
SETZERO_L (rem_l);
return E_CLINT_OK ;
}
In the next step we check whether the divisor has only one digit. In this case a
branch is made to a faster variant of division, which we shall discuss further below.
if (DIGITS_L (b_l) == 1)
goto shortdiv;
Now begins the actual division. First the scaling factor d is determined as the
exponent of a power of two. As long as b n 1 BASEDIV2 :=
B/ 2
, the most-
significant digit b n 1 of the divisor is shifted left by one bit, where d , beginning
with d =0 , is incremented by 1 . Furthermore, the pointer msdptrb_l is set to
the most-significant digit of the divisor. The value BITPERDGT
− d will be used
frequently in the sequel, and therefore it is saved in the variable sbitsminusd .
msdptrb_l = MSDPTR_L (b_l);
bn_1 = *msdptrb_l;
while (bn_1 < BASEDIV2)
{
d++;
bn_1 <<= 1;
}
sbitsminusd = (int)(BITPERDGT - d);
If d> 0 , then the two most-significant digits b n 1 b n 2 of db are computed and
stored in bn_1 and bn_2 . In this we must distinguish the two cases that the divisor b
has exactly two, or more than two, digits. In the first case, binary zeros are inserted
into b n 2 from the right, while in the second case the least-significant digits of
b n 2 come from b n 3 .
Search WWH ::




Custom Search