In: Computer Science
Draw the layout of the PSW register of the 8051 Microcontroller and explain its flags with examples.
PSW REGISTER OF THE 8051
The program status word (PSW) register is an 8-bit register.It is also referred to as the flag register. Although the PSW register is 8 bits wide, only 6 bits of it are used by the 8051.The two unused bits are user-definable flags. Four of the flags are called conditional flags, meaning that they indicate some conditions that result after an instruction is executed. These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow).As seen from below figure, the bits PSW.3 and PSW.4 are designated as RS0 and RS1 as register selection bit, respectively, and are used to change the bank registers.The PSW.5 and PSW.l bits are general-purpose status flag bits and can be used by the programmer for any purpose. In other words, they are user definable. See below Figure for the bits of the PSW register.
CY, the carry flag
AC, the auxiliary carry flag
P, the parity flag
OV, the overflow flag
instruction that affect flags of PSW
Show the status of CY, AC, and P flags after the addition of 9CH and 64H in the following instruction.
MOV A, #9CH
ADD A, # 64H
Solution: 9C 10011100 +64 01100100 100 00000000 CY = 1 since there is a carry beyond D7 bit AC = 0 since there is a carry from D3 to D4 P = 0 because the accumulator has even number of 1's