Free Electronic Circuits & 8085 projects

Electronic projects with circuit diagram and 8085 microprocessor projects.

Debug the delay routine

Published on Nov 18 2009 // Working with Counters

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:

  • DELAY    :  LXI H, N :Load 16 bit count
  • L1     :   DCX H         : Decrement count
  •      MOV A, L
  •     ORA H      : logically OR Hand L
  •     JNZ L1 : If result is not 0 repeat

Related Programs (Click down)

Data transfer from one memory block  to other memory block.

Find the factorial of a number

Find the Square Root of a given number

Split a HEX data into two nibbles and store it