We write a program in the 8085 which is written in assembly language just for the implementation of a decimal counter which is used by the logic controller interface. The input of the starting count must be the input through the complete interface and moreover we display the count on the interface.
Let us consider a sample program on this –
The program which follows it should always contain an infinite loop until the inputs of the user contains a valid value of two-digit Binary Coded Decimal value just only to the Port B. After that the initial count gets displayed by sending it to Port A. After the delay of every 0.5 sec the value of the count gets incremented by 1 in the decimal and is just sent to Port A terminal for the display. Just after rolling of the count value over to 00 from 99, the repetition of the operation is done without any end.
Here is the sample program code.
; FILE NAME COUNTER.ASM ORG C000H PA EQU D8H PB EQU D9H PC EQU DAH CTRL EQU DBH DELAY EQU 04BEH MVI A, 10001010B OUT CTRL ; Configure 8255 ports in desired modes ; All the next 9 instructions will ensure that control is transferred to next portion of program ; only after Port B receives a valid 2-digit BCD input. AGAIN: IN PB ANI 0FH CPI 0AH JNC AGAIN IN PB ANI F0H CPI A0H JNC AGAIN IN PB REPEAT: OUT PA ; Now displaying the count value PUSH PSW LXI D, FFFFH CALL DELAY ; Generating delay of 0.5 second POP PSW ADI 01H DAA ; Incrementing A value in decimal JNZ REPEAT JMP AGAIN