Microprocessors: From Assembly Language to C Using thePIC18Fxx2

Chapter 4: Unsigned 8-Bit Arithmetic, Logical, Conditional Operations

This chapter examines additional features of the PIC18Fxx2 instruction set architecture in the context of unsigned 8-bit arithmetic, bitwise logical, and shift operations. These operations are used to implement equality, inequality, and comparison tests for conditional code execution and loop control.

4.1 LEARNING OBJECTIVES

After reading this chapter, you will be able to:

  • Describe the operation of the bit manipulation instructions of the PIC18 instruction set.

  • Translate C language statements that perform 8-bit addition, subtraction, bitwise logical, and shift operations into PIC18 instruction sequences.

  • Translate C language statements that perform 8-bit zero, nonzero, equality, inequality, and unsigned comparison operations into PIC18 instruction sequences.

  • Translate C conditional statements and loop structures such as do-while, while-do, and for{} into PIC18 instruction sequences.

4.2 BITWISE LOGICAL OPERATIONS, BIT OPERATIONS

Table 4.1 lists the C language arithmetic and logical operators discussed in this book. As seen in the previous chapter, the arithmetic/logic unit (ALU) implements these operations in the processor data path. The previous chapter covered some of the arithmetic capabilities of the ALU such as addition, subtraction, increment, and decrement. The bitwise logical operators & (AND), (OR), ^ (XOR), and ~ (complement) comprise the logical operations performed by the ALU.

Table 4.1: C Language Arithmetic and Logical Operators

Operator

Description

+, -

(+) addition, (-) subtraction

++, --

(++) increment, (--) decrement

*, /

(*) multiplication, (/) division

>>, <<

right shift (>>), left shift (<<)

&, , ^

bitwise AND (&), OR (),...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Arithmetic Logic Units (ALU)
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.