SW500010 Microchip Technology, SW500010 Datasheet - Page 94

HI-TECH C PRO FOR PIC10/12/16

SW500010

Manufacturer Part Number
SW500010
Description
HI-TECH C PRO FOR PIC10/12/16
Manufacturer
Microchip Technology
Type
Compilerr
Series
PIC10/12/16r
Datasheets

Specifications of SW500010

Supported Families
PIC10, PIC12, PIC16
Core Architecture
PIC
Software Edition
Professional
Kit Contents
Software And Docs
Mcu Supported Families
PIC10/12/16
Tool Type
Compiler
Lead Free Status / RoHS Status
Not applicable / Not applicable
For Use With/related Products
PIC10, PIC12, PIC14, PIC16, PIC16E
Lead Free Status / Rohs Status
Lead free / RoHS Compliant
Other names
019P
778-1006
778-1006
Operators
operator toggles each bit within a value. Consider the following code.
c = 0x55;
if( ~c == 0xAA)
count++;
FFAAh and so the comparison in the above example would fail. The compiler may be able to issue
a mismatched comparison 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 C will not perform the integral promotion so as to increase the code efficiency.
Consider the following example.
a = b + c;
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 with-
out promotion, after the unsigned int result was converted back to unsigned char, the final
result would be the same. If an 8-bit addition is more efficient than a 16-bit addition, the compiler
will encode the former.
have to be performed to comply with the ANSI standard.
3.7.2 Shifts applied to integral types
The ANSI standard states that the result of right shifting (> > operator) signed integral types is
implementation defined when the operand is negative. Typically, the possible actions that can be
taken are that when an object is shifted right by one bit, the bit value shifted into the most significant
bit of the result can either be zero, or a copy of the most significant bit before the shift took place.
The latter case amounts to a sign extension of the number.
integral type (for example signed char, signed int or signed long). Thus an object with
the signed int value 0x0124 shifted right one bit will yield the value 0x0092 and the value
0x8024 shifted right one bit will yield the value 0xC012.
94
Another problem that frequently occurs is with the bitwise compliment operator, “~”. This
unsigned char count, c;
If c contains the value 55h, it often assumed that ~c will produce AAh, however the result is
The consequence of integral promotion as illustrated above is that operations are not performed
unsigned char a, b, c;
Strictly speaking, this statement requires that the values of b and c should be promoted to
If, in the above example, the type of a was unsigned int, then integral promotion would
HI-TECH C PRO for the PIC10/12/16 MCU Family performs a sign extension of any signed
Right shifts of unsigned integral values always clear the most significant bit of the result.
C Language Features

Related parts for SW500010