Interrupts, Polling, Types & 8085 Interrupt Processing
Open in the Padhaiko app5.1 Interrupt and its importance
An interrupt is an asynchronous hardware or software signal that informs the microprocessor that an external peripheral device or internal system event requires immediate service.
When an interrupt occurs:
- The microprocessor suspends execution of its current program.
- It saves its current execution state (the Program Counter) onto the stack.
- It branches to a dedicated subroutine known as an Interrupt Service Routine (ISR) or interrupt handler.
- After executing the ISR, the processor restores its saved state and resumes execution of the interrupted program exactly where it left off.
Importance of Interrupts
In real-world computer systems, interrupts are essential for three primary reasons:
- Elimination of Idle Waiting: In non-interrupt systems, the CPU must continuously query (poll) slow peripheral devices. Because peripherals operate millions of times slower than the CPU, polling wastes enormous computational bandwidth. Interrupts allow the CPU to perform useful calculations continuously while peripherals run independently.
- Immediate Real-Time Response: Time-critical events (such as power failure detection, emergency motor shutoff, industrial sensor alarms, and real-time clock ticks) must be acknowledged within microseconds. Interrupts force the CPU to respond immediately to critical signals.
- Asynchronous Concurrent I/O: Interrupts enable true asynchronous I/O operations where multiple peripherals (keyboards, serial ports, network interfaces, storage controllers) interact with the computer concurrently without interfering with the execution of the main user application.
5.2 Polling vs interrupt
Data transfer between a microprocessor and peripheral devices can be coordinated either through Polling (Programmed I/O) or through Interrupt-Driven I/O.
| Aspect | Polling (Programmed I/O) | Interrupt-Driven I/O |
|---|---|---|
| Control Mechanism | Software-driven; CPU repeatedly tests status register of peripheral in a loop | Hardware-driven; peripheral asserts physical interrupt line when ready |
| CPU Utilization | Highly wasteful; CPU spends most of its execution cycles in busy-waiting loops | Highly efficient; CPU executes main program and services devices only on demand |
| Response Latency | High latency; response time depends on how frequently the CPU checks the device | Minimal latency; CPU responds immediately after finishing current instruction |
| Priority Handling | Fixed by polling order in software loop (first polled device has highest priority) | Handled automatically by hardware daisy-chain or programmable priority controller |
| Hardware Complexity | Minimal; requires only standard I/O port buffers and latches | Requires interrupt controller hardware, vector decoders, and CPU interrupt logic |
| Scalability | Poor; adding more devices degrades system performance and increases polling delay | Excellent; many devices can share interrupt lines without slowing down the CPU |
5.3 Types of interrupts
Interrupts in microprocessor systems are classified into three primary operational categories:
1. Hardware vs Software Interrupts
- Hardware Interrupts: Initiated by an external hardware device by asserting a physical pin on the microprocessor package (e.g.,
TRAP,RST 7.5,RST 6.5,RST 5.5, andINTRon the 8085;NMIandINTRon the 8086). Hardware interrupts occur asynchronously with respect to the microprocessor internal instruction execution. - Software Interrupts: Initiated synchronously from within an executing program by invoking a specific microprocessor instruction (e.g.,
RST nwhere n = 0 to 7 on the 8085;INT nwhere n = 0 to 255 on the 8086). Software interrupts are used to invoke operating system kernel services (system calls), handle software exceptions (division by zero, overflow), and insert debugging breakpoints.
2. Vectored vs Non-Vectored Interrupts
- Vectored Interrupts: The microprocessor internal hardware automatically determines the starting memory address of the Interrupt Service Routine (the Vector Address). No external hardware is required to provide the address over the data bus.
- On the 8085:
TRAP(0024H),RST 7.5(003CH),RST 6.5(0034H), andRST 5.5(002CH) are vectored interrupts.
- On the 8085:
- Non-Vectored Interrupts: The microprocessor does not know the vector address in advance. Instead, when the processor acknowledges the interrupt by pulsing
INTA_barLOW, an external peripheral or interrupt controller must supply an instruction (such asRST norCALL <addr>) over the data bus.- On the 8085,
INTRis the only non-vectored hardware interrupt.
- On the 8085,
3. Maskable vs Non-Maskable Interrupts
- Maskable Interrupts: Interrupts that can be enabled, disabled, or ignored under software control by manipulating internal control flags or mask bits.
- On the 8085,
INTR,RST 5.5,RST 6.5, andRST 7.5are maskable interrupts.
- On the 8085,
- Non-Maskable Interrupts (NMI): Interrupts that cannot be disabled, masked, or ignored by any software instruction. When asserted, the CPU must acknowledge and service the interrupt immediately. Non-maskable interrupts are reserved exclusively for catastrophic events such as AC power failure detection, RAM bus parity errors, or watchdog timer timeouts.
- On the 8085,
TRAPis the only non-maskable interrupt.
- On the 8085,
5.4 Interrupts in 8085 and interrupt instructions
The Intel 8085 microprocessor features five hardware interrupt pins, listed below in strict order of hardware priority:
| Interrupt Name | Priority | Trigger Sensitivity | Maskability | Vector Address (Hex) | Vector Address (Dec) |
|---|---|---|---|---|---|
| TRAP | 1 (Highest) | Level AND Rising Edge | Non-maskable | 0024H | 36 |
| RST 7.5 | 2 | Rising Edge Only (Latched) | Maskable (via SIM) | 003CH | 60 |
| RST 6.5 | 3 | Level Sensitive (HIGH) | Maskable (via SIM) | 0034H | 52 |
| RST 5.5 | 4 | Level Sensitive (HIGH) | Maskable (via SIM) | 002CH | 44 |
| INTR | 5 (Lowest) | Level Sensitive (HIGH) | Maskable (via EI/DI) | Supplied externally | Variable |
Triggering Characteristics of 8085 Interrupts
- TRAP (Non-Maskable, Highest Priority):
- It requires both a rising edge and a sustained HIGH level: the signal must make a low-to-high transition to be recognized and remain HIGH until the 8085 samples it. This dual sensitivity prevents false triggering caused by electrical noise spikes.
- It cannot be disabled by
DIorSIM. - Vector address = 4.5 x 8 = 36 = 0024H.
- RST 7.5 (Edge-Sensitive):
- It is triggered strictly by a rising edge (low-to-high transition).
- The edge sets an internal D flip-flop inside the 8085. Therefore, even if the external pulse goes LOW before the CPU finishes its current instruction, the interrupt request remains stored (latched) until serviced or cleared.
- Vector address = 7.5 x 8 = 60 = 003CH.
- RST 6.5 and RST 5.5 (Level-Sensitive):
- Triggered by a continuous logic HIGH level.
- These pins have no internal latches; the external signal must be held HIGH until the processor samples and recognizes the interrupt during the final clock state of the executing instruction.
- Vector addresses: RST 6.5 = 6.5 x 8 = 52 = 0034H; RST 5.5 = 5.5 x 8 = 44 = 002CH.
- INTR (General-Purpose, Non-Vectored):
- Level-sensitive input sampled during the last clock cycle of each instruction.
- When accepted, the 8085 asserts
INTA_bar(Interrupt Acknowledge, pin 12) LOW. The external hardware must place a single-byteRST ninstruction (opcodes C7H, CFH, D7H, DFH, E7H, EFH, F7H, FFH) or a three-byteCALLinstruction on data bus D7–D0.
8085 Interrupt Control Instructions
The 8085 provides four dedicated machine instructions to manage its interrupt subsystem:
1. EI (Enable Interrupts)
- Opcode: FBH (1 byte, 4 T-states).
- Sets the internal Interrupt Enable (IE) flip-flop.
- Enables
INTR,RST 7.5,RST 6.5, andRST 5.5.
2. DI (Disable Interrupts)
- Opcode: F3H (1 byte, 4 T-states).
- Resets the internal Interrupt Enable (IE) flip-flop.
- Disables all maskable interrupts (
INTR,RST 7.5,RST 6.5,RST 5.5). Does NOT affectTRAP. - The IE flip-flop is also automatically cleared when:
- System hardware
RESETis asserted. - Any interrupt is accepted by the CPU.
- System hardware
3. SIM (Set Interrupt Mask)
- Opcode: 30H (1 byte, 4 T-states).
- A multipurpose instruction that reads the 8-bit contents of the Accumulator to program the interrupt masks for RST 7.5, RST 6.5, RST 5.5, reset the RST 7.5 flip-flop, and output serial data onto the
SODpin.
+----+----+----+----+----+----+----+----+
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
+----+----+----+----+----+----+----+----+
| | | | | | | |
| | | | | | | +---> M5.5: Mask RST 5.5 (1=Masked, 0=Available)
| | | | | | +--------> M6.5: Mask RST 6.5 (1=Masked, 0=Available)
| | | | | +-------------> M7.5: Mask RST 7.5 (1=Masked, 0=Available)
| | | | +------------------> MSE: Mask Set Enable (1=Update D2–D0, 0=Ignore D2–D0)
| | | +-----------------------> R7.5: Reset RST 7.5 flip-flop (1=Clear pending request)
| | +----------------------------> 0: Unused / don't care
| +---------------------------------> SDE: Serial Data Enable (1=Output D7 to SOD pin)
+--------------------------------------> SOD: Serial Output Data bit4. RIM (Read Interrupt Mask)
- Opcode: 20H (1 byte, 4 T-states).
- Loads the Accumulator with the current status of the interrupt mask bits, pending interrupt requests, the Interrupt Enable flag, and the serial input pin (
SID).
+----+----+----+----+----+----+----+----+
| D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
+----+----+----+----+----+----+----+----+
| | | | | | | |
| | | | | | | +---> M5.5: Current mask status of RST 5.5 (1=Masked)
| | | | | | +--------> M6.5: Current mask status of RST 6.5 (1=Masked)
| | | | | +-------------> M7.5: Current mask status of RST 7.5 (1=Masked)
| | | | +------------------> IE: Interrupt Enable flag (1=Interrupts enabled)
| | | +-----------------------> P5.5: Pending request on RST 5.5 (1=Pending)
| | +----------------------------> P6.5: Pending request on RST 6.5 (1=Pending)
| +---------------------------------> P7.5: Pending request on RST 7.5 (1=Pending)
+--------------------------------------> SID: Current logic level on physical SID pin5.5 Interrupt service routine
An Interrupt Service Routine (ISR) is a specialized subroutine designed to service a specific hardware or software interrupt condition.
Memory Organization of 8085 Vector Table
The 8085 reserves the first 64 bytes of memory (0000H through 003FH) for restart and interrupt vector locations. Each restart vector is allocated exactly 8 bytes of memory:
| Instruction / Pin | Vector Formula | Hex Address | Memory Available | Typical Action |
|---|---|---|---|---|
| System RESET / RST 0 | 0 x 8 | 0000H | 8 bytes (0000H–0007H) | Power-on initialization jump (JMP MAIN) |
| RST 1 | 1 x 8 | 0008H | 8 bytes (0008H–000FH) | Software restart / debug handler |
| RST 2 | 2 x 8 | 0010H | 8 bytes (0010H–0017H) | Software restart |
| RST 3 | 3 x 8 | 0018H | 8 bytes (0018H–001FH) | Software restart |
| RST 4 | 4 x 8 | 0020H | 4 bytes (0020H–0023H) | Software restart |
| TRAP | 4.5 x 8 | 0024H | 4 bytes (0024H–0027H) | Emergency power failure / critical fault jump |
| RST 5 | 5 x 8 | 0028H | 4 bytes (0028H–002BH) | Software restart |
| RST 5.5 | 5.5 x 8 | 002CH | 4 bytes (002CH–002FH) | Hardware interrupt jump (JMP ISR_55) |
| RST 6 | 6 x 8 | 0030H | 4 bytes (0030H–0033H) | Software restart |
| RST 6.5 | 6.5 x 8 | 0034H | 4 bytes (0034H–0037H) | Hardware interrupt jump (JMP ISR_65) |
| RST 7 | 7 x 8 | 0038H | 4 bytes (0038H–003BH) | Software restart |
| RST 7.5 | 7.5 x 8 | 003CH | 4 bytes (003CH–003FH) | Hardware interrupt jump (JMP ISR_75) |
Because vector locations are separated by only 4 or 8 bytes, an entire ISR cannot fit in the vector space. Instead, a 3-byte unconditional jump instruction (JMP <ISR_ADDRESS>) is placed at the vector location, redirecting execution to the full ISR located elsewhere in system memory.
Standard Structure of an ISR
A robust ISR follows five essential steps:
- Context Saving: Save all CPU registers that the ISR will modify onto the stack using
PUSHinstructions (PUSH PSW,PUSH B,PUSH D,PUSH H). - Execute Device Service: Perform the required data read, write, or algorithmic operation.
- Context Restoration: Restore the saved registers in reverse order using
POPinstructions (POP H,POP D,POP B,POP PSW). - Re-Enable Interrupts: The 8085 hardware automatically disables maskable interrupts upon accepting an interrupt request. The ISR must execute an
EIinstruction immediately before returning so subsequent interrupts can be serviced. - Return: Execute
RET(Return) to pop the return address from the stack into the Program Counter.
5.6 Interrupt processing in 8085
The complete cycle of 8085 interrupt handling consists of an automated sequence of hardware operations followed by software execution:
Eight-Stage 8085 Interrupt Processing Sequence
- Stage 1 — Signal Assertion: An external peripheral asserts an interrupt pin (TRAP, RST 7.5, RST 6.5, RST 5.5, or INTR).
- Stage 2 — Completion of Current Instruction: The 8085 never aborts an instruction mid-cycle. It completes the execution of the current instruction to maintain architectural consistency.
- Stage 3 — Sampling and Priority Evaluation: During the final clock cycle (T-state) of the executing instruction, internal CPU logic samples all interrupt pins. If multiple lines are active, the internal priority resolver selects the request with the highest hardware priority.
- Stage 4 — Condition Check: The processor verifies that:
- The selected interrupt is not masked (in the SIM mask register).
- Maskable interrupts are globally enabled (internal
IE = 1). (TRAP bypasses these checks as it is non-maskable).
- Stage 5 — Automatic Hardware Disable: The 8085 automatically clears the internal Interrupt Enable flip-flop (
IE = 0), disabling all maskable interrupts to prevent nested interrupt collisions. - Stage 6 — Return Address Pushed to Stack: The 8085 pushes the 16-bit Program Counter (the address of the next sequential instruction) onto the stack:
- High byte of PC is stored at
[SP - 1] - Low byte of PC is stored at
[SP - 2] - Stack Pointer is decremented by 2 (
SP = SP - 2).
- High byte of PC is stored at
- Stage 7 — Vector Generation or Acknowledgment:
- For Vectored Interrupts (TRAP, RST 5.5, RST 6.5, RST 7.5): The internal hardware forces the corresponding vector address (0024H, 002CH, 0034H, or 003CH) into the Program Counter.
- For Non-Vectored Interrupt (INTR): The 8085 generates an active-low INTA_bar (Interrupt Acknowledge) strobe. During this cycle, external hardware places an instruction (e.g.,
RST n, opcode11nn n111B) onto data lines D7–D0. The 8085 fetches and executes this instruction, branching ton x 8.
- Stage 8 — Execution of ISR and Return: The 8085 begins executing instructions at the vector location. The ISR performs its task, re-enables interrupts via
EI, and executesRET. TheRETinstruction pops the stored 16-bit address from the stack into the Program Counter, resuming the main program.
Worked Examples
Configuring 8085 Interrupt Masks Using the SIM Instruction
An 8085 microprocessor system requires the following interrupt configuration:
- Unmask RST 7.5 and RST 6.5 (allow both interrupts to be serviced).
- Mask RST 5.5 (disable RST 5.5).
- Reset the internal RST 7.5 edge-triggered flip-flop to clear any prior pending request.
- Do not affect the Serial Output Data (SOD) pin.
- Construct the 8-bit accumulator mask word in binary and hexadecimal.
- Write the assembly instruction sequence to apply this mask configuration and globally enable interrupts. Show register states and timing.
Determine Accumulator Bit Values for SIM: The bit fields of the Accumulator for SIM are defined as:
D0(M5.5):1(Mask / Disable RST 5.5)D1(M6.5):0(Unmask / Enable RST 6.5)D2(M7.5):0(Unmask / Enable RST 7.5)D3(MSE):1(Mask Set Enable: must be 1 to update bits D2–D0)D4(R7.5):1(Reset RST 7.5 flip-flop to clear pending request)D5:0(Unused)D6(SDE):0(Serial Data Enable disabled; SOD pin is unchanged)D7(SOD):0(Don't care since SDE = 0)
Combining bits D7 down to D0: Accumulator Byte = 0 0 0 1 1 0 0 1 B = 19H
Assembly Instruction Sequence:
ORG 2000H
MVI A,19H
SIM
EI
HLTInstruction Trace and Register States:
MVI A,19H: Loads the formulated control word 19H into the Accumulator.
SIM: Transfers Accumulator bits into the internal interrupt mask register: RST 5.5 is masked (disabled), RST 6.5 and RST 7.5 are unmasked, and the RST 7.5 edge flip-flop is reset. Machine cycles: Opcode Fetch (4T) = 4 T-states.EI: Sets internal Interrupt Enable flip-flop (IE = 1), globally enabling maskable interrupts. Machine cycles: Opcode Fetch (4T) = 4 T-states.
The Accumulator byte for SIM is 19H (00011001B). The sequence MVI A,19H, SIM, and EI applies the mask, clears pending RST 7.5 requests, and enables interrupts globally.
Interrupt-Driven Pulse Counter Program with RST 7.5
Design an interrupt-driven pulse counter for an 8085 microprocessor. External sensor pulses arrive on the RST 7.5 hardware interrupt pin.
- The main program must initialize a 16-bit memory variable
COUNTERat memory address 2050H to 0000H, unmask RST 7.5 (with RST 6.5 and RST 5.5 masked), globally enable interrupts, and wait for pulses. - Write the Interrupt Service Routine (ISR) starting at address 2100H that increments
COUNTERby 1 upon each pulse, saves and restores registers, re-enables interrupts, and returns. Show vector linking and register states.
Formulate SIM Control Word for Main Program:
- Mask RST 5.5: D0 = 1
- Mask RST 6.5: D1 = 1
- Unmask RST 7.5: D2 = 0
- Mask Set Enable: D3 = 1
- Reset RST 7.5 flip-flop: D4 = 1
- SDE = 0, SOD = 0
Control Word = 0 0 0 1 1 0 1 1 B = 1BH
Vector Location Setup (at 003CH): Because RST 7.5 vectors to address 003CH, we place a 3-byte unconditional jump at 003CH:
ORG 003CH
JMP 2100HMain Program and ISR Implementation:
ORG 2000H
LXI SP,2400H
LXI H,0000H
SHLD 2050H
MVI A,1BH
SIM
EI
WAIT_LOOP:
HLT
JMP WAIT_LOOP
ORG 2100H
PUSH PSW
PUSH H
LHLD 2050H
INX H
SHLD 2050H
POP H
POP PSW
EI
RETExecution Trace on First Interrupt Event:
- A rising edge on RST 7.5 sets the internal flip-flop.
- The 8085 finishes its current instruction, pushes return address (200EH, the instruction after
HLT) onto stack at 23FEH, disables interrupts, and jumps to 003CH. - At 003CH,
JMP 2100Hdirects execution to the ISR. - In ISR,
LHLD 2050Hloads 0000H into HL.INX Hincrements HL to 0001H.SHLD 2050Hsaves 0001H back into memory.
- Registers are popped,
EIenables interrupts, andRETrestores PC to resume theWAIT_LOOP.
The main program configures SIM with 1BH and sets the stack. The vector at 003CH jumps to 2100H, where the ISR preserves registers, increments the 16-bit count at 2050H, executes EI, and returns.
Interpreting 8085 Interrupt Status Using the RIM Instruction
During the execution of an industrial controller program, an 8085 microprocessor executes the RIM instruction. The Accumulator is loaded with the hexadecimal value 5DH.
Decode this byte completely and determine:
- The logic level currently present on the physical
SIDpin. - The status of pending interrupt requests on
RST 7.5,RST 6.5, andRST 5.5. - The status of the internal Interrupt Enable (
IE) flip-flop. - The individual mask status of
RST 7.5,RST 6.5, andRST 5.5.
Convert Hexadecimal Status Byte to Binary: 5DH = 0 1 0 1 1 1 0 1 B
Assign bit positions D7 down to D0:
D7= 0D6= 1D5= 0D4= 1D3= 1D2= 1D1= 0D0= 1
Map Bits to RIM Register Definitions:
- SID Pin (Bit D7 = 0): The serial input data line
SIDis at logic 0 (0V). - Pending Interrupts (Bits D6, D5, D4):
D6(P7.5= 1): A hardware request is pending on RST 7.5 (latched in its flip-flop).D5(P6.5= 0): No request pending on RST 6.5.D4(P5.5= 1): A hardware request is pending on RST 5.5.
- Interrupt Enable Flag (Bit D3 = 1):
IE = 1: The internal Interrupt Enable flip-flop is set (interrupts are globally enabled viaEI). - Mask Bits (Bits D2, D1, D0):
D2(M7.5= 1): RST 7.5 is masked (disabled). Even though a request is pending (P7.5=1), the CPU will not service it until unmasked.D1(M6.5= 0): RST 6.5 is unmasked (available).D0(M5.5= 1): RST 5.5 is masked (disabled).
SID pin = 0; Pending interrupts: RST 7.5 is pending, RST 6.5 is not pending, RST 5.5 is pending; Interrupt Enable flag = 1 (enabled); Masks: RST 7.5 is masked, RST 6.5 is unmasked, RST 5.5 is masked.
Exercises
Exercises
Construct a comprehensive reference table for all five hardware interrupts of the Intel 8085 microprocessor. For each interrupt, specify: priority rank, triggering sensitivity (edge, level, or both), maskability, and the exact vector address in both hexadecimal and decimal notation.
Hardware Interrupt Summary Table:
| Interrupt Name | Priority Rank | Trigger Type | Maskability | Vector Address (Hex) | Vector Address (Decimal) |
|---|---|---|---|---|---|
| TRAP | 1 (Highest) | Level AND Rising Edge | Non-Maskable | 0024H | 36 (4.5 x 8) |
| RST 7.5 | 2 | Rising Edge Only (Latched) | Maskable (via SIM) | 003CH | 60 (7.5 x 8) |
| RST 6.5 | 3 | High Level Sensitive | Maskable (via SIM) | 0034H | 52 (6.5 x 8) |
| RST 5.5 | 4 | High Level Sensitive | Maskable (via SIM) | 002CH | 44 (5.5 x 8) |
| INTR | 5 (Lowest) | High Level Sensitive | Maskable (via EI/DI) | Non-vectored | Supplied by external hardware |
Engineering Observations on Triggering Differences:
TRAPrequires both a rising edge and a sustained HIGH level to prevent noise spikes from falsely triggering an unmaskable routine.RST 7.5is edge-triggered; its internal flip-flop stores narrow pulses even if the line returns LOW before instruction completion.RST 6.5,RST 5.5, andINTRare level-sensitive; the external device must hold the pin HIGH until the CPU enters the acknowledge phase.
TRAP (Priority 1, Non-maskable, Edge+Level, 0024H / 36); RST 7.5 (Priority 2, Maskable, Edge, 003CH / 60); RST 6.5 (Priority 3, Maskable, Level, 0034H / 52); RST 5.5 (Priority 4, Maskable, Level, 002CH / 44); INTR (Priority 5, Maskable, Level, Non-vectored).
Compare Polling and Interrupt-Driven I/O across five critical criteria. Under what specific operational condition is Polling technically superior to an Interrupt-Driven design?
Comparison of Polling and Interrupt-Driven I/O:
- CPU Overhead: Polling wastes hundreds of thousands of CPU cycles executing query loops. Interrupts consume zero CPU cycles until the peripheral requires service.
- System Throughput: Interrupt systems provide dramatically higher overall throughput because the CPU executes computational algorithms concurrently with peripheral activity.
- Response Speed (Latency): Interrupts offer near-instantaneous response (serviced immediately after the current instruction completes). Polling latency depends on loop execution time.
- Hardware Complexity: Polling requires no specialized interrupt controllers, request pins, or vector tables. Interrupts require priority arbitration and vector hardware.
- Multiple Devices: Polling slows down linearly as more devices are added. Interrupt systems handle dozens of devices with priority-based queuing.
When Polling is Technically Superior: Polling is superior in dedicated, single-purpose embedded controllers where the processor has no other computational tasks and data arrives continuously at very high rates (e.g., continuous ADC streaming or high-speed packet capture).
In such scenarios:
- The overhead of saving and restoring CPU registers (
PUSH/POP), flushing pipelines, and executingCALL/RETsequences during an interrupt takes 20 to 50 clock cycles. - A tight polling loop (
IN,ANI,JNZ) detects and processes incoming data in fewer clock cycles than the interrupt context-switch penalty.
Interrupts maximize CPU efficiency and provide low-latency response. Polling is superior only in dedicated single-task systems where data arrives continuously at maximum speed, avoiding the 20–50 cycle context-switch overhead of interrupt handling.
Explain the step-by-step sequence of internal hardware and software operations performed by the 8085 microprocessor when an interrupt request is acknowledged, serviced, and completed.
Step-by-Step Interrupt Sequence:
- Current Instruction Completion: The 8085 finishes executing the current instruction.
- Interrupt Sampling and Priority Arbitration: During the final T-state, interrupt lines are sampled. If multiple lines are active, the internal priority logic selects the highest priority active line.
- Mask and Enable Validation: The CPU verifies that the interrupt is unmasked and that the Interrupt Enable flip-flop is set (
IE = 1). - Hardware Disable: The 8085 automatically clears
IE = 0, temporarily disabling all maskable interrupts to prevent nested conflicts. - Stacking Return Address: The CPU decrements the Stack Pointer by 2 and pushes the 16-bit contents of the Program Counter (the return address) onto the stack (
PCLat SP-2,PCHat SP-1). - Vector Generation:
- For vectored pins (TRAP, RST 7.5, RST 6.5, RST 5.5), the PC is loaded with the hardwired vector address.
- For INTR, the CPU asserts
INTA_barLOW, and the external controller supplies an instruction byte (RST norCALL).
- ISR Execution: The processor begins executing the ISR, saving working registers via
PUSH. - Re-enabling and Return: The ISR executes
EIto re-enable interrupts and finishes withRET.RETpops the 16-bit address from the stack into the PC, resuming the interrupted program.
The 8085 finishes the current instruction, resolves priority, clears IE to 0, pushes the Program Counter onto the stack, vectors to the ISR (automatically or via INTA_bar), executes the service routine, re-enables interrupts with EI, and returns via RET.
Explain the bit structures and operational roles of the SIM (Set Interrupt Mask) and RIM (Read Interrupt Mask) instructions in the 8085 microprocessor.
Construct the SIM control byte to:
- Unmask RST 5.5
- Mask RST 6.5 and RST 7.5
- Enable the Serial Output Data (SOD) pin and output a logic 1 onto SOD.
SIM and RIM Roles:
- SIM (Set Interrupt Mask): An output instruction that reads Accumulator bits to update the hardware masks for RST 7.5, RST 6.5, and RST 5.5, reset the RST 7.5 edge flip-flop, and transmit serial data out of the SOD pin.
- RIM (Read Interrupt Mask): An input instruction that loads the Accumulator with the current mask settings, pending interrupt states, Interrupt Enable status, and the current level on the physical SID pin.
Formulate SIM Control Byte: Bit requirements:
D0(M5.5):0(Unmask RST 5.5)D1(M6.5):1(Mask RST 6.5)D2(M7.5):1(Mask RST 7.5)D3(MSE):1(Enable mask bits D2–D0)D4(R7.5):0(Do not reset RST 7.5 flip-flop)D5:0(Unused)D6(SDE):1(Serial Data Enable active)D7(SOD):1(Output logic 1 on SOD pin)
Assembled byte: D7 D6 D5 D4 D3 D2 D1 D0 = 1 1 0 0 0 1 1 0 B = C6H
SIM programs interrupt masks and outputs serial data; RIM reads masks, pending requests, and serial input. The control byte to unmask RST 5.5, mask RST 6.5/7.5, and output logic 1 on SOD is C6H (11000110B).
Design an interface circuit for the non-vectored INTR interrupt pin of the 8085 microprocessor using a 74LS244 octal buffer. When an external device asserts INTR, the circuit must respond to the active-low INTA_bar strobe by placing the software restart instruction RST 6 (opcode F7H) onto data bus lines D7–D0.
Calculate the vector address of RST 6, specify the hardwired connections to the 74LS244 buffer, and write an 8085 assembly initialization routine.
Vector Address and Opcode for RST 6: The restart formula is: Vector Address = 6 x 8 = 48 = 0030H.
The opcode for RST n is 11 nnn 111B. For n = 6 (110B): Opcode = 1 1 1 1 0 1 1 1 B = F7H
Hardware Interconnection with 74LS244 Octal Buffer:
- Inputs (1A1–1A4, 2A1–2A4):
- Connect lines corresponding to logic 1 (bits D7, D6, D5, D4, D2, D1, D0) to +5V (Vcc) through pull-up resistors.
- Connect the line corresponding to logic 0 (bit D3) directly to ground (0V).
- Outputs (1Y1–1Y4, 2Y1–2Y4):
- Connect directly to 8085 data bus lines D7 through D0.
- Enable Inputs (1OE_bar, 2OE_bar):
- Tie both active-low output enables to the 8085 INTA_bar pin (pin 12).
- During normal operation,
INTA_bar = 1; buffer outputs remain high-impedance. - When the 8085 acknowledges an INTR request, it pulls
INTA_barLOW; the 74LS244 drives F7H (RST 6) onto D7–D0.
Assembly Initialization Routine:
ORG 2000H
LXI SP,2400H
EI
HLT
ORG 0030H
JMP ISR_RST6
ISR_RST6:
PUSH PSW
MVI A,01H
OUT 80H
POP PSW
EI
RETRST 6 vectors to 0030H (48). Its opcode F7H (11110111B) is hardwired into the inputs of a 74LS244 buffer enabled by INTA_bar. The 8085 reads F7H on INTA_bar, pushes the return address to the stack, and branches to 0030H.