APPENDIX B FLOATING-POINT OPERATION FUNCTION


It is only when the -fpu option is specified that the compiler outputs floating-point arithmetic instructions.

If the -chkfpu option is specified in the assembler, the floating-point arithmetic instructions written in a program are detected as warning.

B.1 When Using Floating-point Arithmetic Instructions in Tasks and Task Exception Handling Routines

Make settings that include "FPSW" for Task context register (context) in System Information (system). As a result, the FPSW register is managed independently in each task.

The initial FPSW value for tasks and task exception handling routines is initialized by the value according to compiler options to be used. For details, refer to "4.2.4 Internal processing of task" and "6.2.2 Internal processing of task exception handling routine".

B.2 When Using Floating-point Arithmetic Instructions in Handlers

It is necessary that the handler explicitly guarantee the FPSW register.

The initial FPSW value of handlers is undefined.

To guarantee and initialize the FPSW register, write a program as follows.

 #include <machine.h>    // To use the intrinsic function get_fpsw() and set_fpsw(),
                         // include machine.h.
 #include "kernel.h"
 #include "kernel_id.h"
 void handlervoid
 {
     unsigned long old_fpsw;    // Declare variable for saving the FPSW register
     old_fpsw = get_fpsw;    // Save the FPSW register
     set_fpsw0x00000100;     // Initialize the FPSW register if necessary
     /* Floating-point arithmetic operation */  
     set_fpswold_fpsw;       // Restore the FPSW register
 }