当前位置: 代码迷 >> 电脑整机及配件 >> 交通灯的黄灯很暗解决办法
  详细解决方案

交通灯的黄灯很暗解决办法

热度:4379   发布时间:2013-02-26 00:00:00.0
交通灯的黄灯很暗
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
  相关解决方案