Cryptography Reference
In-Depth Information
Function:
left/right shift
(multiplication and division by powers of two)
Syntax:
int shift_l (CLINT n_l, long int noofbits);
n_l (operand)
noofbits (exponent of the power of two)
Input:
n_l (product or quotient, depending on sign of noofbits)
Output:
E_CLINT_OK if all ok
E_CLINT_UFL if “underflow”
E_CLINT_OFL if overflow
Return:
int
shift_l (CLINT n_l, long int noofbits)
{
USHORT shorts = (USHORT)((ULONG)(noofbits<0?-noofbits : noofbits) / BITPERDGT);
USHORT bits = (USHORT)((ULONG)(noofbits<0?-noofbits : noofbits) % BITPERDGT);
long int resl;
USHORT i;
int error = E_CLINT_OK;
clint *nptr_l;
clint *msdptrn_l;
RMLDZRS_L (n_l);
resl = (int) ld_l (n_l) + noofbits;
If n_l == 0 , we need only set the error code correctly, and we are done. The same
holds if noofbits == 0 .
if (*n_l == 0)
{
return ((resl < 0) ? E_CLINT_UFL : E_CLINT_OK);
}
if (noofbits == 0)
{
return E_CLINT_OK;
}
Next it is checked whether there is an overflow or underflow to announce. Then a
branch is taken depending on the sign of noofbits to shift either to the left or to
the right.
 
Search WWH ::




Custom Search