2.6 Interrupts and Exceptions 中断和异常

The 80386 has two mechanisms for interrupting program execution:

80386对中断处理执行有两个机制:

Exceptions are synchronous events that are the responses of the CPU to certain conditions detected during the execution of an instruction.

异常是同步事件,在CPU执行指令期间侦测到特定条件时的响应。

Interrupts are asynchronous events typically triggered by external devices needing attention.

中断是由外部设备有需要关注事件时触发的非同步事件。

Interrupts and exceptions are alike in that both cause the processor to temporarily suspend its present program execution in order to execute a program of higher priority. The major distinction between these two kinds of interrupts is their origin. An exception is always reproducible by re-executing with the program and data that caused the exception, whereas an interrupt is generally independent of the currently executing program.

中断和异常都会导致处理器挂起当前正在执行的程序而转去执行一个更高优先级的程序,这一点上二者很相似。二者主要的区别是它们的来源不同。异常总是由程序或数据引起的,并可重现;而中断产生通常不依赖于当前执行的程序。

Application programmers are not normally concerned with servicing interrupts. More information on interrupts for systems programmers may be found in Chapter 9 . Certain exceptions , however, are of interest to applications programmers, and many operating systems give applications programs the opportunity to service these exceptions. However, the operating system itself defines the interface between the applications programs and the exception mechanism of the 80386.

应用程序通常不关心服务中断。更多的针对系统程序的中断信息可以第9章找到。然而,某些特定的异常是应用程序感兴趣的,很多操作系统会给应用程序提供处理这些异常的时机。操作系统自身在应用程序和80386的异常机制之间会提供接口。

Table 2-2 highlights the exceptions that may be of interest to applications programmers.

表2-2高亮部分的异常通常都是应用程序关心的。

  • A divide error exception results when the instruction DIV or IDIV is executed with a zero denominator or when the quotient is too large for the destination operand . (Refer to Chapter 3 for a discussion of DIV and IDIV.)

DIV 或IDIV指令在执行时,最到0做分母或者商超过目的操作数大小时会发生除法错误。(参考第3章关于DIV和IDIV的讨论)

  • The debug exception may be reflected back to an applications program if it results from the trap flag (TF).

如果是从陷阱标志(TF)返回,调试异常可以被反射回应用程序

  • A breakpoint exception results when the instruction INT 3 is executed. This instruction is used by some debuggers to stop program execution at specific points.

INT3指令执行时会引发断点异常。这条指令被一些调试器用来在特定点停止程序执行。

  • An overflow exception results when the INTO instruction is executed and the OF (overflow) flag is set (after an arithmetic operation that set the OF flag ) . (Refer to Chapter 3 for a discussion of INTO) .

当INTO指令执行或OF标志位被置位时(数学运算会置位OF)时会产生溢出异常。(参考第3章关于INTO的讨论。)

  • A bounds check exception results when the BOUND instruction is executed and the array index it checks falls outside the bounds of the array . (Refer to Chapter 3for a discussion of the BOUND instruction. )

BOUND指令执行或当数组索引超越边界时会引发越界异常。(参考第3章关于BOUND指令的讨论。)

  • Invalid opcodes may be used by some applications to extend the instruction set. In such a case, the invalid opcode exception presents an opportunity to emulate the opcode.

非法指令可以被某些程序来扩展指令集。在这种情况下,非常指令异常会提供一个虚拟该指令的时机。

  • The "coprocessor not available" exception occurs if the program contains instructions for a coprocessor, but no coprocessor is present in the system.

协处理器不可用异常发生在程序包含协处理器指令,但系统中没有协处理器时。

  • A coprocessor error is generated when a coprocessor detects an illegal operation.

当协处理器侦测到一个非法操作时发生协处理器错误

The instruction INT generates an interrupt whenever it is executed; the processor treats this interrupt as an exception. The effects of this interrupt (and the effects of all other exceptions) are determined by exception handler routines provided by the application program or as part of the systems software (provided by systems programmers). The INT instruction itself is discussed in Chapter 3. Refer to Chapter 9 for a more complete description of exceptions.

无论何时运行INT指令都会产生一个中断;处理器把该中断视做一个异常。该中断的影响(并且所有其他异常的影响结果)取决于应用程序或操作系统所提供的异常处理例程。INT指令本身在第3章讨论。第9章会有更多更多全面的关于异常的说明。

Table 2-2. 80386 Reserved Exceptions and Interrupts 80386提供的异常和中断

Vector Number      Description

0                  Divide Error 除法错误

1                  Debug Exceptions 调试异常

2                  NMI Interrupt NMI中断(Non Maskable Interrupt 不可屏敝中断)

3                  Breakpoint 断点

4                  INTO Detected Overflow 溢出中断

5                  BOUND Range Exceeded 越界

6                  Invalid Opcode 非法操作符

7                  Coprocessor Not Available 协处理器不可用

8                  Double Exception 双重异常

9                  Coprocessor Segment Overrun 协处理器段越界

10                 Invalid Task State Segment 非法的任务状态段(TSS)

11                 Segment Not Present 段不存在

12                 Stack Fault 栈错误

13                 General Protection 通用保护

14                 Page Fault 页错误

15                 (reserved) 保留

16                 Coprocessor Error 协处理器错误

17-32              (reserved) 保留

【译】x86程序员手册08 -2.6中断和异常的更多相关文章

  1. 【译】x86程序员手册01

    Intel 80386 Reference Programmer's Manual 80386程序员参考手册 Chapter 1 -- Introduction to the 80386 第1章 - ...

  2. 【译】x86程序员手册03 - 2.1内存组织和分段

    2.1 Memory Organization and Segmentation 内存组织和分段 The physical memory of an 80386 system is organized ...

  3. 【译】x86程序员手册02 - 基本的程序模式

    Chapter 2 -- Basic Programming Model: 基本的程序模式 Introduces the models of memory organization. Defines ...

  4. 【译】x86程序员手册39-10.3切换到保护模式

    10.3 Switching to Protected Mode  切换到保护模式 Setting the PE bit of the MSW in CR0 causes the 80386 to b ...

  5. 【译】x86程序员手册35-9.8异常条件

    译注:一些异常没有翻译,因为看书时主要为了理解linux代码,所以代码中没有主要使用的就没有仔细看.这部分内容后期再看时再进行翻译. 9.8 Exception Conditions 异常条件 The ...

  6. 【译】x86程序员手册33-9.6中断任务和中断处理程序

    9.6 Interrupt Tasks and Interrupt Procedures 中断任务和中断处理程序 Just as a CALL instruction can call either ...

  7. 【译】x86程序员手册31- 第9章 异常和中断

    Chapter 9 Exceptions and Interrupts 第9章 异常和中断 Interrupts and exceptions are special kinds of control ...

  8. 【译】x86程序员手册26-7.5任务切换

    7.5 Task Switching 任务切换 The 80386 switches execution to another task in any of four cases: 80386在以下四 ...

  9. 【译】x86程序员手册25-7.1任务状态段

    7.1 Task State Segment 任务状态段 All the information the processor needs in order to manage a task is st ...

随机推荐

  1. 学习——Git及VersionControl

    一.Git基本介绍 1.Git是什么? Git是一款免费.开源的分布式版本控制系统,用于敏捷高效地处理任何或小或大的项目.用以有效.高速的处理从很小到非常大的项目版本管理.Git 是 Linus To ...

  2. - > 网络流(【最大流】草地排水模板题)

    1993 草地排水 USACO  时间限制: 2 s  空间限制: 256000 KB  题目等级 : 钻石 Diamond 题解       题目描述 Description 在农夫约翰的农场上,每 ...

  3. 常见的各品牌路由器默认IP地址汇总清单

    常见的各品牌路由器默认IP地址汇总清单 下面是各常见品牌路由器的默认IP清单: 如果您使用的设备品牌不在上述列表中,也可以试着访问下RouterIPAddress.com或SetupRouter.co ...

  4. Proxy Server代理服务器(轉載)

    宽带IP城域网开通以来,单位连上了宽带网,10M的带宽让我们感受到了宽带的魅力.电信只提供7个IP地址,对任何一个单位来说都太少了,常用的解决办法是使用代理服务器.微软的MS Proxy Server ...

  5. wpf slider进度条的样式模板,带有进度颜色显示

    效果图: 仅仅需在前台加上这段代码就可以: <UserControl.Resources> <!--笔刷--> <LinearGradientBrush x:Key=&q ...

  6. Java创建和解析Json数据方法——org.json包的使用(转)

    org.json包的使用 1.简介   工具包org.json.jar,是一个轻量级的,JAVA下的json构造和解析工具包,它还包含JSON与XML, HTTP headers, Cookies, ...

  7. 具体解释clone函数

    我们都知道linux中创建新进程是系统调用fork,但实际上fork是clone功能的一部分,clone和fork的主要差别是传递了几个參数.clone隶属于libc.它的意义就是实现线程. 看一下c ...

  8. Linux下的画图软件

    Pinta是一款和windows下的画图相类似打一款画图软件,并且它还包含了一些基本的图像编辑工具. 比如:标尺.图层.操作历史记录.图像调整.渲染效果等等,可以满足对图像处理要求不太高的用户的基本需 ...

  9. UVA - 10691 Subway

    题目大意:给定n个点.要求建造尽量少得铁路(从原点发射出的射线).使得全部点到铁路的最短距离小于d. 解题思路:题目能够转化成区间选点问题,即以极角来表示铁轨.然后计算出每一个区间可行的极角范围,进行 ...

  10. sql server数据库添加记录

    转自:http://jingyan.baidu.com/article/f25ef254449a9a482c1b8293.html