How processor handles case of division by zero

前端 未结 3 1447
刺人心
刺人心 2020-12-10 04:33

Curious what the processor/CPU does in general or let say, on intel cpu & Linux, when it executes a division by zero instruction. Also how the error is relayed to the ap

3条回答
  •  悲哀的现实
    2020-12-10 04:59

    Let me try to answer this a little differently. Every processor I have worked with defines an interrupt vector structure. On the Intel chips this structure is called the interrupt dispatch table (IDT). The interrupt vector is an array of pointers to functions. Each entry in the array corresponds to a specific event (interrupt or exception (fault or trap)).

    The operating system sets up the functions (interrupt handler, exception handler) for each event. When a divide by zero occurs, it triggers an exception. The CPU responds by invoking the exception handler in the interrupt vector corresponding to a divide by zero. On the Pentium, this is the very first entry in the table.

提交回复
热议问题