SECTION IV-1: Bits of PIC Status Register

The PIC has a flag register to indicate arithmetic conditions such as the carry bit. The flag register in the PIC is called the status register.

The PIC18 Status Register:-

The status register is an 8-bit register. It is also referred to as the flag register. The status register is 8 bits wide. 5 bits of status register is used by the PIC18. The three unused bits are unimplemented and read as 0. The 5 flags are called conditional flags. They indicate  some conditions that result after an instruction is executed. these five flags are  as follows:

  1. C (carry)
  2. DC (digital carry)
  3. Z (zero)
  4. OV (Over flow)
  5. N (Negative)

Each of the conditional flags can be used to perform a conditional branch (jump)

Bits of Status Register


The brief explanation of the flag bits of the status register and the impact of instructions on this register is discussed below:

  •  The CARRY Flag:-

This flag is set wherever there is a carry out from the D7 bit. This flag bit is affected after an 8-bit addition or subtraction.

  •  DC, The Ditigal Carry Flag:-

If there is a carry from D3 to D4 during an ADD or SUB operation, this bit is set, otherwise, it is cleared. This flag bit is used by instructions that perform BCD (binary coded decimal) arithmetic. In some microprocessors this is called the AC (auxiliary carry flag).

  •  Z, The Zero Flag:-

The zero flag reflects the result of an arithmetic or logic operation. If the result is zero, then Z=1. The result is not zero if Z=0.

  •  OV, The overflow Flag:-

This flag is set whenever the result of a signed number operation is too large, causing the high order bit to overflow into the sign bit. In general, the carry flag is used to detect errors in unsigned arithmetic operations while the overflow flag is used to detect errors in signed arithmetic operations. The OV and N flag bits are used for the signed number arithmetic operations.

  •  N, The Negative Flag:-

Binary representation of signed numbers uses D7 as the sign bit. The negative flag reflects the result of an arithmetic operation. If the D7 bit of the result is zero, then N = 0 and the result is positive. If the D7 bit is 1, then N = 1 and the result is negative. The negative and OV flag bits are used for the signed number arithmetic operations.


More From