Back to the 2014 paper

Module 2: x86 Architecture, CPU Control, I/O, Memory System Design

20142m

What is the difference between a subroutine and an interrupt service routine?

Worked SolutionAI Assisted

Subroutine vs Interrupt Service Routine (ISR):

Feature Subroutine (Procedure) Interrupt Service Routine (ISR / Interrupt Handler)
Invocation Synchronous, explicitly called by program via CALL instruction Asynchronous, invoked by hardware signal (INTR, NMI) or exception/trap. CPU diverts without program request
Control Program has control - known location in code flow Unpredictable timing, depends on external event / fault
Linkage CALL saves return address (PC) on stack; RET returns Interrupt logic saves PC and PSW/FLAGS automatically; return via IRET/RETI
Context Saving Caller may save few registers (convention dependent) Must save entire processor state (registers, flags) as interrupt can occur between any two instructions
Priority/Nesting No priority concept, normal nesting via calls Has priority; higher priority interrupts can preempt lower ISR; requires PIC (8259) arbitration
Synchronization Blocking / sequential flow Must be reentrant, short, ends with EOI to PIC; often disables interrupts at entry

Key Idea: Subroutine = software-initiated planned transfer; ISR = hardware-initiated event-driven transfer that transparently suspends current task. Example: CALL SORT vs keyboard ISR at vector 21h invoked on key press.

Similar questions

Free AppAndroid App

Coursify Android App

Generate AI courses, take quick quizzes between classes, and master complex engineering concepts on the go.