understanding interrupts in the intel 8085
bhaskar rijal / 16.01.2023

Think of interrupts exactly like the name suggests. It’s the processor getting a poke while it is doing something else. It allows the 8085 to pause its current program to handle a quick task and then go right back to where it left off. This is kinda useful for handling things like keyboard inputs or signals from other devices without the processor having to stare at them constantly.
The Five Main Interrupts
The 8085 has five specific types of interrupts. Each one has a specific address (vector) where the code jumps when the interrupt happens.
TRAP This is the boss. It has the highest priority and is "non-maskable," which means you cannot disable it. It is usually used for emergencies like power failures where the system needs to save data immediately. If TRAP calls, the processor has to answer.
RST 7.5, RST 6.5, and RST 5.5 These three are in the middle. They are "maskable," meaning as a programmer you can choose to ignore them if you want. They jump to their own specific addresses when triggered.
INTR This is the general-purpose external interrupt. It has the lowest priority of the group. It is usually triggered by hardware signals, like a request from a peripheral device.
How It Actually Works
When an interrupt hits, the processor does a "save game" routine.
It pauses the main program.
It saves the Program Counter so it remembers exactly which line of code it was on.
It jumps to the Vector Address of the interrupt and runs the routine for that specific task (the Interrupt Service Routine).
Once that task is done, it restores the Program Counter and goes back to the main program like nothing happened.
Chaos Control
You don't always want to be interrupted tho. The 8085 gives you control over this using flags and instructions.
IE (Interrupt Enable) Flag: This is like a master switch for the maskable interrupts (the RSTs and INTR). If it is on, interrupts work. If it is off, they get ignored.
DI and EI Instructions: These are the commands you write in your code to flip that switch.
EI(Enable Interrupts) turns the listening mode on, andDI(Disable Interrupts) turns it off so you can work in peace.
Priorities and Nesting
Since you have five different interrupts, there has to be a pecking order. If two things happen at the exact same time, the processor checks them in this order:
TRAP (Highest)
RST 7.5
RST 6.5
RST 5.5
INTR (Lowest)
There is also a concept called Nested Interrupts. This is what happens if you get interrupted while you are already handling an interrupt. The processor saves its spot again, handles the new higher-priority task, and then works its way back down the stack. It ensures that the most critical tasks always get done first.