Assembly-internal interrupt

Interruption means that the CPU no longer continues to execute the instruction (just executed), but instead switches to processing this special information.

Internal interrupt generation
 

8086CPU, when the following situations occur inside the CPU, corresponding interrupt information will be generated:

  (1) Division errors, such as division overflow caused by executing the div instruction;

  (2) Single-step execution;
  (3) Execute the into instruction;

  (4) Execute the int instruction.

 The CPU must first know the source of the received interrupt information. Therefore, the interrupt message must contain a code that identifies the source. The 8086CPU uses the data of the interrupt type code to identify the source of the interrupt information. The interrupt type code is a byte data that can represent the source of 256 types of interrupt information. In the future, we will generate events that interrupt information, that is, the source of interrupt information, referred to as interrupt sources.

For the above four interrupt sources, the interrupt type codes in the 8086CPU are as follows:

        (1) Division error: 0

        (2) Single-step execution: 1

        (3) Execute the into command: 4

        (4) Execute the int instruction. The format of the instruction is int n. n in the instruction is a byte type immediate number, which is the interrupt type code provided to the CPU.

Interrupt vector table

The CPU uses the 8-bit interrupt type code to find the entry address of the corresponding interrupt handler through the interrupt vector table. So what is an interrupt vector table? The interrupt vector table is a list of interrupt vectors. So what is an interrupt vector? The so-called interrupt vector is the entry address of the interrupt handler. To expand, the interrupt vector table is a list of interrupt handler entry addresses.
The interrupt vector table is stored in memory, which stores the entry points of the interrupt handlers corresponding to 256 interrupt sources, as shown in Figure 12.1.

It can be seen that as long as the CPU knows the interrupt type code, it can use the interrupt type code as the entry number of the interrupt vector table, locate the corresponding entry, and obtain the entry address of the interrupt handler.
The interrupt vector table is stored in the memory. For the 8086 PC, the interrupt vector table is designated to be placed at memory address 0. The interrupt vector table is stored in 1024 units from memory 0000:0000 to 0000:03FF. Can it be placed elsewhere? No, if 8086CPU is used, the interrupt vector table must be placed in the unit 0000:0000~0000:03FF. This is a rule, because the 8086CPU reads the interrupt vector table from this place.
So how much space does an entry occupy in the interrupt vector table? One entry stores an interrupt vector, which is the entry address of an interrupt handler.

Guess you like

Origin blog.csdn.net/lm68140318/article/details/132553643