edited by
1,407 views
5 votes
5 votes

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
edited by

1 Answer

Best answer
8 votes
8 votes
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

Related questions

1 votes
1 votes
1 answer
4
AakS asked Jul 23, 2017
2,730 views
What is the difference between LOAD/STORE & MOVE instructions?Are they CPU - architecture dependent?