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
(A) 1
(B) 255
(C) 256
(D) Will not come out of the loop
Answer: (C)
Explanation:
A1: MOV AL, 00H // value of AL =0000 0000 INC AL // INCREMENT AL JNZ A1 // jump to A1 when AL=0
AL = 0000 0000
Next step is for increment the value of AL. So, AL will keep on incrementing and after 255th iteration the value will become 1111 1111, again the condition is checked and incremented, now in 256th iteration AL = 1 0000 0000.
As AL is an 8-bit register, 1 is discarded and the value becomes 0000 0000 and conditional jump to A1 occurs.
So, total 256 iterations.
Option (C) is correct.
Quiz of this Question