Section 2: Compiler
83
TI
-
89 / TI
-
92 Plus Sierra C Assembler Reference Manual
Not for Distribution
Beta Version February 2, 2001
2.12.2.
Internal Floating-Point Functions
The Sierra C compiler supports two different floating-point formats, each one
being automatically used in specific cases. The supported formats include the
TI BCD floating
-
point format and an IEEE format which exists only in the
compiler, not on the TI-89 / TI-92 Plus. Floating
-
point operations on constants
are performed in the IEEE format by the compiler while all other floating
-
point
operations are handled by internally generated calls to the BCD floating
-
point
routines on the TI-89 / TI-92 Plus. Floating
-
point constants are converted to
BCD if they are used as operands in the TI BCD floating
-
point routines. It is
important to remember that in rare cases, it is possible that a value computed in
the IEEE format and converted to BCD may differ from the result of the identical
operation if performed by the TI floating
-
point routines due to the difference in
accuracy between IEEE and BCD. Floating
-
point constant operations should be
used with caution for this reason, although since the IEEE format is comparable
to 20 BCD digits and the TI BCD values have 16 digits, differences will be
extremely rare.
double flt1=1024. * 16.; /* IEEE operations */
double flt2;
flt2 = flt1 * 4.; /* TI BCD floating-point routines */
When generating code for the TI BCD floating-point routines, floating-point
registers fp0 through fp7 correspond to stack frame locations (-10, a6) through
(-80, a6), respectively; each location occupies ten bytes. To minimize the amount
of code needed to make an internally generated call, the compiler goes through
an interface function on the TI-89 / TI-92 Plus, _ _ bcd_math. Calls to the
floating-point interface function differ from calls generated for C language
function calls in two major respects:
•
Operand information, including the specification of both source and
destination registers (when applicable), is encoded into a single two-byte
argument.
•
The called (not the calling) function restores the stack upon function return.
When using the function call to _ _ bcd_math, a two-byte code word is inserted
into the instruction sequence immediately following the function call. The code
word fully describes the floating-point operation, the size of the operands, and
the effective addresses of both the source and destination operands. If both the
source and destination operands are registers (data and/or emulation
floating-point registers), no information other than that supplied by the code word
is required.