Page 120 - Understanding Automotive Electronics
P. 120
2735 | CH 4 Page 107 Tuesday, March 10, 1998 11:06 AM
MICROCOMPUTER INSTRUMENTATION AND CONTROL 4
Condition Code Register
The condition code reg- The other 8-bit register, the condition code (CC) register (also called status
ister, also called the sta- register), indicates or flags certain conditions that occur during accumulator
tus register, indicates operations. Rules are established in the design of the microprocessor so that a 1
certain conditions that or 0 in the bit position of the CC register represents specific conditions that
take place during various have happened in the last operation of the accumulator. The bit positions and
accumulator operations. rules are shown in Figure 4.5a. One bit of the CC register indicates that the A
register is all zeros. Another bit, the carry bit, indicates that the last operation
performed on the accumulator caused a carry to occur. The carry bit acts like
the ninth bit of the accumulator. Notice what happens when we add 1 to 255
in binary:
Decimal Binary
255 11111111
+ 1 + 1
256 100000000
The condition code reg- The eight bits in the accumulator are all zeros, but the carry bit being set
ister can indicate if the to a 1 (high) indicates that the result is actually not 0, but 256. Such a
value contained in the condition can be checked by examining the CC register carry bit for a 1.
accumulator is negative. The condition code register also provides a flag that, when set to a 1,
This gives the CPU the indicates that the number in the accumulator is negative. Most
ability to represent a microcomputers use a binary format called two’s complement notation for doing
much wider range of arithmetic. In two’s complement notation, the leftmost bit indicates the sign
numbers. of the number. Since one of the 8 bits is used for the sign, 7 bits (or 15 if 16
bits are used) remain to represent the magnitude of the number. The largest
positive number that can be represented in two’s complement with 8 bits is
+127 (or +32,767 for 16 bits); the largest negative number is –128 (–32,768).
Since the example accumulator is only 8 bits wide, it can handle only 1 byte at
a time. However, by combining bytes and operating on them one after
another in time sequence (as is done for 16-bit arithmetic), the computer can
handle very large numbers or can obtain increased accuracy in calculations.
Handling bits or bytes one after another in time sequence is called serial
operation.
Branching
Instructions that direct The CC register provides programmers with status indicators (the
the microcomputer to flags) that enable them to monitor what happens to the data as the program
other parts of the pro- executes the instructions. The microcomputer has special instructions that
gram are called branches. allow it to go to a different part of the program. Bits of the CC register are
Branches may be condi- labeled in Figure 4.5a. Typical branch-type instructions are shown in
tional or unconditional. Figure 4.5b.
UNDERSTANDING AUTOMOTIVE ELECTRONICS 107