difference of 'INT' instruction between Linux and Windows

后端 未结 2 466
别跟我提以往
别跟我提以往 2021-01-22 11:47

I write some code to make my own operating system and study x86 assembly language, too. While studying x86 assembly language, I start wondering about interrupt. Look at below as

相关标签:
2条回答
  • 2021-01-22 12:25

    The int instruction raises a software interrupt. This causes the CPU to execute an interrupt handler from the interrupt description table (IDT). On startup, the BIOS sets up an IDT with a number of interrupt handlers that perform some elementary services. DOS adds its own interrupt handlers to this table to provide DOS specific functionality.

    Modern operating systems run in protected mode. In this mode, the BIOS services do not function as they are written to be executed in real mode. A modern operating system typically replaces the standard interrupt description table with a custom table. Thus, neither DOS nor BIOS services are available.

    0 讨论(0)
  • 2021-01-22 12:47

    The INT instruction triggers an exception almost like a divide by zero causes an exception. The difference is that INT allows you to specify what exception you are triggering.

    The operating system must define a table of exception and interrupt handlers. The location and size of the table is defined by hardware register IDTR. The various exceptions (like divide by zero) have an assigned exception number. (INT allows specifying any exception number.)

    See https://en.wikipedia.org/wiki/Interrupt_descriptor_table

    When an exception (or interrupt) occurs, the CPU uses the exception/interrupt number as an index into the table and calls the specific handler.

    The operating system defines the table and the handlers for interrupts and exceptions so they are different amount operating systems.

    0 讨论(0)
提交回复
热议问题