交通灯的黄灯很暗
STACK SEGMENT STACK
DB 200 DUP(0)
STACK ENDS
DATA SEGMENT
LIVING DB 'NOW IS DAY ,EVERY THING IS NOMAL!',0AH,0DH,00H
NIGHT DB 'NOW IS NIGHT,TRAFFIC IS NOT BUSY LIKE DAY!',0AH,0DH,00H
VIP DB 'NOW IS VIP TIME!',0AH,0DH,00H
TIME DB 00H,03H,05H,03H
LEDTAL DB 3FH,06H,5BH,4FH,66H,6DH,7DH,07H,7FH,6FH,73H,38H
COUNT DW 0
DATA ENDS
CODE SEGMENT
ASSUME CS:CODE,DS:DATA,SS:STACK
START:
MOV AX,DATA
MOV DS,AX
PUSH DS
MOV AX,0000H
MOV DS,AX
MOV AX,OFFSET IRQ0
ADD AX,2000H
MOV SI,0020H
MOV [SI],AX
MOV AX,0000H
MOV SI,0022H
MOV [SI],AX
CLI
POP DS
IN AL,21H
AND AL,0FEH
OUT 21H,AL
PUSH DS
MOV AX,0000H
MOV DS,AX
MOV AX,OFFSET IRQ1
ADD AX,2000H
MOV SI,0024H
MOV [SI],AX
MOV AX,0000H
MOV SI,0026H
MOV [SI],AX
CLI
POP DS
IN AL,21H
AND AL,0FDH
OUT 21H,AL
PUSH DS
MOV AX,0000H
MOV DS,AX
MOV AX,OFFSET IRQ2
ADD AX,2000H
MOV SI,0028H
MOV [SI],AX
MOV AX,0000H
MOV SI,002AH
MOV [SI],AX
CLI
POP DS
IN AL,21H
AND AL,0EFH
OUT 21H,AL
PUSH DS
MOV AX,0000H
MOV DS,AX
MOV AX,OFFSET IRQ7
ADD AX,2000H
MOV SI,003CH
MOV [SI],AX
MOV AX,0000H
MOV SI,003EH
MOV [SI],AX
CLI
POP DS
IN AL,21H
AND AL,7FH
OUT 21H,AL
F1: MOV AH,06H
MOV BX,OFFSET LIVING
INT 10H
MOV AL,80H
OUT 63H,AL
MOV AL,0B6H
OUT 43H,AL
MOV AX,59500
OUT 42H,AL
MOV AL,AH
OUT 42H,AL
MOV COUNT,0
STI
;红绿灯属于8255的B端口控制
S1: MOV AL,0C3H ;红绿灯显示;11000011中间4个灯亮,其它灭
OUT 61H,AL
CALL DISP
CMP COUNT,20
JL S1 ;实现了1s的计时
MOV COUNT,0
MOV DI,OFFSET TIME
MOV AL,[DI+1]
CMP AL,00H
JZ A5 ;绿灯高位即十位为0时跳到A5
MOV AL,[DI]
CMP AL,00H
JZ A6 ;绿灯低位即个位为0时跳到A6
DEC AL
MOV [DI],AL
A2: MOV AL,[DI+2] ;红灯控制低位为0跳到A3
CMP AL,00H
JZ A3
DEC AL
MOV [DI+2],AL
JMP S1
A3: MOV AL,9 ;红灯低位为0时重新置9,在高位不为0时
MOV [DI+2],AL
MOV AL,[DI+3]
DEC AL ;红灯高位减1
MOV [DI+3],AL
JMP S1
A5: MOV AL,[DI] ;绿高位为0时跳到A0
CMP AL,01H
JZ A0
DEC AL
MOV [DI],AL
JMP A2
A6: MOV AL,9 ;绿灯低位为0时重新置9,在高位不为0时
MOV [DI],AL
MOV AL,[DI+1]
DEC AL
MOV [DI+1],AL
JMP A2
A0: MOV AL,05H ;显示5秒的黄灯时间
MOV [DI],AL
MOV [DI+2],AL
JMP S21
S21: MOV AL,0C0H ;黄灯的显示,属于8255的c端口高4位控制;绿灯灭,黄灯亮,红灯亮的状态
OUT 62H,AL
CALL DISP
CMP COUNT,20
JL S21
MOV COUNT,0
MOV DI,OFFSET TIME
MOV AL,[DI]
CMP AL,00H
JZ A7
DEC AL
MOV [DI],AL
JMP S22
A7: MOV AL,3 ;恢复原来的计数
MOV [DI+1],AL
MOV AL,0
MOV [DI],AL
MOV AL,3
MOV [DI+3],AL
MOV AL,5
MOV [DI+2],AL
JMP S3
S22: MOV AL,0F3H ;红灯亮,黄灯和绿灯都灭的状态
OUT 61H,AL
MOVAL,0F0H
OUT62H,AL
CALL DISP
CMP COUNT,20
JL S22
MOV COUNT,0
MOV DI,OFFSET TIME
MOV AL,[DI]
CMP AL,00H
JZ A7
DEC AL
MOV [DI],AL
MOV AL,[DI+2]
DEC AL
MOV [DI+2],AL
JMP S21
S3: MOV AL,3CH ;与s1相反的状态
OUT 61H,AL
CALL DISP
CMP COUNT,20
JL S3
MOV COUNT,0
MOV DI,OFFSET TIME
MOV AL,[DI+3]
CMP AL,00H
JZ A8
MOV AL,[DI+2]
CMP AL,00H
JZ A9
DEC AL
MOV [DI+2],AL
A11: MOV AL,[DI]
CMP AL,00H
JZ A12
DEC AL
MOV [DI],AL
JMP S3
A8: MOV AL,[DI+2]
CMP AL,01H
JZ A1
DEC AL
MOV [DI+2],AL
JMP A11
A9: MOV AL,9
MOV [DI+2],AL
MOV AL,[DI+3]
DEC AL
MOV [DI+3],AL
JMP A11
A12: MOV AL,9
MOV [DI],AL
MOV AL,[DI+1]
DEC AL
MOV [DI+1],AL
JMP S3
A1: MOV AL,05H
MOV [DI+2],AL
MOV [DI],AL
JMP S41
S41: MOV AL,30H ;与s22相反的状态
OUT 62H,AL
CALL DISP
CMP COUNT,20
JL S41
MOV COUNT,0
MOV DI,OFFSET TIME
MOV AL,[DI]
CMP AL,00H
JZ A10
DEC AL
MOV [DI],AL
MOV AL,[DI+2]
DEC AL
MOV [DI+2],AL
JMP S42
A10: MOV AL,3
MOV [DI+1],AL
MOV AL,0
MOV [DI],AL
MOV AL,3
MOV [DI+3],AL
MOV AL,5
MOV [DI+2],AL
JMP S1
S42: MOV AL,3FH
OUT 61H,AL
MOVAL,0F0H
OUT62H,AL
CALL DISP
CMP COUNT,20
JL S42
MOV COUNT,0
MOV DI,OFFSET TIME
MOV AL,[DI+2]
CMP AL,00H
JZ A10
DEC AL
MOV [DI+2],AL
MOV [DI],AL
JMP S41
IRQ0: ;实现复位的状态
MOV AL,20H
OUT 20H,AL
MOV DI,OFFSET TIME
MOV AL,3
MOV [DI+1],AL
MOV AL,0
MOV [DI],AL
MOV AL,3
MOV [DI+3],AL
MOV AL,5
MOV [DI+2],AL
JMP F1
IRET
IRQ1: ;实现全红灯的状态
MOV AL,20H
OUT 20H,AL
MOV AH,06H
MOV BX,OFFSET VIP
INT 10H
L7: STI
MOV DI,OFFSET TIME
MOV AL,5
MOV [DI+1],AL
MOV [DI+3],AL
MOV AL,10
MOV [DI],AL
MOV [DI+2],AL
MOV AL,0FH
OUT 61H,AL
CALL DISP
JMP L7
IRET
IRQ2:
MOV AL,20H
OUT 20H,AL
MOV AH,06H
MOV BX,OFFSET NIGHT
INT 10H
STI
MOV DI,OFFSET TIME
MOV AL,11
MOV [DI+1],AL
MOV AL,5
MOV [DI],AL
MOV AL,11
MOV [DI+3],AL
MOV AL,5
MOV [DI+2],AL
L3: MOV COUNT,0
L0: MOV AL,0CCH
OUT 61H,AL
CALL DISP
CMP COUNT,10
JL L0
MOV COUNT,0
L1: MOV AL,0FFH
OUT 61H,AL
CALL DISP
CMP COUNT,10
JL L1
JMP L3
IRET
IRQ7: INC COUNT
MOV AL,20H
OUT 20H,AL
IRET
DISP PROC NEAR
MOV DI,OFFSET TIME
MOV CL,0FEH
ST1: MOV AL,CL
TEST AL,10H
JZ ED
OUT 62H,AL
ROL AL,01H
MOV CL,AL
MOV AL,[DI]
MOV BX,OFFSET LEDTAL
XLAT
OUT 60H,AL
CALL DELAY
INC DI
JMP ST1
ED: RET
DISP ENDP
DELAY PROC NEAR
PUSH CX
MOV CX,1000
WAIT1: LOOP WAIT1
POP CX
RET
DELAY ENDP
CODE ENDS
END START
[b][/b][b][/b]如何更改?
[解决办法]
有可能是线路的问题,也有可能是程序的问题。。。,。
[解决办法]
我看线路问题居多