Question

Q41, 47 and 50

40. Show how you woulu VIILUK WIICICI IU T 41. Give the bit addresses assigned to the flag bit of CY, P, AC, and OV. 42. Of t

0 0
Add a comment Improve this question Transcribed image text
Answer #1

41] Flag register - The 8051 has a flag register to indicate arithmetic conditions such as the carry bit.

                                   The flag register in the 8051 is called the program status word (PSW) register.

PROGRAM STATUS WORD REGISTER [PSW] :     

1.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.

2. 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.

3. These four are CY (carry), AC (auxiliary carry), P (parity), and OV (overflow).

CY AC F0 RS1 RS0 OV -

P

      CY         PSW,7     Carry Flag.

     AC         PSW,6     Auxiliary carry flag.

      F0         PSW,5     Available to the user for general purpose.

     RS1        PSW,4     Register bank selector bit1.

     RS0        PSW,3     Register bank selector bit0.

    OV           PSW,2     Overflow flag.

    -              PSW,1     User definable bit.

    P              PSW,0     Parity flag.

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 Is.

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.

50 ]

INSTUCTIONS FOR Carry Flag :

If there is an carry out from the D7 bit during an operation, CY is set; otherwise CY is cleared.

❍ The CY is used to detect errors in arithmetic operations.

❍ FFH+80H=17FH ⇒ Carry out overflow

❍ It is large than the data range of 8-bit register. 1111 1111 1000 0000 1 0111 1111 Overflow CY=1

                                 

Add a comment
Know the answer?
Add Answer to:
Q41, 47 and 50 40. Show how you woulu VIILUK WIICICI IU T 41. Give the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT