Rev. 1.50, 10/04, page 408 of 448
10.3.19 FSCA (Floating Point Sine And Cosine Approximate): Floating-Point Instruction
PR Format Operation Instruction Code Cycle T Bit
0 FSCA FPUL,DRn sin(FPUL) → FRn
cos(FPUL) → FR[n+1]
1111nnn011111101 3 —
1 — reserved 1111nnnn11111101 — —
Description: This instruction calculates the sine and cosine approximations of FPUL (absolute
error is within ±2^–21) as single-precision floating point values, and places the values of the sine
and cosine in FRn and FR[n + 1], respectively. Since this instruction is an approximate operation
instruction, an imprecision exception is always required (even if the input is a 0, the result is
imprecise).
When FPSCR.enable.I is set, an FPU exception trap is generated. When an exception occurs,
correct exception information is reflected in FPSCR.cause and FPSCR.flag, and FRn and FR[n +
1] is not updated. Appropriate processing should therefore be performed by software.
Notes: None
Operation:
void FSCA(int n){
float angle;
long offset = 0x00010000;
long fraction = 0x0000ffff;
case((FPSCR.PR){
0: clear_cause();
set_I();
/* extract sub-rotation (fraction) part */
fraction &= FPUL;
/* convert to float */
angle = fraction;
/* convert to radian */
angle = 2*M_PI*angle / offset;
FR[n] ~= sin(angle)
FR[n+1] ~= cos(angle)
pc += 2; break;