五、实验连线图辣、程序流程图
七、程序源代码
8253的初始化:
mov al,37h……………….给计数器0写控制字(00110111)
out 43h,al
mov ax,1190h………........赋计数初值
out 40h,al
mov al,ah
out 40h,al
mov al,b7h……………….给计数器2写控制字(10110111)
out 43h,al
mov ax,1000h……………赋计数初值
out 42h,al
mov al,ah
out 42h,al
8255的初始化:
mov al,80h……………….(10000000)
out 63h,al
8259向量表设置:
push ds…………………..保存数据段
mov ax,0000h
mov ds,ax………………数据段清零
mov ax,offset irq7………取中断程序的入口地址(相对地址)
add ax,2000h....................加装载时ip=2000h地址(绝对地址)
mov SI,003ch
mov [SI],ax……………..填偏移地址
mov SI,003eh
mov ax,0000h…………...填段地址
mov [SI],ax
IRQ7开屏蔽:
in al,21h
and al,7fh………………..开8259中断7
out 21h,al
sti
主程序:
start:
mov cl,18h……………….东直行24秒
mov ch,1eh………………南禁行30秒
mov al,d7h……………….东直行指示灯情况(11010111)
out 61,al
a:
cmp cl,00h
jnz a
mov cl,ch……………….东左拐6秒
mov al,d3h……………..东左拐指示灯情况(11010011)
751com.cn
cli
mov cl,1eh……………..东禁行30秒
mov ch,18h…………….南直行24秒
mov al,7dh……………..南直行指示灯情况(01111101)
out 61,al
sti
c:
cmp ch,00h
jnz c
mov ch,cl………………南左拐6秒
mov al,7ch……………..南左拐指示灯情况(01111100)
out 61,al
d:
cmp ch,00h
jnz d
jmp start
irq7:..................................中断服务程序
mov ax,0001…………...清屏
int 10
mov ah,00h
mov al,cl
div 0ah
mov dx,ax
mov al,dl
add al,30h
mov ah,01h
int 10
mov al,dh
add al,30h
mov ah,01h
int 10
dec cl
mov ax,0120h………..空格
int 10
mov ah,00h
mov al,ch
div 0ah
mov dx,ax
mov al,dl
add al,30h
mov ah,01h
int 10
mov al,dh
add al,30h