Why interrupt handlers are written in assembly language?

1 answer

Answer

1050356

2026-04-04 13:20

+ Follow

When an interrupt is requested, the currently running process is suspended and the handler is

invoked. When the handler exits, control is handed back to the running process. Since interrupts are

practically random and unplanned, when the handler passes back control, it must ensure that all

registers and stacks that it used are restored back to the exact state they were in when the process

got interrupted, so that the process can resume like as though nothing happened.

Access to these registers and stacks can only be done in assembly.

Other reasons include the fact that interrupt handlers must be very fast, and since the interrupt

routines are very short, they can be hand‐crafted to be much faster than anything a compiler

generates.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.