Statement:The delay routine given below is in infinite loop, identify the error and correct the program.
Delay routine with error:
DELAY : LXI H, N
L1 : DCX H
JNZ L1
Sol.:
1) The fault in the above program is at instruction JNZ L1. This
condition always evaluates to be true hence loops keep on executing and
hence infinite loop. 2) Reason for
infinite looping: - The instruction DCX H decrease the HL pair count one
by one but it does not affect the zero flag. So when count reaches to
OOOOH in HL pair zero flag is not affected and JNZ L1 evaluates to be
true and loop continues. Now HL again decrements below OOOOH and HL
becomes FFFFH and thus execution continues. 3) The modification in the program is as follows:
This Page is a little effort to make you Sharing of some own materials .This is just a Kick-Start to make the aware of Practical World !!! Best of luck.-DHRUVANG SUTHAR
0 Comments