SW500007 Microchip Technology, SW500007 Datasheet - Page 75

PICC-18 PRO

SW500007

Manufacturer Part Number
SW500007
Description
PICC-18 PRO
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC18r
Datasheets

Specifications of SW500007

Supported Families
PIC18
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC18
Tool Function
Compiler
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / RoHS Compliant
For Use With/related Products
PIC18 Series
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
015P
778-1002
778-1002
C Language Features
The unsigned char result of a - b is 206 (which is not less than 10), but both a and b are con-
verted to signed int via integral promotion before the subtraction takes place. The result of the
subtraction with these data types is -50 (which is less than 10) and hence the body of the if() state-
ment is executed. If the result of the subtraction is to be an unsigned quantity, then apply a cast.
For example:
The comparison is then done using unsigned int, in this case, and the body of the if() would not be
executed.
operator toggles each bit within a value. Consider the following code.
If c contains the value 55h, it often assumed that ~c will produce AAh, however the result is FFAAh
and so the comparison above would fail. The compiler may be able to issue a mismatched compari-
son error to this effect in some circumstances. Again, a cast could be used to change this behaviour.
with char-type operands, but with int-type operands. However there are circumstances when the
result of an operation is identical regardless of whether the operands are of type char or int. In
these cases, HI-TECH PICC-18 STD will not perform the integral promotion so as to increase the
code efficiency. Consider the following example.
Strictly speaking, this statement requires that the values of b and c should be promoted to unsigned
int, the addition performed, the result of the addition cast to the type of a, and then the assignment
can take place. Even if the result of the unsigned int addition of the promoted values of b and c
was different to the result of the unsigned char addition of these values without promotion, after
the unsigned int result was converted back to unsigned char, the final result would be the same.
An 8-bit addition is more efficient than a 16-bit addition and so the compiler will encode the former.
to be performed to comply with the ANSI standard.
Another problem that frequently occurs is with the bitwise compliment operator, “~”. This
The consequence of integral promotion as illustrated above is that operations are not performed
If, in the above example, the type of a was unsigned int, then integral promotion would have
if((unsigned int)(a - b) < 10)
unsigned char count, c;
c = 0x55;
if( ~c == 0xAA)
unsigned char a, b, c;
a = b + c;
count++;
count++;
Operators
61

Related parts for SW500007