Q. Pedestrian crossing lights are installed at the zebra crossing as shown in the figure below.
The system is controlled by an 8085 microprocessor. Write an assembly language
program for 8085 to operate the lights continuously with one light on while the other is
off. The green light is turned on for 4 seconds and red light for 10 seconds. Use
subroutine for the delay, during each light operation. Assume the clock frequency of
8085 is 3MHz.
Solution:
Main Program
START: MVI A, 01H ; turn the green light on
OUT 66H
MVI C, 08h ; time required to turn on green light
LABEL1: CALL DELAY
DCR C
JNZ LABEL1
MVI A, 80H ; turn the red light on
OUT 66H
MVI C, 14H ; time required to turn on red light
LABEL2: CALL DELAY
DCR C
JNZ LABEL2
JMP START ; repeat the task
Delay Subroutine
DELAY: LXI H, F69AH ; count for 0.5 second delay
LABEL3: DCX H
MOV A, L
ORA H
JNZ LABEL3
RET
The system is controlled by an 8085 microprocessor. Write an assembly language
program for 8085 to operate the lights continuously with one light on while the other is
off. The green light is turned on for 4 seconds and red light for 10 seconds. Use
subroutine for the delay, during each light operation. Assume the clock frequency of
8085 is 3MHz.
Solution:
Main Program
START: MVI A, 01H ; turn the green light on
OUT 66H
MVI C, 08h ; time required to turn on green light
LABEL1: CALL DELAY
DCR C
JNZ LABEL1
MVI A, 80H ; turn the red light on
OUT 66H
MVI C, 14H ; time required to turn on red light
LABEL2: CALL DELAY
DCR C
JNZ LABEL2
JMP START ; repeat the task
Delay Subroutine
DELAY: LXI H, F69AH ; count for 0.5 second delay
LABEL3: DCX H
MOV A, L
ORA H
JNZ LABEL3
RET
Comments
Post a Comment