When an interrupt or exception occurs in the x86 architecture, it is assigned a number called a vector. The vector determines which interrupt handler code is invoked to handle the interrupt. Common software and hardware sources of interrupts include exceptions from invalid operations, device interrupts mapped through the Programmable Interrupt Controller (PIC), and software-generated interrupts using the INT instruction. The Interrupt Descriptor Table (IDT) contains interrupt handler entries that are invoked by vector number, and the IDTR register stores the location of the active IDT. The IF flag and STI/CLI instructions control whether maskable hardware interrupts are allowed to occur.