Special Function Registers
These numbered registers provide dedicated program control registers and processor status bits. In the PIC, the program counter, port registers and spare registers are all mapped as part of a block that starts at zero and ends at 0Bh in the 16F84A. For example, the program counter is register number 02. The working register is the only one that is not located in the main register block, and is accessed by specifying it in the instruction.
All processors contain control and status registers whose bits are used individually to set up the processor operating mode, or record significant results from those operations. In the PIC 16, the status register is located at SFR 03. The most frequently used bit is the zero flag. This is internally set to 1 if the result of any operation is zero in the destination register (the register that receives the result). The carry (C) flag is another bit in the status register; it is set if the result of an arithmetic operation produces a carry-out of the most significant bit of the destination register, that is, the register overflows.
The status register bits are often used to control program sequence by conditional branching. Alternate sections of code are executed depending on the condition of the status flag. In the PIC instruction set, this is achieved by an instruction that tests the bit and skips the next instruction if it is 0 or 1. The bit test and skip instruction is generally followed by a jump instruction to take the execution point to another part of the program, or not, as the case may be. This will be explained more fully in the next section.
The most important SFRs in the 16F84A are listed in Table 2.1. The RAM is divided into blocks, where bank 0 contains registers 00h to 7Fh, bank 1 registers 80h to FFh and so on, that is, 128 registers per bank. The SFRs are located at the bottom (lowest addresses) of each register bank (but the data sheet RAM block diagram shows them at the top). Some registers are duplicated in different banks (e.g. program counter, PCL), while others are unique data direction register, TRISA). More complex chips that need more registers have extra banks of RAM. For example, the 16LF1826 has eight. The exact arrangement for each chip