host/baseconv.c
/** Do a multi-precision division of op1 by an 8 bit unsigned integer n,
  * placing the quotient in r and the remainder in op1.
  * \param r The quotient will be placed here. This should be an array with
  *          space for size bytes.
  * \param op1 As an input, this is the dividend, a multi-precision number.
  *            But on output, this will be be remainder. This should be an
  *            array with space for size + 1 bytes.
  * \param temp A temporary work area. Its contents will be overwritten with
  *             junk. This should be an array with space for size + 1 bytes.
  * \param size The size of the division, in number of bytes.
  * \param shift_list Specifies the divisor (the 8 bit unsigned integer n).
  *                   This is actually an array of 8 little-endian 16 bit
  *                   unsigned integers which are:
  *                   n << 7, n << 6, n << 5, ..., n << 0.
  * \warning r, op1 and temp cannot alias each other.
  * \warning For platforms that use the PROGMEM attribute, the shift_list
  *          array must have that attribute.
  */
Do a multi-precision division of op1 by an 8 bit unsigned integer n,
placing the quotient in r and the remainder in op1.
\param r The quotient will be placed here. This should be an array with
space for size bytes.
\param op1 As an input, this is the dividend, a multi-precision number.
But on output, this will be be remainder. This should be an
array with space for size + 1 bytes.
\param temp A temporary work area. Its contents will be overwritten with
junk. This should be an array with space for size + 1 bytes.
\param size The size of the division, in number of bytes.
\param shift_list Specifies the divisor (the 8 bit unsigned integer n).
Do a multi - precision division of op1 by an 8 bit unsigned integer n placing the quotient in r and the remainder in op1 . \ param r The quotient will be placed here . This should be an array with space for size bytes . \ param op1 As an input this is the dividend a multi - precision number . But on output this will be be remainder . This should be an array with space for size + 1 bytes . \ param temp A temporary work area . Its contents will be overwritten with junk . This should be an array with space for size + 1 bytes . \ param size The size of the division in number of bytes . \ param shift_list Specifies the divisor ( the 8 bit unsigned integer n ) .
static void bigDivide(uint8_t *r, uint8_t *op1, uint8_t *temp, uint8_t size, const uint8_t *shift_list)
{
	uint8_t i;
	uint8_t j;
	uint8_t one_bit;
	memset(temp, 0, (uint16_t)(size + 1));
	memset(r, 0, size);
	op1[size] = 0;
	for (i = (uint8_t)(size - 1); i < size; i--)
	{
		one_bit = 0x80;
		for (j = 0; j < 8; j++)
		{
			temp[i] = LOOKUP_BYTE(shift_list[j * 2]);
			temp[i + 1] = LOOKUP_BYTE(shift_list[j * 2 + 1]);
			if (bigCompareVariableSize(temp, op1, (uint8_t)(size + 1)) != BIGCMP_GREATER)
			{
				bigSubtractVariableSizeNoModulo(op1, op1, temp, (uint8_t)(size + 1));
				r[i] |= one_bit;
			}
			one_bit >>= 1;
		}
		temp[i + 1] = 0;
	}
}
static void bigDivide ( uint8_t * r , uint8_t * op1 , uint8_t * temp , uint8_t size , const uint8_t * shift_list ) { uint8_t i ; uint8_t j ; uint8_t one_bit ; memset ( temp , 0 , ( uint16_t ) ( size + 1 ) ) ; memset ( r , 0 , size ) ; op1 [ size ] = 0 ; for ( i = ( uint8_t ) ( size - 1 ) ; i < size ; i -- ) { one_bit = 0x80 ; for ( j = 0 ; j < 8 ; j ++ ) { temp [ i ] = LOOKUP_BYTE ( shift_list [ j * 2 ] ) ; temp [ i + 1 ] = LOOKUP_BYTE ( shift_list [ j * 2 + 1 ] ) ; if ( bigCompareVariableSize ( temp , op1 , ( uint8_t ) ( size + 1 ) ) != BIGCMP_GREATER ) { bigSubtractVariableSizeNoModulo ( op1 , op1 , temp , ( uint8_t ) ( size + 1 ) ) ; r [ i ] |= one_bit ; } one_bit >>= 1 ; } temp [ i + 1 ] = 0 ; } }
Do a multi-precision division of op1 by an 8 bit unsigned integer n,
 placing the quotient in r and the remainder in op1.
Do a multi - precision division of op1 by an 8 bit unsigned integer n placing the quotient in r and the remainder in op1 .