mp_modexp_cpu.cc
/* returns 1 for the most significant carry. 0 otherwise */
returns 1 for the most significant carry. 0 otherwise
returns 1 for the most significant carry . 0 otherwise
int mp_add1_cpu(WORD *ret, const WORD *x)
{
	WORD c[MAX_S];	
	for (int i = 0; i < MAX_S; i++) {
		c[i] = 0;
		ADD_CARRY(c[i], ret[i], x[i], (i == 0) ? 1 : 0);
	}
	while (1) {
		bool all_zero = true;
		for (int j = 0; j < MAX_S - 1; j++) { 
			if (c[j])
				all_zero = false;
		}
		if (all_zero)
			break;
		for (int j = MAX_S - 2; j >= 0; j--)
			ADD_CARRY_CLEAR(c[j + 1], ret[j + 1], ret[j + 1], c[j]);
	}
	return c[MAX_S - 1];
}
int mp_add1_cpu ( WORD * ret , const WORD * x ) { WORD c [ MAX_S ] ; for ( int i = 0 ; i < MAX_S ; i ++ ) { c [ i ] = 0 ; ADD_CARRY ( c [ i ] , ret [ i ] , x [ i ] , ( i == 0 ) ? 1 : 0 ) ; } while ( 1 ) { bool all_zero = true ; for ( int j = 0 ; j < MAX_S - 1 ; j ++ ) { if ( c [ j ] ) all_zero = false ; } if ( all_zero ) break ; for ( int j = MAX_S - 2 ; j >= 0 ; j -- ) ADD_CARRY_CLEAR ( c [ j + 1 ] , ret [ j + 1 ] , ret [ j + 1 ] , c [ j ] ) ; } return c [ MAX_S - 1 ] ; }
returns 1 for the most significant carry.
returns 1 for the most significant carry .
// carry. c[i] is set by a[i] /* NOTE MAX_S - 1, not just MAX_S */