C Program to Demonstrate use of Interrupts in C Programming


Power of Interrupts :

  • Interrupts are messages to the Pentium chip to halt it current activity, and perform our requested job.
  • We can almost do anything using interrupts without using functions.
  • Note below example – we haven’t used printf() still we are able to print message on screen.

Live Program :

Output:


Explanation of Program :

  • dos.h header file contain geninterrupt() function which is  used to create interrupt.
  • geninterrupt(0x21) is used to generate 0x21 interrupt.
  • Note that the sentence is ended with a ‘$’ which is a terminating character.
  • geninterrupt(0x21) means that we want to generate the 0x21 interrupt.
  • The ‘0x’ prefix is given which tells that the number is in hexadecimal.
  • There are many interrupts, each having its own unique number.

  • We want to fill the register AH with integer 9.
  • Register is actually a memory location inside your Pentium chip.

  • We are storing the address of the message to register DX.