OPTIMIZATIONS
Function
-Cni
None
None
__CNI__
None
The -Cni option enhances character operation code density by omitting integral promotion. This option enables behavior that is not ANSI-C compliant.
In ANSI-C operations with data types, anything smaller than int must be promoted to int (integral promotion). With this rule, adding two unsigned character variables causes the Compiler to zero-extend each character operand, and add them as int operands. Integral promotion is unnecessary when the result will be stored as a character. Using this option, the Compiler avoids promotion when possible. Performing operations on a character base instead of an integer base may decrease code size.
In most expressions, ANSI-C requires char type variables to be extended to the next larger type int, which requires a 16-bit size, according to ANSI standard. The -Cni option suppresses this ANSI-C behavior and thus allows the use of 'characters' and 'character-sized constants' in expressions.
The ANSI standard requires that old-style function declarations using the char parameter be extended to int. The -Cni option disables this extension and saves additional RAM.
Refer the following listing.
old_style_func (a, b, c) char a, b, c; { ... }
The space reserved for a, b, and c is one byte each, instead of two.
For expressions containing different types of variables, the following conversion rules apply:
signed char a, b; if (a > b * (signed char)129)