#include <nitro/cp.h>void CP_SetSqrtImm64( u64 param );void CP_SetSqrtImm32( u32 param );
| param | Value of the square root to be calculated. |
None.
Sets the parameters for square root calculations. It does not set the square root calculation mode but merely stores the parameter. There are two calculation modes, as follows:
| Square Root Calculation Mode | Calculation | Calculation Cycles | CPU Cycle Conversion |
|---|---|---|---|
| CP_SQRT_32BIT_MODE | Square root calculation of 32-bit value | 13 cycles | 26 cycles |
| CP_SQRT_64BIT_MODE | Square root calculation of 64-bit value | 13 cycles | 26 cycles |
Note: With the square root calculator, sometimes the value is overwritten in the interrupt. If the parameters are set up and an interrupt occurs during square root calculation when using a square root calculator, the original calculated result will be broken. Therefore, if you are using the square root calculator in an interrupt, its status needs to be temporarily saved/restored using CP_SaveContext and CP_RestoreContext.
The status of square root calculators is also automatically saved/restored when threads are switched.
Example: Restore the square root calculator status
intr_func( void ) { CPContext context; CP_SaveContext( &context ); CP_SetSqrt32( 1000 ); CP_WaitSqrt(); result = CP_GetSqrtResult32(); CP_RestoreContext( &context ); }
Stores values in SQRT_PARAM(0x40002B8) of the IO register.
CP_SetSqrt*, CP_IsSqrtBusy, CP_WaitSqrt, CP_GetSqrtResult*
08/09/2006 Added a note regarding use inside interrupts.
01/09/2004 Added content.
2003/12/01 Initial version.
CONFIDENTIAL