Skip to content
Related Articles

Related Articles

8085 program for hexadecimal counter
  • Last Updated : 12 Dec, 2018

Write a program to count continuously in hexadecimal from FFH to 00H in a system with clock frequency 0.5 microseconds. Use register C to set up a delay of 1ms between each count and display output at one of the output ports.

Problem Analysis:

  1. The hexadecimal counter is set by loading a register with starting number and decrementing it till zero is reached and then again decrementing it to will produce -1, which is two’s complement of FFH. Hence, the register again reaches FFH.
  2. The 1ms time delay is set up by the procedure shown in flowchart-
    time delay
    The register is loaded with appropriate number such that the execution of above loop produces a time delay of 1ms.

Program:

AddressLabelMnemonics
2000HMVI B, FFH
2002HNEXTDCR B
2003HMVI C, COUNT
2005HDELAYDCR C
2006HJNZ DELAY
2009HMOV A, B
200AHOUTPORT#
200CHJMP NEXT

The C register is the time delay register which is loaded by a value COUNT to produce a time delay of 1ms.
To find the value of COUNT we do-

TD = TL + TO
where- TD = Time Delay
TL = Time delay inside loop
TO = Time delay outside loop

The delay loop includes two instructions- DCR C (4 T-states) and JNZ (10 T-states)
So TL = 14*Clock period*COUNT
=> 14*(0.5*10-6)*COUNT
=> (7*10-6)*COUNT



Delay outside the loop includes-
DCR B : 4T
MVI C, COUNT : 7T
MOV A, B : 4T
OUTPORT : 10T
JMP : 10T
Total : 35T

TO= 35*Clock period => 17.5 microseconds

So, 1ms= (17.5+ 7*COUNT)microsecond

Therefore, COUNT=(140)10

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :