-3

What will the carry flag (CF), the overflow flag (OF), the sign flag (SF) and the zero flag (ZF) be set to if the following arithmetic is done in an 8-bit register?

0xFE + 0xFB

  1. CF=1, OF=0, SF=1, ZF=0
  2. CF=1, OF=1, SF=0, ZF=0
  3. CF=1, OF=0, SF=1, ZF=1
  4. CF=1, OF=1, SF=1, ZF=0
  5. None of the above.

Thanks

Exercise question from William Stallings - Computer organization and architecture.

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847

1 Answers1

0

CF = 1 because there is an overflow (the unsigned result is 0x1F9 which does not fit in 8 bits)

OF = 0 because we add 2 negative numbers and the result is also negative

SF = 1 because the result is negative (bit 7 of the result is set)

ZF = 0 because the result is not zero

So the answer is 1. Also see about assembly CF(Carry) and OF(Overflow) flag

memo
  • 1,868
  • 11
  • 19