Again, remember that the carry flag must be set before a subtraction operation, so that a borrow can be detected as C 0.
DIGIT CARRY (DC)
A file register can be seen as containing 8 individual bits, or 1 byte. It can also be used as 2 4-bit nibbles (a small byte!). Each nibble can be represented as
1 hex digit (0-F). The digit carry records a carry from the most significant bit of the low nibble (bit 3). Hence the digit carry allows 4-bit hexadecimal arith- metic to be carried out in the same way as 8-bit binary arithmetic uses the carry flag C.
REGISTER BANK SELECT (RP1:RP0)
The PIC 16F877 file register RAM is divided into four banks of 128 locations, banks 0–3 (Figure 2-3 in data sheet). At power on reset, bank 0 is selected by default. To access the others, these register bank select bits must be changed, as shown in Table 1.5.
It can be seen that some registers repeat in more than one bank, making it easier and quicker to access them when switched to that bank. For example, the status register repeats in all banks. In addition, a block of GPRs at the end of each bank repeat, so that their data contents are available without changing banks.
The register banks are selected by setting and clearing the bits RP0 and RP1 in the status register. More conveniently, the pseudo-operation BANKSEL can be used instead. The operand for BANKSEL is any register in that bank, or its label. In effect, BANKSEL detects the bank bits in the register address and copies them to the status register bank select bits.