GATE Computer ScienceHardGATE CS (PYQ pattern)

An 8-bit CPU compares A = 0x7F with B = 0x80 by computing A + (~B) + 1 and sets flags N (sign of result), Z, C (carry-out of the adder) and V (signed overflow). Which of the following are true? I. N = 1 II. V = 1 III. C = 1 IV. A < B as signed numbers according to N ⊕ V V. A < B as unsigned numbers according to C = 0

  1. A. I, II and IV only
  2. B. I, II and V only
  3. C. I, IV and V only
  4. D. II, III and V only

Correct answer: B. I, II and V only

A − B = 127 − (−128) = 255 does not fit in signed 8 bits: the result pattern 0xFF has N = 1 and V = 1. There is no carry-out because 0x7F < 0x80 unsigned, so C = 0 (borrow) and unsigned A < B. N ⊕ V = 0, correctly reporting that A is not less than B signed.

More Digital Logic questions

Exams that ask this topic