Microcontroller › 8051 › ASM software interrupt › interrupts are used when we
interrupts are used when we need to perform a special task during regular task. the full attention of controller is removed from regular task to an important task until this important task is performed.
for example a controller is busy in blinking led on a port0. at Pin 1.0 a buzzer is connected. and a switch is connected to int0 pin. ur task is to on the buzzer when u want. if u use polling u have to monitor P3.2 continuously during led blinking process and this will consume ur 24 clock cycle in each poll. this is not efficient programming . if u use interrupt concept there is no need to monitor the pin P3.2.
example code-
ORG 0000H
LJMP MAIN;
ORG 0003H // int0 isr address
SETB P1.0; // buzzer on when interrupt occur
RETI; // return interrupt
ORG 0030H
MAIN: SETB TCON.0; // int0 an edge trigger interrupt
MOV IE,#81H; // enable harwre interrupt int0
HERE: CPL P0; // led bilinking
ACALL delay;
SJMP HERE;
Delay: // generate a delay subroutine
END