关闭

6-7 8255 控制交通灯

标签: 8255
110人阅读 评论(0) 收藏 举报
分类:

一、实验目的

并行接口8255实现十字路口交通灯模拟。

二、实验内容

l7、l6、l5 作为南北交通灯与pc7、pc、pc5 相连,

l2、l1、l0作为东西交通灯与pc2、pc1、pc0相连。

使6个灯有规律的亮灭。

四、汇编程序data segment

ioport equ 0ff00h-0280hio8255a equ ioport+288h
io8255b equ ioport+289h
io8255c equ ioport+28ah
io8255d equ ioport+28bh
portc1 db 24h,44h,04h,44h,04h,44h,04h
db 81h,82h,80h,82h,80h,82h,80h
db 24h,44h,04h,44h,04h,44h,04h
db 81h,82h,80h,82h,80h,82h,80h
db 24h,44h,04h,44h,04h,44h,04h
db 81h,82h,80h,82h,80h,82h,80h

db 0ffh
data ends
code segment
assume cs:code, ds:data
start:mov ax,data
mov ds,ax
mov dx,io8255d
mov al,90h
out dx,al
lea di,portc1
re_on:mov al,[di]
inc di
cmp al,0ffh
jz exit
mov dx,io8255c
on: out dx,al
call delay
jmp re_on
exit:mov ah,4ch
int 21h
delay proc near
mov cx,0ffffh
de1:mov bx,0ff0h
de0:dec bx
jnz de0
loop de1
ret
delay endp
code ends
end start

data segment
ioport equ 0ff00h-0280h
io8255a equ ioport+288h
io8255b equ ioport+289h
io8255c equ ioport+28ah
io8255d equ ioport+28bh
portc1 db 24h,44h,04h,44h,04h,44h,04h
db 81h,82h,80h,82h,80h,82h,80h
db 24h,44h,04h,44h,04h,44h,04h
db 81h,82h,80h,82h,80h,82h,80h
db 24h,44h,04h,44h,04h,44h,04h
db 81h,82h,80h,82h,80h,82h,80h

db 0ffh
data ends
code segment
assume cs:code, ds:data
start:mov ax,data
mov ds,ax
mov dx,io8255d
mov al,90h
out dx,al
lea di,portc1
re_on:mov al,[di]
inc di
cmp al,0ffh
jz exit
mov dx,io8255c
on: out dx,al
call delay
jmp re_on
exit:mov ah,4ch
int 21h
delay proc near
mov cx,0ffffh
de1:mov bx,0ff0h
de0:dec bx
jnz de0
loop de1
ret
delay endp
code ends
end start
说明:db循环写三次可实现交通灯的机制。






0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:6034次
    • 积分:253
    • 等级:
    • 排名:千里之外
    • 原创:20篇
    • 转载:2篇
    • 译文:0篇
    • 评论:0条
    文章分类
    文章存档