Question

In: Computer Science

Draw the layout of the PSW register of the 8051 Microcontroller and explain its flags with examples.


Draw the layout of the PSW register of the 8051 Microcontroller and explain its flags with examples.

Solutions

Expert Solution

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

  • This flag is set whenever there is a carry out from the D7 bit.
  • This flag bit is affected after an 8-bit addition or subtraction.
  • It can also be set to 1 or 0 directly by an instruction such as “SETB C” and “CLR C” where “SETB C” stands for “set bit carry” and “CLR C” for “clear carry”.

AC, the auxiliary 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 is used by instructions that perform BCD (binary coded decimal) arithmetic.

P, the parity flag

  • The parity flag reflects the number of 1 s in the A (accumulator) register only.
  • If the A register contains an odd number of Is, then P = 1. Therefore, P = 0 if A has an even number of 1s.

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.
  • The overflow flag is only used to detect errors in signed arithmetic operations

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

Related Solutions

What is the purpose of the status register in PIC microcontroller architecture? Draw this register and...
What is the purpose of the status register in PIC microcontroller architecture? Draw this register and define the function of each of its bits. Find C, Z, and DC flag bits for each of the following codes: a) MOVLW 9FH ADDLW 61H C = , Z = , DC = b) MOVLW 82H ADDLW 22H C = , Z = , DC = c) MOVLW 67H ADDLW 99H C = , Z = , DC =
Give 4 examples of CLOSED LOOP control system and draw its block diagram
Give 4 examples of CLOSED LOOP control system and draw its block diagram
Draw the two transistor equivalent circuit of the SCR and explain its operation?
Draw the two transistor equivalent circuit of the SCR and explain its operation?
Q2. a) Explain the penetration test carried out on bitumen, state its significance and draw the...
Q2. a) Explain the penetration test carried out on bitumen, state its significance and draw the test apparatus. b). Mention the main factors considered in the choice of construction materials at the design office – is any of them more important than the other? c). What factors affect the weldability of steel? d). Consider the iron value chain from material extraction to disposal, at what point according to your assessment is the most energy used? As a design engineer, at...
What is consumerism? Explain this concept based on US examples of consumerism and its impact on...
What is consumerism? Explain this concept based on US examples of consumerism and its impact on US economy.
Explain the rule of law concept and give examples of its relevance to an international manager.
Explain the rule of law concept and give examples of its relevance to an international manager.
Choose any RC column section and draw its interaction diagram. Discuss and explain the process.
Choose any RC column section and draw its interaction diagram. Discuss and explain the process.
C)    Explain MVC architectural pattern and its components. Draw a diagram that describes the pattern. Describe...
C)    Explain MVC architectural pattern and its components. Draw a diagram that describes the pattern. Describe the behavior of MVC by using online shopping application that has the following responsibilities: browse catalog, add item to shopping cart, remove item from shopping cart, display shopping cart. State the two advantages and two disadvantages of using this pattern.
Draw a flow chart of the Staffing/hiring Process at organizations. Explain each step and its significance...
Draw a flow chart of the Staffing/hiring Process at organizations. Explain each step and its significance in the process. With the help of flow chart, explain the training process. Explain how can the training programmes effectiveness be evaluated? What are the various types of cost involved with Training programmes?
Draw a flow chart of the Staffing/hiring Process at organizations. Explain each step and its significance...
Draw a flow chart of the Staffing/hiring Process at organizations. Explain each step and its significance in the process.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT