Rev. 1.50, 10/04, page 387 of 448
10.3.11 FLOAT (Floating-point Convert from Integer): Floating-Point Instruction
PR Format Operation Instruction Code Cycle T Bit
0 FLOAT FPUL,FRn (float)FPUL → FRn 1111nnnn00101101 1 —
1 FLOAT FPUL,DRn (double)FPUL → DRn 1111nnn000101101 1 —
Description:
When FPSCR.PR = 0: Taking the contents of FPUL as a 32-bit integer, converts this integer to a
single-precision floating-point number and stores the result in FRn.
When FPSCR.PR = 1: Taking the contents of FPUL as a 32-bit integer, converts this integer to a
double-precision floating-point number and stores the result in DRn.
When FPSCR.enable.I = 1 and FPSCR.PR = 0, 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 is not updated. Appropriate
processing should therefore be performed by software.
Notes: None
Operation:
void FLOAT(int n, float *FPUL)
{
union {
double d;
int l[2];
} tmp;
pc += 2;
clear_cause();
if(FPSCR.PR==0){
FR[n] = *FPUL; /* convert from integer to float */
tmp.d = *FPUL;
if(tmp.l[1] & 0x1fffffff) inexact();
} else {
DR[n>>1] = *FPUL; /* convert from integer to double */
}
}