2.4k views

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 | 2.4k views
+1

### 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 begins

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...

by Boss
edited
0
thanks fr the xplanation
+6

Both the case ANS will be 259,1

Part1:

It will go first L DEC 4 time(L=0) first then H DEC 1 time (H=0)and transfer control goto to LOOP.in this case L is again dec then it will become 255(11111111)

During the exicution of decrement instruction value 1 is subtract from the register content. When it will satisfied the minimum limit.then all 00000000 raising up to 11111111

00000000

-               1

11111111

So both the case PART1  and PART2 ans will be same but syntax is differ but exicution is same.

Ans:.  259 OR 1

ANS

0
But how can we say so surely that when L=0 and a decrement operation is performed then L will be rolled back to 1111 1111 (decimal-255)?
It is not written anywhere that the computer uses signed or unsigned data.By default, All computers use signed 2's complement representation.
0
-1 representation in 2's complement form is 1111 1111
0
Sir.... I dont understand in the first case what happen to DCR L when second transefer to the loop for the first time... According to your answer it seems like nothing happens and DCR H make H=00 and transfer fails..
0