Rev. 1.50, 10/04, page 411 of 448
10.3.21 FSQRT (Floating-point Square Root): Floating-Point Instruction
PR Format Operation Instruction Code Cycle T Bit
0 FSQRT FRn sqrt (FRn)* → FRn 1111nnnn01101101 14 —
1 FSQRT DRn sqrt (DRn)* → DRn 1111nnn001101101 30 —
Note: * sqrt(FRn) and sqrt(DRn) are the square roots of FRn and DRn, respectively.
Description: When FPSCR.PR = 0: Finds the arithmetical square root of the single-precision
floating-point number in FRn, and stores the result in FRn.
When FPSCR.PR = 1: Finds the arithmetical square root of the double-precision floating-point
number in DRn, and stores the result in DRn.
When FPSCR.enable.I is set, an FPU exception trap is generated regardless of whether or not an
exception has occurred. When an exception occurs, correct exception information is reflected in
FPSCR.cause and FPSCR.flag, and FRn or DRn is not updated. Appropriate processing should
therefore be performed by software.
Notes: None
Operation:
void FSQRT(int n){
pc += 2;
clear_cause();
switch(data_type_of(n)){
case NORM : if(sign_of(n) == 0) normal_ fsqrt(n);
else invalid(n); break;
case DENORM: if(sign_of(n) == 0) set_E();
else invalid(n); break;
case PZERO :
case NZERO :
case PINF : break;
case NINF : invalid(n); break;
case qNaN : qnan(n); break;
case sNaN : invalid(n); break;
}
}