#include <nitro/cp.h>
void CP_SetSqrt64( u64 param );
void CP_SetSqrt32( u32 param );
param | Value of the square root to be calculated. |
None.
Sets the parameters for square root calculations. Sets the square root calculation mode first, and then stores parameters. There are two calculation modes, as follows:
Division Mode | Calculation |
CP_SQRT_32BIT_MODE | Square root calculation of 32-bit value |
CP_SQRT_64BIT_MODE | Square root calculation of 64-bit value |
Note: With the square root calculator, sometimes the value is overwritten in the interrupt. If the parameters are set up, an interrupt occurs during the square root calculation and the square root calculator is used, then the original calculated result is invalid. Therefore, if you are using the square root calculator in an interrupt, the status of the square root calculator needs to be temporarily saved/restored using CP_SaveContext
and CP_RestoreContext
.During a thread switch, the contents of the square root calculator are also automatically saved/restored.
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
SQRTCNT(0x40002B0)
and SQRT_PARAM(0x40002B8)
of the IO register.
CP_SetSqrtImm*, CP_IsSqrtBusy, CP_WaitSqrt, CP_GetSqrtResult*, CP_SaveContext, CP_RestoreContext
03/08/2005 Unified Japanese term for "interrupt."
05/06/2004 Added description about status restoration.
01/09/2004 Added content.
12/01/2003 Initial version.