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