Exceptions: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
No edit summary
No edit summary
Line 3: Line 3:
|}
|}


'''Exceptions''' as described in this article are generated by the CPU when an 'error' occurs. Some exceptions are not really errors in most cases, such as [[Page Fault|page faults]].
'''Exceptions''' as described in this article are generated by the CPU when an 'error' occurs. Some exceptions are not really errors in most cases, such as [[#Page Fault|page faults]].


Exceptions are classified as:
Exceptions are classified as:
Line 156: Line 156:
|}
|}


== Faults ==
== Exceptions ==


=== Divide-by-zero Error ===
=== Faults ===

==== Divide-by-zero Error ====
The '''Divide-by-zero Error''' occurs when dividing any number by 0 using the DIV or IDIV instruction. Many OS developers use this exception to test whether their exception handling code works. This exception may also occur when the result is too large to be represented in the destination.
The '''Divide-by-zero Error''' occurs when dividing any number by 0 using the DIV or IDIV instruction. Many OS developers use this exception to test whether their exception handling code works. This exception may also occur when the result is too large to be represented in the destination.


The Instruction Pointer points to the instruction which caused the exception.
The instruction pointer points to the DIV or IDIV instruction which caused the exception.


=== Bound Range Exceeded ===
==== Bound Range Exceeded ====
This exception can occur when the BOUND instruction is executed. The BOUND instruction compares an array index with the lower and upper bounds of an array. When the index is out of bounds, the Bound Range Exceeded exception occurs.


The instruction pointer points to the BOUND instruction which caused the exception.


=== Invalid Opcode ===
==== Invalid Opcode ====
=== Device Not Available ===
==== Device Not Available ====
=== Invalid TSS ===
==== Invalid TSS ====
=== Segment Not Present ===
==== Segment Not Present ====
=== Stack-Segment Fault ===
==== Stack-Segment Fault ====
=== General Protection Fault ===
==== General Protection Fault ====
=== Page Fault ===
==== Page Fault ====
=== x87 Floating-Point Exception ===
==== x87 Floating-Point Exception ====
=== Alignment Check ===
==== Alignment Check ====
=== SIMD Floating-Point Exception ===
==== SIMD Floating-Point Exception ====


== Traps ==
=== Traps ===


=== Debug ===
==== Debug ====
{{stub}}
{{stub}}
=== Breakpoint ===
=== Overflow ===


== Aborts ==
==== Breakpoint ====
A Breakpoint exception occurs at the execution of the INT3 instruction. Some debug software replace an instruction by the INT3 instruction. When the breakpoint is trapped, it replaces the INT3 instruction with the original instruction, and decrements the instruction pointer by one.
=== Double Fault ===
=== Machine Check ===


The instruction pointer points to the byte after the INT3 instruction.


== Misc ==
==== Overflow ====
An Overflow exception is raised when the INTO instruction is executed while the overflow bit in [[RFLAGS]] is set to 1.
=== Non-maskable Interrupt ===

The instruction pointer points to the instruction after the INTO instruction.

=== Aborts ===
==== Double Fault ====
==== Machine Check ====


=== Misc ===
==== Non-maskable Interrupt ====
{{stub}}

Revision as of 14:11, 27 October 2008

Exceptions as described in this article are generated by the CPU when an 'error' occurs. Some exceptions are not really errors in most cases, such as page faults.

Exceptions are classified as:

  • Faults: These can be corrected and the program may continue as if nothing happend.
  • Traps: Traps are reported immediately after the execution of the trapping instruction.
  • Aborts: Some severe unrecoverable error.
Name Vector nr. Type Mnemonic Error code?
Divide-by-zero Error 0 Fault #DE No
Debug 1 Fault/Trap #DB No
Non-maskable Interrupt 2 Interrupt #NMI No
Breakpoint 3 Trap #BP No
Overflow 4 Trap #OF No
Bound Range Exceeded 5 Fault #BR No
Invalid Opcode 6 Fault #UD No
Device Not Available 7 Fault #NM No
Double Fault 8 Abort #NM Yes
Coprocessor Segment Overrun 9 Fault - No
Invalid TSS 10 Fault #TS Yes
Segment Not Present 11 Fault #NP Yes
Stack-Segment Fault 12 Fault #SS Yes
General Protection Fault 13 Fault #SS Yes
Page Fault 14 Fault #SS Yes
Reserved 15 - - No
x87 Floating-Point Exception 16 Fault #MF No
Alignment Check 17 Fault #AC Yes
Machine Check 18 Abort #MC No
SIMD Floating-Point Exception 19 Fault #XM/#XF No
Reserved 20-29 - - No
Security Exception 30 - #SX No
Reserved 31 - - No

Exceptions

Faults

Divide-by-zero Error

The Divide-by-zero Error occurs when dividing any number by 0 using the DIV or IDIV instruction. Many OS developers use this exception to test whether their exception handling code works. This exception may also occur when the result is too large to be represented in the destination.

The instruction pointer points to the DIV or IDIV instruction which caused the exception.

Bound Range Exceeded

This exception can occur when the BOUND instruction is executed. The BOUND instruction compares an array index with the lower and upper bounds of an array. When the index is out of bounds, the Bound Range Exceeded exception occurs.

The instruction pointer points to the BOUND instruction which caused the exception.

Invalid Opcode

Device Not Available

Invalid TSS

Segment Not Present

Stack-Segment Fault

General Protection Fault

Page Fault

x87 Floating-Point Exception

Alignment Check

SIMD Floating-Point Exception

Traps

Debug

This page is a stub.
You can help the wiki by accurately adding more contents to it.

Breakpoint

A Breakpoint exception occurs at the execution of the INT3 instruction. Some debug software replace an instruction by the INT3 instruction. When the breakpoint is trapped, it replaces the INT3 instruction with the original instruction, and decrements the instruction pointer by one.

The instruction pointer points to the byte after the INT3 instruction.

Overflow

An Overflow exception is raised when the INTO instruction is executed while the overflow bit in RFLAGS is set to 1.

The instruction pointer points to the instruction after the INTO instruction.

Aborts

Double Fault

Machine Check

Misc

Non-maskable Interrupt

This page is a stub.
You can help the wiki by accurately adding more contents to it.