11.07.2015 Views

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

PicC 9.50 dsPIC Manual.pdf

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

PsectsC Language Featuresunsigned char a, b, c;a = b + c;Strictly speaking, this statement requires that the values of b and c should be promoted to unsignedint, the addition performed, the result of the addition cast to the type of a, and then the assignmentcan take place. Even if the result of the unsigned int addition of the promoted values of b and cwas different to the result of the unsigned char addition of these values without promotion, afterthe 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 an a 32-bit addition, the compiler will encode the former.If, in the above example, the type of a was unsigned int, then integral promotion would haveto be performed to comply with the ANSI standard.3.8.2 Shifts applied to integral typesThe ANSI standard states that the result of right shifting (> > operator) signed integral types isimplementation defined when the operand is negative. Typically, the possible actions that can betaken are that when an object is shifted right by one bit, the bit value shifted into the most significantbit 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.HI-TECH <strong>dsPIC</strong>C performs a sign extension of any signed integral type (for example signedchar, signed int or signed long). Thus an object with the signed int value 0x0124 shiftedright one bit will yield the value 0x0092 and the value 0x8024 shifted right one bit will yield thevalue 0xC012.Right shifts of unsigned integral values always clear the most significant bit of the result.Left shifts (< < operator), signed or unsigned, always clear the least significant bit of the result.3.8.3 Division and modulus with integral typesThe sign of the result of division with integers when either operand is negative is implementationspecific. Table 3.6 shows the expected sign of the result of the division of operand 1 with operand 2when compiled with HI-TECH C.In the case where the second operand is zero (division by zero), the result will always be zero.3.9 PsectsThe compiler splits code and data objects into a number of standard program sections referred toas psects. The HI-TECH assembler allows an arbitrary number of named psects to be included inassembler code. The linker will group all data for a particular psect into a single segment.44

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!