How many number of times the instruction sequence below will loop before…

2013

How many number of times the instruction sequence below will loop before coming out of the loop?

A1:  MOV AL, 00H
     INC AL
     JNZ A1 
  1. A.

    1

  2. B.

    255

  3. C.

    256

  4. D.

    Will not come out of the loop

Attempted by 28 students.

Show answer & explanation

Correct answer: D

The instruction sequence creates an infinite loop because the Zero Flag is never cleared. Initially, MOV AL, 00H sets the accumulator to zero. Then INC AL increments it to one, making the Zero Flag false (since 1 ≠ 0). The JNZ A1 instruction checks if the result is non-zero; since it is, execution jumps back to label A1. Crucially, the MOV instruction resets AL to zero every time the loop restarts, so INC always produces 1. Because JNZ only exits when the result is zero (which never happens after incrementing from 0), the loop condition remains true forever. Option A is incorrect because the jump occurs immediately after incrementing, not once. Options B and C are wrong since the counter never reaches 255 or 256 due to the reset. Thus, the program will never exit.

Explore the full course: Isro