|
P控制规律如下:南北路口的绿灯、东西路口的红灯同时亮30秒;
南北路口的黄灯闪烁5次,同时东西路口的红灯继续亮;
南北路口的红灯、东西路口的绿灯同时亮30秒;
南北路口的红灯继续亮,同时东西路口的黄灯闪烁5次;
不断重复。
ORT_A EQU 2A0H ;8255 PORT A ADDRESS
PORT_B EQU 2A1H ;8255 PORT B ADDRESS
PORT_C EQU 2A2H ;8255 PORT C ADDRESS
CMD_PORT EQU 2A3H
PORT_CS EQU 2A3H
CODE SEGMENT
ASSUME CS:CODE
START:
MOV AL,10000011B ;PORT_A 和PORT_C 高四位均为输出,PORT_C的低四位为输入端,工作于0方式
MOV DX,PORT_CS
OUT DX,AL
SHOW:
MOV DX,PORT_A
MOV AL,00100100B
OUT DX,AL
MOV CX,5
HUANG4:
CALL TIMING
LOOP HUANG4
CALL TIMING
MOV CX,5
HUANG:
MOV AL,01000100B
OUT DX,AL
CALL TIMING
MOV DX,PORT_A
MOV AL,00000100B
OUT DX,AL
CALL TIMING
LOOP HUANG
MOV AL,10000001B
OUT DX,AL
CALL TIMING
MOV CX,5
HUANG2:
CALL TIMING
LOOP HUANG2
MOV CX,5
HUANG3:
MOV AL,10000010B
OUT DX,AL
CALL TIMING
MOV DX,PORT_A
MOV AL,10000000B
OUT DX,AL
CALL TIMING
LOOP HUANG3
JMP SHOW
TIMING PROC NEAR
CALL DELAY
RET
TIMING ENDP
DELAY PROC NEAR
PUSH CX
PUSH BX
MOV BX,0FFH
DELAY_:
MOV CX,0FFH
DELAY_AGAIN:
LOOP DELAY_AGAIN
DEC BX
JNZ DELAY_
POP BX
POP CX
RET
DELAY ENDP
CODE ENDS
END START
两个灯同时亮老是不会延迟 高手帮帮俺吧 小弟谢了!!!
|
|