目录
目录
学习重点
- 中断原因
- 中断请求标记(INTR)
- 中断判优逻辑(排队)
- 中断服务程序入口地址
- 中断响应
- 条件
- 时间
- 中断隐指令
- 保存断点
- 寻找入口地址
- 硬件关中断
- 保存和恢复现场
- 多重中断
- 屏蔽技术(MASK)
- 屏蔽字
- 修改屏蔽字
- 断点保护
- 断点进栈
- 存入0地址
1.概述
1.1 引起中断的因素
- 认为设置中断:如转管指令
- 程序性事故:溢出,操作码不能识别,除法非法
- 硬件故障
- IO设备
- 外部事件
1.2 中断系统的功能
- 各中断源如何向cpu提出请求
- 各中断源同时提出请求怎么办
- CUP何时以及如何响应终端
- 如何保护现场
- 如何寻找入口地址
- 如何恢复现场,返回
- 处理中断过程中又出现新的中断怎么办
软件+硬件实现
2.中断请求和中断判优逻辑
2.1 中断请求标记 INTR
- 每一位代表一个中断源
2.2 中断判优逻辑
2.2.1 硬件实现
-
分散在各个中断源的接口电路中:链式排队器
-
集中在CPU内
- 双非门可以增强信号
- 通过第一个非门后的信号线情况所有比该中断源优先级低的中断请求
2.2.2 软件实现(程序查询)
3.中断服务程序入口地址寻找
3.1 硬件向量法
两种方式:
- 存放跳转指令,直接跳转到中断服务程序
- 存放入口地址,送入PC寄存器执行中断服务程序
硬件向量法速度快,但是灵活性很低
3.2 软件查询法
中断源按优先级从高到低排列,程序依次查询每个中断源的完成触发器(D)
- 若D为0,无中断,检查下一个中断源
- 若D为1,有中断,跳转对应的服务程序
4.中断响应
4.1 中断响应条件
允许中断触发器:EINT=1
4.2 响应中断的时间
指令执行周期结束时刻由CPU发出查询信号
4.3 中断隐指令
1)保护程序断点:
- 断点存于特定地址 (0号地址) 内
- 断点进栈,返回时出栈
2)寻找服务程序入口地址:
- 向量地址 —> PC (硬件向量法)
- 中断识别程序 入口地址 M —> PC (软件查询法)
3)硬件关中断:
- INT:中断标记
- EINT:允许中断
- R-S 触发器(或非门)
- R=0,S=0时状态不定
- R=1,S=0时置1
- R=0,S=1时置0
- R=1,S=1时状态不变
- 与非门与则相反
- 中断INT置为1后,EINT就置为0
5.保护现场和恢复现场
5.1 保护现场
- 保存断点:中断隐指令完成
- 保存寄存器内容:中断服务程序完成
5.2 恢复现场
由中断服务程序完成
6.多重中断
6.1 概念
中断程序可以被更高优先级的程序中断
6.2 实现多重中断条件
- 提前设置开中断指令
- 优先级别高 的中断源有权 中断优先级低 的中断源
- 中断谁返回谁
6.3 中断屏蔽字技术
1.屏蔽触发器(MASK)
通过中断 屏蔽触发器(MASK) 设置中断屏蔽
- MASK值为1,屏蔽,INTP=0,表示不能中断,不能被排队器选中
2.屏蔽字
- 1表示MASK=1,不能被中断
- 0表示MASK=0,可以被中断
3.屏蔽技术可改变处理优先等级
重新设置屏蔽字
4.屏蔽技术的其他作用
可以认为的设置某个中断源的请求
6.4 多重中断的断点保护
1)单重中断:
- 断点进栈:中断隐指令
- 断点存入0地址:中断隐指令
2)中断周期:
3)问题:
- 多个中断存放的都是0地址,会冲突,需要转存至其他地址单元