8086制作的交通灯,使用8086CPU,以74273,8255和74LS138来作为模块
仿真原理图如下(proteus仿真工程文件可到本帖附件中下载)
8086汇编语言源程序如下:
- ;====================================================================
- ; Main.asm file generated by New Project wizard
- ;
- ; Created: 周二 3月 10 2020
- ; Processor: 8086
- ; Compiler: MASM32
- ;
- ; Before starting simulation set Internal Memory Size
- ; in the 8086 model properties to 0x10000
- ;====================================================================
- ;====================================================================
- ; rtl.asm file generated by New Project wizard
- ;
- ; Created: 周六 11月 30 2019
- ; Processor: 8086
- ; Compiler: Digital Mars C
- ;====================================================================
- IOCON EQU 02B6H
- IOA EQU 02B0H
- IOB EQU 02B2H
- IOC EQU 02B4H
- CODE SEGMENT
- ASSUME CS:CODE
- START:MOV AL,80H ;8255A的ABC口都为工作方式0,都为输出口
- MOV DX,IOCON
- OUT DX,AL ;向8255A发送工作方式控制字
-
- MOV DX,IOB
- MOV AL,0F0H
- OUT DX,AL ;关闭所有的黄灯和绿灯
-
- MOV DX,IOC
- MOV AL,0F0H
- OUT DX,AL ;打开所有的红灯
-
- CALL DELAY1 ;长延时
- IOLED0:
- MOV AL,10100101B
- MOV DX,IOC
- OUT DX,AL ;东西的红灯亮,南北的绿灯亮
- CALL DELAY1 ;长延时
- CALL DELAY1 ;长延时
- OR AL,0F0H
- OUT DX,AL ;南北的绿灯灭
- MOV CX,8 ;南北的黄灯闪烁8次
- IOLED1:
- MOV DX,IOB
- MOV AL,10101111B
- OUT DX,AL ;南北的黄灯亮
- CALL DELAY2 ;短延时
- OR AL,01010000B
- OUT DX,AL ;南北的黄灯灭
- CALL DELAY2 ;短延时
- LOOP IOLED1
-
- MOV DX,IOC
- MOV AL,0F0H
- OUT DX,AL ;所有的红灯全亮,绿灯全灭,进行消隐
- CALL DELAY2 ;短延时
-
- MOV AL,01011010B
- OUT DX,AL ;南北的红灯亮,东西的绿灯亮
- CALL DELAY1 ;长延时
-
- OR AL,0F0H
- OUT DX,AL ;东西的绿灯灭
- MOV CX,8 ;东西的黄灯闪烁8次
- IOLED2:
- MOV DX,IOB
- AND AL,01011111B
- OUT DX,AL ;东西的黄灯亮
- CALL DELAY2 ;短延时
-
- OR AL,10100000B
- OUT DX,AL ;东西的黄灯灭
- CALL DELAY2 ;短延时
- LOOP IOLED2
-
- MOV DX,IOC
- MOV AL,0F0H
- OUT DX,AL ;所有的红灯全亮,绿灯全灭,进行消隐
- CALL DELAY2 ;短延时
- JMP IOLED0
-
- DELAY1: ;长延时
- PUSH AX
- PUSH CX
- MOV CX,0030H
- DELY2:CALL DELAY2 ;短延时
- LOOP DELY2
- POP CX
- POP AX
- RET
- DELAY2:
- PUSH CX
- MOV CX,8000H
- DELA1:LOOP DELA1
- POP CX
- RET
- CODE ENDS
- END START
复制代码
代码与Proteus8.8版本仿真下载:
十字路口交通灯实验.7z
(53.16 KB, 下载次数: 91)
|