一、实验目的
并行接口8255实现十字路口交通灯模拟。
二、实验内容
l7、l6、l5 作为南北交通灯与pc7、pc、pc5 相连,
l2、l1、l0作为东西交通灯与pc2、pc1、pc0相连。
使6个灯有规律的亮灭。
四、汇编程序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
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循环写三次可实现交通灯的机制。