Microprocessors: From Assembly Language to C Using thePIC18Fxx2

This chapter applies the arithmetic, logical, and shift operations discussed in the previous chapter to extended precision operands; that is, operands that are larger than 8 bits. Furthermore, signed number representation and its effect on shift and comparison operations are covered.
After reading this chapter, you will be able to:
Translate C language statements that perform extended-precision addition, subtraction, bitwise logical, and shift operations into PIC18 instruction sequences.
Compare and contrast signed magnitude, one's complement, and two's complement representations of signed integers.
Translate C language statements that perform shift and comparison operations using signed operands into PIC18 instruction sequences.
Translate PIC18 instructions, such as branches, that use PC-relative addressing into machine code.
Previous chapters have used only the unsigned char data type in C programs, which limits these variables to a 0 to 255 integer range. Obviously, there is a need to accommodate larger number ranges both in C and in PIC18 assembly language programs. The short, int, and long data types in C are used for extended precision integers.
Table 5.1 shows the sizes and ranges of the char, short, int, and long data types for the HI-TECH C compiler used in this book (other C compilers for the PIC18 may use different data sizes). While a char data type is always a byte, the short, int, and long sizes are compiler and...