Evaluating the wordSize and shift of an Object
The wordSize and shift of an object are defined by its attributes (specified in the Data Dictionary Editor). MicroC determines the
wordSize
andshift
of an expression made of objects and operators using the formulas listed in the Fixed-Point Macros Macro Definition Description table.The conventions used in the table are as follows:
●
●
●
●
●
●
All other parameters WS = SUM(MAX(RG1, RG2), MAX(SH1,If the
wordSize
is greater than 32 bits, MicroC displays the following messages:
● wrn_err.inf - Warning: Fixed-Point Overflow in Expression:<Expression>
● generated code - /* Warning - Fixed- Point Overflow in Expression. *
/
This message is located right after the expression.When you use fixed-point variables in integer arithmetic, MicroC uses the special functions (or C macros) provided in the FXP package to perform the calculations. The following table lists these macros.
Fixed-Point Macros Macro Definition Description
LS_FXP2FXP8 (FPvalue, fromFPshift, toFPshift) ((sint8(FPvalue)) << ((toFPshift) - (fromFPshift))) Converts a fixed-point number with shift=fromFPshift to an 8-bit fixed-point number with shift=toFPshift using left shifting RS_FXP2FXP8 (FPvalue, fromFPshift, toFPshift) ((sint8(FPvalue)) >> ((fromFPshift) - (toFPshift))) Converts a fixed-point number with shift=fromFPshift to an 8-bit fixed-point number with shift=toFPshift using right shifting LS_FXP2FXP16 (FPvalue, fromFPshift, toFPshift) ((sint16(FPvalue)) << ((toFPshift) - (fromFPshift))) Converts a fixed-point number with shift=fromFPshift to a 16-bit fixed-point number with shift=toFPshift by using left shifting RS_FXP2FXP16 (FPvalue, fromFPshift, toFPshift) ((sint16(FPvalue)) >> ((fromFPshift) - (toFPshift))) Converts a fixed-point number with shift=fromFPshift to a 16-bit fixed-point number with shift=toFPshift right shifting LS_FXP2FXP32 (FPvalue, fromFPshift, toFPshift) ((sint32(FPvalue)) << ((toFPshift) - (fromFPshift))) Converts a fixed-point number with shift=fromFPshift to a 32-bit fixed-point number with shift=toFPshift using left shifting RS_FXP2FXP32 (FPvalue, fromFPshift, toFPshift) ((sint32(FPvalue)) >> ((fromFPshift) - (toFPshift))) Converts a fixed-point number with shift=fromFPshift to a 32-bit fixed-point number with shift=toFPshift using right shifting