1,713 views
0 votes
0 votes
how many times the loop will be executed

LXI H,0106 H

DCR L

LOOP :DCX H

NZ LOOP

HLT

a)105 times    b) 261 times c) 0 times  d) forever

1 Answer

Best answer
3 votes
3 votes

HL register pair is 32 bit register . 

LXI H ,0106 H -- Thsi instruction mean intialize HL register pair HL with 0106 

SO H get  0000 0001 (01 )

L  get 0000 0110 (06)

DCR  L  (06-->05) this mean decrement content of L register so 06 get decremented to 05 

LOOP DCX  ( DCX decrement the register pait by 1 here HL is a register pair which will be decremnet by 1 )

So HL=0105.

Continue above process until HL doesnt get intailize to 00 

as soon it will be 00 it will violate NZ flag and reach to halt state 

So the above loop will run for 105 times 

NOTE (DCR=DECREMENT THE CONTENT OF REGISTER BY 1 , WHILE DCX DECREMENT THE CONTENTS OF REGISTER PAIR BY 1) :)

selected by

Related questions

2 votes
2 votes
0 answers
1
gailort asked May 11, 2022
799 views
A system is based on an 8-bit microprocessor and has two I/O devices. The I/O controllers for this system use separate control and status registers. Both devices handle d...
1 votes
1 votes
1 answer
2
vishnu777 asked Oct 12, 2021
249 views
I want to confirm the exact difference between a cpu and microprocessor and also between microprocessor and microcontroller.Anyone pls explain!
2 votes
2 votes
0 answers
3
Harikesh Kumar asked Jan 14, 2018
362 views
Please explain in detailed
0 votes
0 votes
0 answers
4
Na462 asked Nov 20, 2017
317 views
Can plz anybody explain with example:- RLC,RRC,RAL,RAR operators ,How they work?