retagged by
5,087 views
6 votes
6 votes

Question

  • Part- I

If the program below, the number of times the FIRST and SECOND JNZ instruction cause the control to be transferred to LOOP respectively
MVI H,02H
MVI L,05H
LOOP : DCR L
FIRST : JNZ LOOP
DCR H
SECOND : JNZ LOOP

A. 5 and 2
B. 21 and 1
C. 259 and 1
D. 260 and 1

   

  • Part- II 

If In place of DCR L instruction, if we use SUB L,#1.

The number of times the FIRST and SECOND JNZ instruction cause the control to be transferred to LOOP respectively

                                                                                                                                                                                   

  1.  5 and 2
  2.  260 and 1
  3.  259 and 1
  4.  6 and 1
retagged by

1 Answer

Best answer
9 votes
9 votes

MVI L,05H
LOOP : DCR L      ///////////  L==> 04
FIRST : JNZ LOOP            CONTROL transfered 1st time

LOOP : DCR L      ///////////  L==> 03
FIRST : JNZ LOOP            CONTROL transfered 2nd time

LOOP : DCR L      ///////////  L==> 02
FIRST : JNZ LOOP            CONTROL transfered 3rd time

LOOP : DCR L      ///////////  L==> 01
FIRST : JNZ LOOP            CONTROL transfered 4th time

LOOP : DCR L      ///////////  L==> 00
FIRST : JNZ LOOP            CONTROL transfered will not be transfred condition failed  now execute  next instruction

LOOP : DCR L
FIRST : JNZ LOOP
DCR H                                  /////////////h==>01
SECOND : JNZ LOOP         /////////////// CONTROL transfered 1st time

LOOP : DCR L
FIRST : JNZ LOOP
DCR H                                  /////////////h==>00
SECOND : JNZ LOOP         /////////////// CONTROL  will not be transfred condition failed

part 1 first = 4 ,,second ==1/////////////all options given are wrong

part---2 beginswink

MVI L,05H
LOOP : SUB L , #1       ///////////  L==> 04
FIRST : JNZ LOOP            CONTROL transfered 1st time

......will be same as above till  L==00//////////////means it ran 4times upto now

                           LOOP : SUB L , #1 
                           FIRST :JNZ LOOP
  next           DCR H              ///h==>01
                  SECOND : JNZ LOOP   //////CONTROL transfered 1st time

 

         LOOP :      SUB L , #1     //////  now this will be again executed SUB actually invokes carry flag but DCR doesn't

             

                         00000000 (carry flag will be generated )

subtract(--)     1111111 

                   11111111===>255  

               
                           FIRST :JNZ LOOP///////////////////so  first will again run 255 times

                  after that
                   DCR H              ///h==>00
                  SECOND : JNZ LOOP   //////CONTROL not transfered condition failed

so part2 first= 255+4 ==259 and second ==1...
           

edited by
Answer:

Related questions