Subroutines are blocks of code that perform specific tasks and are stored separately from the main program to avoid duplicating code segments. When called, a subroutine will execute its instructions and then return control to the point from which it was called in the main program. Interrupts temporarily halt the main program to allow interrupt service routines (ISRs) to handle priority events, with the processor saving return addresses to resume the main program after interrupts are serviced. PIC microcontrollers have multiple sources of interrupts, each with associated flags to enable interrupts and indicate interrupt requests.