📝 Interrupt Driven I/O Data Transfer in 8085 Microprocessor (31 MCQs)
Peripheral-Initiated Data Transfer Using Interrupt Requests
Interrupt-driven I/O allows an external device to request data-transfer service from the 8085 when it becomes ready. Instead of continuously checking device status, the processor executes its normal program until an interrupt request is recognized. It then temporarily transfers control to an interrupt service routine that performs the required input or output operation.
Interrupt Inputs and Priority in Device Communication
The 8085 provides TRAP, RST 7.5, RST 6.5, RST 5.5 and INTR as hardware interrupt inputs. Their priority decreases in that order. A peripheral can connect to an appropriate interrupt request, subject to its electrical interface, priority requirements, triggering characteristics and masking configuration.
Interrupt Recognition and Service-Routine Execution
The processor completes the current instruction before accepting an eligible interrupt. It saves the return address on the stack and transfers control to the appropriate vector or externally supplied instruction. The service routine identifies the device condition, transfers data through IN or OUT, and returns using RET after the required interrupt-enable handling.
Example of Interrupt-Driven Input Through RST 6.5
Assume an input device requests service through enabled RST 6.5. The processor transfers control to vector address 0034H, where a jump can lead to the service routine. The routine executes IN 81H and STA 2050H to read the input byte and save it in memory before returning.
Reduced Processor Waiting and Service-Routine Organization
Interrupt-driven I/O avoids continuous polling and allows the processor to perform other calculations while waiting for external events. Service routines isolate device-handling operations from the main program. However, interrupt response, register preservation, request clearing and peripheral acknowledgement must be handled correctly to prevent lost or repeated service requests.
Misconceptions About Interrupt-Driven Data Transfer
'The peripheral directly writes data into the accumulator' is incorrect because the processor executes the service routine. 'Interrupt-driven I/O requires continuous polling' confuses it with programmed I/O. 'Accepting an interrupt automatically transfers an entire data block' is incorrect because each required transfer must be performed by the service routine or another transfer mechanism.
Interrupt Service and Data-Transfer Sequence Questions
Practise identifying interrupt requests, priority, vector addresses and service-routine operations. Trace the saved return address, peripheral data read and return sequence. Understand when EI and DI are used, and distinguish interrupt-driven I/O from programmed polling and DMA, where an external controller performs the data transfer.
Interrupt-Driven I/O and Service-Routine Terms
- Interrupt Request - Asks the processor for service.
- ISR - Handles the interrupt event.
- Vector Address - Identifies an interrupt entry location.
- RST 6.5 - Level-sensitive hardware interrupt.
- EI - Enables maskable interrupts.
- RET - Returns from the service routine.
📝 All Interrupt Driven I/O Data Transfer in 8085 Microprocessor MCQs
Q1. What is the purpose of the CMA instruction in 8085 assembly?
📖 Explanation: The CMA (Complement Accumulator) instruction flips every bit of the accumulator, producing the 1's complement of the original byte. This is essential when forming a 2's complement because the next step adds 1. Options A, C, and D describe different instructions (INR, STAX, ADI) and therefore are incorrect. Understanding CMA helps students see how low‑level bit manipulation prepares data for arithmetic operations in real hardware.
Q2. In the given program, which register pair holds the address of the output memory starting at 2201 H?
📖 Explanation: The LXI D, 2201 H instruction loads the D‑E register pair with the address 2201 H, making it the pointer for storing results. H‑L is used for the input address, while B‑C and A‑F are not valid register pairs in 8085. Recognizing the role of D‑E clarifies how the program separates source and destination locations, a key concept for designing memory‑mapped I/O routines.
Q3. Why does the program use the ADI 01 H instruction after CMA?
📖 Explanation: After obtaining the 1's complement with CMA, adding 1 (ADI 01 H) yields the 2's complement of the original byte, which is the desired arithmetic negation. This step is necessary because 2's complement equals 1's complement plus one. Options A, B, and D either misstate the purpose or describe other operations, so they are incorrect. Grasping this sequence is vital for implementing signed arithmetic in embedded systems.
Q4. If the input byte at 2101 H is 0xFF, what value will be stored at 2201 H after the first iteration?
📖 Explanation: Starting with 0xFF, CMA produces 0x00 (the 1's complement). Adding 1 with ADI 01 H gives 0x01, but the program then stores the accumulator before checking the carry. Since the carry flag is set after the addition, the JNC branch is not taken, and the B register is loaded with 0x01, which is later added to the next byte. However, the first stored result is the accumulator value before any further addition, which is 0x00. This illustrates how overflow handling influences stored data.
Q5. Which instruction decrements the counter C after processing each byte?
📖 Explanation: The DCR C instruction subtracts one from the contents of register C, which holds the byte count N. This decrement occurs after each byte is processed, ensuring the loop terminates after N iterations. INX C and DCX C are not valid 8085 instructions, and DEC C would affect the accumulator, not the counter. Understanding loop control mechanisms is essential for writing correct interrupt‑driven I/O routines that process a variable number of bytes.
Q6. When the program encounters a carry after adding the previous carry bit, which register is set to 0x01?
📖 Explanation: If the addition of the previous carry (stored in B) to the current byte generates a new carry, the program executes MVI B, 01 H, loading B with 0x01 to propagate the carry to the next iteration. Register A holds the accumulator, D is part of the destination address, and H is part of the source address. This behavior demonstrates how software can emulate multi‑byte addition by manually handling carries across bytes.
Q7. A system requires converting a 4‑byte signed integer from two's complement to its magnitude representation using interrupt‑driven I/O. Which sequence correctly adapts the given program?
📖 Explanation: To obtain the magnitude, the program must first check the most significant byte for a negative sign. If negative, it should complement each byte (CMA) and then add 1 to the least significant byte, propagating carries across the remaining bytes—exactly what the original algorithm does. Simply swapping CMA for a non‑existent NEG instruction or removing carry handling would produce incorrect results, and applying ADI 01 H alone would not handle the sign correctly. This adaptation mirrors real‑world needs for signed‑to‑unsigned conversion in interrupt‑driven data streams.
Q8. Why is the JNC instruction used after storing each complemented byte?
📖 Explanation: JNC (Jump if No Carry) checks the status of the carry flag after the addition. If no carry occurred, the program loads B with 0x00; otherwise, it loads B with 0x01, ensuring the correct propagation of the carry to the next byte's addition. Skipping storage (option A) is not the purpose, and resetting the accumulator (option D) is unrelated. Understanding JNC's role is crucial for implementing multi‑byte arithmetic in interrupt‑driven I/O where each byte may affect the next.
Q9. In an interrupt‑driven I/O scenario, what advantage does using a counter register (C) provide over polling the end‑of‑transfer flag?
📖 Explanation: Using a counter to track remaining bytes lets the CPU perform other tasks while an interrupt service routine handles each byte, avoiding continuous polling that wastes cycles. Interrupt vectors (option B) are still required, and simultaneous device handling (option C) needs additional mechanisms. Zero latency (option D) is unrealistic because interrupt handling incurs some delay. This advantage aligns with real‑time system design where efficiency is paramount.
Q10. Which register pair is incremented to point to the next source byte after each loop iteration?
📖 Explanation: The INX H instruction increments the H‑L pair, moving the source pointer to the next memory location containing the next input byte. D‑E points to the destination address and is also incremented separately. B‑C and A‑F are not valid register pairs for addressing in 8085. Recognizing the role of H‑L clarifies how sequential memory access is achieved during interrupt‑driven data processing.
Q11. If the byte count N stored at 2100 H is 0x02, how many times will the LOOP label be executed?
📖 Explanation: The program loads C with the value at 2100 H (0x02) and decrements C at the end of each loop iteration. The JNZ instruction causes the loop to repeat while C ≠ 0. Starting from 0x02, the loop runs twice before C reaches zero and the program exits. This simple counting illustrates basic loop control in interrupt‑driven routines.
Q12. Which of the following best describes the role of the HLT instruction at the end of the program?
📖 Explanation: HLT stops the processor until the next interrupt occurs, effectively ending the current routine. It does not disable interrupts (option A), clear the accumulator (option C), or reset the program counter (option D). In interrupt‑driven designs, placing HLT after processing ensures the CPU remains idle until another I/O event triggers a new interrupt.
Q13. During execution, the program stores the intermediate result using STAX D. What does STAX D do?
📖 Explanation: STAX D writes the contents of the accumulator to the memory location pointed to by the D‑E register pair, which was initialized to 2201 H. This enables the program to write each computed 2's complement byte to the output area. Options B, C, and D describe other addressing modes that are not used here. Understanding STAX is key for storing results in interrupt‑driven I/O workflows.
Q14. Which condition causes the program to load B with 0x01 after processing a byte?
📖 Explanation: If the addition of the complemented byte and the previous carry produces a new carry, the JNC instruction is not taken, and the program executes MVI B, 01 H, setting B to 0x01 for the next iteration. This propagates the carry across multi‑byte numbers. The other options do not trigger this specific behavior, highlighting the importance of carry handling in multi‑byte arithmetic.
Q15. In an interrupt‑driven system, why is it advantageous to keep the ISR (Interrupt Service Routine) short, as exemplified by this byte‑wise complement program?
📖 Explanation: Short ISRs finish quickly, decreasing the time between the interrupt request and the processor's return to normal execution, which is known as interrupt latency. While stack usage and register saving are considerations, the primary benefit in real‑time systems is lower latency, ensuring timely response to subsequent interrupts. Memory fragmentation is unrelated to ISR length.
Q16. If the program is modified to process N bytes where N can be up to 0xFF, which register must be used to hold the count to avoid overflow?
📖 Explanation: Register C is an 8‑bit register capable of holding values up to 0xFF, matching the maximum possible byte count. Using B (also 8‑bit) would work similarly, but the program already designates C for the counter, keeping the logic clear. D and H are part of address registers and not suitable for a simple count. Selecting the correct register prevents overflow errors in larger data transfers.
Q17. What would be the effect of removing the JNC NXT instruction and always loading B with 0x01?
📖 Explanation: If B is always set to 0x01, the program assumes a carry from the previous byte regardless of actual arithmetic results, leading to incorrect 2's complement values for bytes that did not generate a carry. This does not cause infinite loops (option D) nor does it prevent carry propagation (option B). The result is systematic error in multi‑byte conversion, demonstrating why conditional carry handling is essential.
Q18. Which of the following statements correctly explains why the program uses both CMA and ADI 01 H instead of a single instruction?
📖 Explanation: The 8085 instruction set does not provide a dedicated two's complement operation; therefore, the program must first obtain the 1's complement with CMA and then add 1 using ADI 01 H to achieve the two's complement. ADI does not clear the accumulator, and CMA does not affect the carry flag, so options B, C, and D are incorrect. This two‑step process reflects common low‑level techniques for signed arithmetic.
Q19. In a scenario where the input data represents a signed 16‑bit integer, how many bytes must the program process to correctly compute its two's complement?
📖 Explanation: A signed 16‑bit integer occupies two bytes (least significant at the lower address). The program must therefore process exactly two bytes to compute the full two's complement, handling carries between them. Processing more or fewer bytes would either miss part of the value or introduce extraneous data.
Q20. If the source memory at 2101 H contains the sequence 0x34, 0x12 and N = 0x02, what values will be stored at 2201 H and 2202 H after execution?
📖 Explanation: First byte 0x34: CMA → 0xCB, ADI 01 H → 0xCC (no carry, B = 0). Second byte 0x12: CMA → 0xED, add B (0) → 0xED, no carry, so stored value is 0xED. Thus the stored bytes are 0xCC and 0xED. Option B matches this result. The other options either miscalculate the second byte or add an extra carry.
Q21. Why is it important for the interrupt service routine to preserve registers like B that hold carry information?
📖 Explanation: Register B is used to carry over the overflow from one byte to the next during multi‑byte two's complement calculation. If the ISR does not preserve B, the carry information would be lost, leading to incorrect results for subsequent bytes. While preserving registers also prevents data loss for the main program (option A), the specific reason here is maintaining arithmetic correctness across bytes.
Q22. Which of the following best describes the overall function of the presented program?
📖 Explanation: The program reads N bytes, computes the 1's complement with CMA, adds 1, and propagates carries across bytes, which together produce the two's complement of the original multi‑byte number. It does not rearrange byte order, compress data, or perform encryption, making option B the correct description.
Q23. If the interrupt that triggers this routine occurs while another ISR is executing, what hardware mechanism ensures correct execution order?
📖 Explanation: Interrupt controllers often include a priority encoder that determines which interrupt has higher priority and should be serviced first. This mechanism allows nested interrupts to be handled in a deterministic order. DMA controllers manage data transfer, while the stack pointer and program counter are used by the CPU after an interrupt is accepted, not for prioritization.
Q24. A designer wants to modify the program to handle N up to 0xFFFF bytes using a 16‑bit counter. Which change is necessary?
📖 Explanation: Since C is only 8 bits, it can count up to 0xFF. To handle up to 0xFFFF, a 16‑bit counter is needed, which can be formed by pairing two 8‑bit registers such as B and C, allowing the program to decrement the low byte and handle underflow to the high byte. Using SP or merely resetting C would not provide a continuous 16‑bit count, and memory size is unrelated to the counter.
Q25. What is the effect of the INX D instruction in each loop iteration?
📖 Explanation: INX D increments the D‑E register pair, which points to the destination memory area beginning at 2201 H. This moves the write pointer to the next address for storing the computed two's complement byte. It does not affect the accumulator, carry flag, or input data directly.
Q26. In the context of interrupt‑driven I/O, why might a programmer choose to store intermediate results in memory rather than in registers?
📖 Explanation: When an interrupt occurs, the CPU may need to preserve the current state, including register contents. Storing intermediate results in memory ensures they remain intact across nested interrupts or context switches. Registers are faster but volatile, and while they can hold binary data, they are limited in number. Avoiding bus contention is not the primary reason for this design choice.
Q27. If the program is executed on a system where the interrupt vector for this routine is 0x38, what must be placed at address 0x38?
📖 Explanation: The interrupt vector address (0x38) holds the address of the ISR that the CPU jumps to when the interrupt occurs. Therefore, the starting address of this program must be stored at 0x38 so that the processor can locate and execute the routine. The other options do not correctly describe the role of an interrupt vector.
Q28. Which of the following statements is true about the role of the carry flag in multi‑byte two's complement computation?
📖 Explanation: During multi‑byte two's complement calculation, a carry generated from adding 1 to the 1's complement of a byte must be added to the next more significant byte. This propagation ensures the overall signed value is correctly negated. The flag is not ignored, nor is it cleared each time; it specifically handles signed arithmetic, not just unsigned overflow.
Q29. What would happen if the JNZ LOOP instruction were mistakenly replaced with JZ LOOP?
📖 Explanation: JZ jumps when the zero flag is set (i.e., when C becomes zero). Replacing JNZ with JZ would cause the program to jump back to LOOP only when C equals zero, leading to an immediate repeat after the counter reaches zero and potentially creating an infinite loop or skipping further processing. The correct behavior is to continue looping while C ≠ 0, which JNZ provides.
Q30. In an interrupt‑driven design, which hardware feature allows the CPU to resume the main program after the ISR completes?
📖 Explanation: When an interrupt is serviced, the CPU automatically pushes the current Program Counter onto the stack. After the ISR executes a RET (return) instruction, the PC is popped from the stack, allowing the CPU to resume execution of the main program at the point of interruption. This mechanism is essential for seamless context switching.
Q31. Why is the MOV C,M instruction used immediately after loading H‑L with 2100 H?
📖 Explanation: The instruction MOV C,M copies the byte located at the memory address pointed to by H‑L (which holds 2100 H) into register C. Since the memory location 2100 H contains the number of bytes N to process, this step initializes the loop counter. It does not load data bytes or affect the carry flag.