Question 9Asked in UGC NET Computer Science, November 2017 (Paper II & III, Selected Questions)

Consider the following program fragment in assembly language :

Consider the following program fragment in assembly language : mov ax, 0h mov cx, 0A, h doloop : dec ax loop doloop What is the value of ax and cx registers after the completion of the doloop?
  1. Aax = FFF5 h and cx = 0 h
  2. Bax = FFF6 h and cx = 0 h
  3. Cax = FFF7 h and cx = 0A h
  4. Dax = FFF5 and cx = 0A h
Show answerHide answer

Correct answer: (B) ax = FFF6 h and cx = 0 h

Explanation

cx = 0Ah = 10, so the loop body runs 10 times; loop decrements cx and stops when cx = 0h. ax starts at 0 and is decremented 10 times: 0 − 10 = FFF6h (16-bit two's complement). So ax = FFF6h and cx = 0h.

From UGC NET Computer Science PYQ, November 2017 (Paper II & III, Selected Questions)

This is question 9 of UGC NET Computer Science PYQ, November 2017 (Paper II & III, Selected Questions). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.