资源描述
实验五 8259中断控制器实验
一、实验目的
1、认识TDS86/88微机的中断特性。
2、掌握8259中断控制器的工作原理。
3、掌握8259中断控制器的应用编程。
4、学习并掌握8259中断控制器的级连方式的使用方法。
二、实验设备
1、TDS86/88实验箱一台。
2、排线、单导线若干。
3、微机一台。
三、实验内容
在实验箱上面,主片8259已被初始化,可直接使用,从片8259全开放给用户使用,但需用户根据实验要求自行设计连接线路个初始化编程。
1、单片单中断源8259实验
KK2+
IRQ7
主8259
按图六所示实验线路,编写程序,使每响应外部中断IRQ7时,显示字符“7”,中断10次后,程序退出。
图六
实验参考程序如下:(P4.ASM)
code segment
assume cs:code,ds:code
org 100h
start: push cs
pop ds
cli
push ds
push ds
mov ax,0
mov ds,ax
mov dx, offset intserve
add dx,1000h
sub dx, 100h
mov bx, 003ch
mov word ptr[bx],dx
pop dx
mov word ptr[bx+2],dx
pop ds
in al, 21h
and al,7fh
out 21h,al
mov cx,10
ag: sti
cmp cx,0
jnz ag
hlt
intserve proc far
push ax
mov ah,01h
mov al,"7"
int 10h
mov al," "
int 10h
dec cx
mov al, 20h
out 20h,al
pop ax
iret
intserve endp
code ends
end start
运行程序,按动KK2微动开关键,显示器上将显示字符“7”,重复按动KK2直到中断10次后,程序退出。
2、 单片多中断源8259应用实验
KK2+
IRQ7
主8259
IRQ6
KK1-
按图七所示连接实验线路,编写程序,完成下述功能。当无中断请求时,执行主程序,延时显示“M”字符,若有中断号“7”或“6”,若正在执行较低级的中断服务子程序,则允许比它优先级高的中断被响应(IRQ6>IRQ7)。程序在执行过程中,每显示一个字符,空一格以便于观察。
图七
实验参考程序如下:(P5.ASM)
code segment
assume ds:code,cs:code
org 100h
start: push cs
pop ds
cli
push ds
push ds
mov ax,0
mov ds,ax
mov dx,offset int7
add dx,1000h
sub dx,100h
mov bx,003ch
mov word ptr[bx],dx
pop dx
mov word ptr[bx+2],dx
pop ds
push ds
push ds
mov ax,0
mov ds,ax
mov dx,offset int6
add dx,1000h
sub dx,100h
mov bx,0038h
mov word ptr[bx],dx
pop dx
mov word ptr[bx+2],dx
pop ds
in al,21h
and al,3fh
out 21h,al
ag: sti
push cx
push ax
mov ah,01
mov al,"M"
int 10h
mov al," "
int 10h
mov ax,3h
ag2: mov cx,0ffffh
ag1: loop ag1
dec ax
jnz ag2
pop ax
pop cx
jmp ag
hlt
int6 proc far
push ax
mov ah,01h
mov al,"6"
int 10h
mov al," "
int 10h
push cx
mov ax,3h
int6ag2: mov cx,0ffffh
int6ag1: loop int6ag1
dec ax
jnz int6ag2
pop cx
mov al,20h
out 20h,al
pop ax
iret
int6 endp
int7 proc far
push ax
mov ah,01h
mov al,"7"
int 10h
mov al," "
int 10h
push cx
mov ax,3h
int7ag2: mov cx,0ffffh
int7ag1: loop int7ag1
dec ax
jnz int7ag2
pop cx
mov al,20h
out 20h,al
pop ax
iret
int7 endp
code ends
end start
3、 8259级连实验
将实验箱上的两片8259按图八所示,构成8259级连方式的实验线路,其中规定主片的IRQ7连接一片从片,从片上的IR7接外中断申请电平,并规定从片的中断矢量号为30H—37H,从片8259的CS端接I0Y0。因此,从片的端口寄存器地址为00H和01H。
实验参考程序如下:
code segment
assume cs:code,ds:code
org 100h
start: push cs
pop ds
cli
mov al,11h
out 20h,al
mov al,08h
out 21h,al
mov al,80h
out 21h,al
mov al,1dh
out 21h,al
mov al,7dh
out 21h,al
mov al,11h
out 00h,al
mov al,30h
out 01h,al
mov al,07h
out 01h,al
mov al,09h
out 01h,al
mov al,7fh
out 01h,al
push ds
push ds
mov ax,0
mov ds,ax
mov dx,offset intserve
add dx,1000h
sub dx,100h
mov bx,00dch
mov word ptr [bx],dx
pop dx
mov word ptr [bx+2],dx
pop ds
mov cx,10
ag: sti
cmp cx,0
jnz ag
hlt
intserve proc far
push ax
mov ah,01h
mov al,"7"
int 10h
mov al," "
int 10h
dec cx
mov al,20h
out 00h,al
pop ax
iret
intserve endp
code ends
end start
按动KK1微动开关,观察屏幕显示情况。
在上述实验中,若将intsever的中断服务程序的入口地址改为添入主片的IRQ7所对应的矢量表格中,会有什么样的结果,编程序实验之。
8259 CAS0
主片 CAS1
CAS2
INTA
IRQ7
CS0 IR7
CS1
CS2
INTA
INT
8259从片
A0
CS
WR
RD
D0
|
D7
KK1-
XA0
IOYO
XIOW
XIOR
XD0
|
XD7
图八
展开阅读全文