CP_SetSqrt*

Syntax

#include <nitro/cp.h>

void CP_SetSqrt64( u64 param );
void CP_SetSqrt32( u32 param );

Arguments

param Value of the square root to be calculated.

Return Values

None.

Description

Sets the parameters for square root calculations. Sets the square root calculation mode first, and then stores parameters. Calculation modes are listed below.

Square Root Calculation Mode Calculation Calculation Cycles CPU Cycle Conversion
CP_SQRT_32BIT_MODE Square root calculation of 32-bit values 13 cycles 26 cycles
CP_SQRT_64BIT_MODE Square root calculation of 64-bit values 13 cycles 26 cycles

Note: With the square root calculator, an interrupt may affect data integrity. If the parameters are set and an interrupt occurs during square root calculation, the result may not be accurate. Therefore, to maintain the integrity of an interrupted square root calculation, temporarily store and restore the calculator status using CP_SaveContext() and CP_RestoreContext(), respectively. The status of square root calculators is also automatically saved/restored when threads are switched.


Example: Restore the status of the square root calculator.

intr_func( void ) 
{
  CPContext context;
       
  CP_SaveContext( &context );
  CP_SetSqrt32( 1000 );
  CP_WaitSqrt();
  result = CP_GetDqrtResult32();
  CP_RestoreContext( &context );
}

Internal Operation

Stores values in SQRTCNT(0x40002B0) and SQRT_PARAM(0x40002B8) of the IO register.

See Also

CP_SetSqrtImm*
CP_IsSqrtBusy
CP_WaitSqrt
CP_GetSqrtResult*
CP_SaveContext
CP_RestoreContext

Revision History

2005/03/08 Standardized the Japanese term for interrupt.
2004/05/06 Added description about status restoration.
2004/01/09 Added content.
2003/12/01 Initial version.


CONFIDENTIAL