Back to the 2021 paper

Module 2: The 8051 Architecture

20217m

What is the difference between over-flow and carry flag? Explain with an example.

Worked SolutionAI Assisted

Carry (CY) vs Overflow (OV) – Difference with Example

  • CY (PSW.7): Unsigned overflow – carry out of bit7. 1 if result exceeds 255 (addition) or borrow in subtraction. For unsigned numbers.
  • OV (PSW.2): Signed overflow – carry into sign bit XOR carry out. 1 if signed result exceeds -128..127. For signed 2's complement.

Example:

  1. MOV A,#0FFH; ADD A,#01H → A=00H, CY=1 (unsigned overflow 255+1), AC=1, OV=0 (signed -1+1=0 no overflow). CY indicates unsigned wrap.
  2. MOV A,#7FH; ADD A,#01H → A=80H, CY=0 (no unsigned overflow), OV=1 (signed 127+1 = -128 overflow). This shows signed overflow without carry.

Check: OV = CY6 XOR CY7.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.