305 views

In the program below, the number of ​times the FIRST and SECOND JNZ instructions cause the control to be transferred to LOOP respectively

 MVI H, 02H MVI L, 05H LOOP: DCR L ; Decrement L by 1 FIRST: JNZ LOOP DCR H SECOND: JNZ LOOP
1. 5 and 2
2. 4 and 1
3. 259 and 1
4. 260 and 1
retagged | 305 views
0

...................

just conver above code into Loops

L=5,H=2;
DO
{
L=L-1
If(L>0)
{
PRINT("LOOP") // prints 4 times
}
}WHILE(L>0)

L=0; After above code.

DO
{
H=H-1;
IF(H>0)
{
print("LOOP"); // prints 1 time
DO
{
L=L-1 // 0-1 give -1 and so on ... it will run -1 to -128 and 127 to 1 total 255 times
If(L>0)
{
PRINT("LOOP") // 255 times printed
}
}
}

So because of L= 4+255 = 259 times and Because of H=1 times.
edited by
0
Please explain how 127 will come after value reaches to -128..
0
#include<stdio.h>
int main()
{
char i=0;
int b;
while(1)
{
i=i-1;
printf("%d \t",i);
if (i==0)

break;
}

/* i=-128;
b=(((int)i)-1);
printf("%d",b); */

}
+2
after -128 it will become -129 in 2's complement :

that is 101111111 but our no is of only 8 bit msb 1 is truncated and it gives 127 ...
0
Good explanation bro.

+1 vote
1