Friday, February 17, 2012

Make a Digital Clock in 8085 programming | Programming Techniques

Make a Digital Clock in 8085 programming | Programming Techniques:


8085 is a assembly level programming. It uses a lot of mnemonics to write a code. To understand a lot of mnemonics is a negative part of any assembly level programming. The following code designs a digital clock with approximately 1 second delay (it depends upon your kits frequency). The delay is calculated by multiplying total T-states an time required for each T-states. It is a 12 hours clock and resets its time after 12 hours.

Source Code

MVI A,80H
OUT 43
START: MVI D,00H
NEXTHOUR:  
    MVI C,00H
NEXTMINUTE:
    MVI E,00H
NEXTSECOND:
    PUSH B
    CALL CALLING
    POP B
    INR E
    MOV A,E
    OUT 40
    CPI 3CH
    JNZ NEXTSECOND
    INR C
    MOV A,C
    OUT 41
    CPI 3CH
    JNZ NEXTMINUTE
    INR D
    MOV A,D
    OUT 42
    CPI CH
    JNZ NEXTHOUR
    JMP START
CALLING:  
    LXI B,FFFFH
DELAY:  
    DCX B
    MOV A,C
    ORA B
    NOP
    NOP
    RZ
    JMP DELAY  

The two lines of code : MVI A, 80 and OUT 43 is used to initialize output port. It varies on kit to kit. So see your manufacturer's specifications for this.