June 24, 2021 :

Share

Program Status Word (PSW)

The PSW is an 8-bit register, its SFR memory location of D0H. PSW register is also called as Flag Register.

  1. 4 Arithmetic Flags (Carry, Auxiliary Carry, Overflow, Parity)
  2. 2 Register Select bits (RS0 and RS1)
  3. 2 User defined flags. (PSW.5 and PSW.1)
Program Status Register | PSW | rlc-eee
Carry Flag (C, PSW.7)

Bit Address: D7H

After performing Addition operation, if the carry is generated from the MSB (D7) bit, then carry = 1 other wise carry will be 0.

After performing Subtraction operation, if there is a borrow in to D7 bit, then carry = 1.

Carry flag can be directly modified by bit level instructions SETB and CLRB.

Auxiliary carry flag (AC, PSW.6)

Bit Address: D6H

AC is set to 1 when there is a carryout from D3 bit to D4 bit. (i.e., from Lower nibble to Higher nibble). AC used in conventional BCD arithmetic.

To understand how the carry flag and auxiliary flag is affected after arithmetic operations with examples, check out the video.




Flag 0 (F0, PSW.5)

Bit Address: D5H

It is a general-purpose flag. This flag is not affected by any arithmetic or logical operations.

Register Bank Select Bits (RS1 and RS0)

Bit Address: RS1- D4H, RS0-D3H

These bits are used to select the register bank as listed in the below table.

RS1 RS0 Bank
0 0 Bank 0
0 1 Bank 1
1 0 Bank 2
1 1 Bank 3
Overflow Flag (OV, PSW.2)

Bit Address: D2H

Overflow flag is set to 1, if either of the following condition occurs.

  1. There is a carry from D6 to D7 but no carry out from D7.
  2. There is a carry out from D7, but no carry from D6 to D7.

Overflow flag = C6 XOR C7

It is set to 1 to indicate that result of signed arithmetic is erroneous (out of range).

PSW.1

Bit Address: D1H

This bit is reserved for future use. This bit can be used as a user flag.

Parity (P, PSW.0)

Bit Address: D0H

Parity bit indicates the number of 1’s present in the Accumulator register.It is set to 1 if the accumulator register has odd number of ones, otherwise reset to 0.

Share

Tags : eee    ece    embedded system    microcontroller