Statement:The delay routine given below is in infinite loop, identify the error and correct the program.
Delay routine with error:
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:
Related Programs (Click down)