π Programmed I/O Data Transfer in 8085 Microprocessor (10 MCQs)
CPU-Controlled Input and Output Operations
Programmed I/O is a data-transfer method in which the 8085 controls peripheral communication through executed instructions. The processor checks the device's status, determines whether it is ready and performs the transfer using IN or OUT. The CPU remains responsible for controlling each operation, making this method straightforward but potentially time-consuming when peripheral devices operate more slowly than the processor.
Status Register and Peripheral Readiness Checking
An interfaced device may provide a status register indicating whether data is available for reading or whether it can accept output. The processor accesses this register through a designated port or memory address. Logical instructions such as ANI examine selected status bits, while conditional jumps determine whether the processor should continue waiting or transfer information.
Polling Loop and Instruction-Based Data Transfer
The processor repeatedly executes a polling sequence until the required status condition is detected. For input, it then executes IN to read the data into the accumulator. For output, it checks whether the device can accept data before executing OUT. This sequence prevents transfers from occurring before the peripheral is ready.
Example of Polling an Input Device
Assume port 80H contains a status byte whose bit 0 becomes one when input data is ready, and port 81H supplies that data. Execute WAIT: IN 80H, ANI 01H, JZ WAIT, IN 81H, STA 2050H. The processor repeatedly checks readiness before storing the received byte.
Advantages and Limitations of Continuous Polling
Programmed I/O requires relatively simple interfacing because the processor directly controls the status checks and data transfers. It is suitable for simple devices and applications with limited transfer requirements. However, continuous polling consumes processor time and prevents other program work during prolonged waiting periods, making interrupt-driven transfer preferable for many event-oriented applications.
Misconceptions About Programmed I/O
'Polling transfers data without processor involvement' is incorrect because the CPU executes every checking and transfer instruction. 'IN automatically waits until a device is ready' overlooks the need for a separate readiness check. 'ANI 01H changes the original memory status register' is incorrect because it modifies the accumulator copy.
Polling Logic and Peripheral-Readiness Examination Questions
Trace the status-checking loop and determine when JZ repeats or exits. Identify the roles of the status port, data port, accumulator and logical mask. Examination questions may require writing a polling program, interpreting individual status bits or comparing programmed I/O with interrupt-driven and DMA transfer.
Polling and Programmed Transfer Terminology
- Polling - Repeatedly checks peripheral readiness.
- Status Register - Reports the device operating condition.
- ANI - Masks accumulator bits using immediate data.
- IN - Reads an input port.
- OUT - Writes to an output port.
- Busy Waiting - Consumes CPU time while checking readiness.
π All Programmed I/O Data Transfer in 8085 Microprocessor MCQs
Q1. A microcontroller stores N = 03h at address 2100h and the three bytes 12h, 34h, 56h at addresses 2101hβ2103h (least significant first). After executing the 8085 program, which value will be stored at address 2202h?
π Explanation: The program first loads N (03h) and processes the LSB at 2101h. Complementing 12h gives EDh; adding 01h yields EEh with no carry, so B becomes 00h. The next byte 34h is complemented to CBh and B (00h) is added, leaving CBh unchanged, which is stored at 2202h. Hence 0xCB is the correct result, while the other choices either ignore the complement step or misβhandle the carry.
Q2. Given N = 02h stored at 2100h and bytes FFh and 01h at 2101hβ2102h (LSB first), what value will appear at 2201h after the program runs?
π Explanation: The first byte FFh is complemented to 00h, then ADI 01h produces 01h with no carry, so B is set to 00h. This result (01h) is stored at 2201h. Because there is no carry, the second byte 01h is merely complemented to FEh and B (00h) is added, yielding FEh, which is stored at 2202h. Thus 0x01 is the correct answer for the first destination location; the other options either miss the addition of 01h or misinterpret the carry.
Q3. For N = 03h with bytes 00h, FFh, FFh at 2101hβ2103h (LSB first), what value will be stored at 2203h after execution?
π Explanation: Processing the first byte 00h: CMA yields FFh, ADI 01h produces 100h, so the accumulator wraps to 00h and sets the carry flag. The program stores 00h and sets B to 01h. The second byte FFh is complemented to 00h; adding B (01h) gives 01h with no new carry, so B becomes 00h and 01h is stored. The third byte FFh is complemented to 00h, B (00h) added yields 00h, which is stored at 2203h. Therefore 0x00 is correct; other options ignore the initial carry propagation.
Q4. If the memory location 2100h contains 00h (meaning N = 0), what will the program do?
π Explanation: When N is zero, the program loads C with 00h and immediately proceeds to the loop where it decrements C (DCR C) resulting in FFh, which is nonβzero. The subsequent JNZ LOOP therefore branches back to the start of the loop, causing the program to repeat indefinitely. No HLT instruction is reached, so the program never terminates. The other answers incorrectly assume termination or processing of data.
Q5. To store the result beginning at address 2300h instead of 2201h, which instruction should be modified?
π Explanation: The destination address is set by the DE register pair, which is initialized with the instruction LXI D, 2201h. To redirect the output to 2300h, only this instruction needs to be altered to LXI D, 2300h. Changing LXI H would affect the source address, MOV C, M already uses the correct source, and STAX D automatically stores to the address held in DE, so those options would not achieve the required relocation.
Q6. What is the primary purpose of the CMA instruction in the 2's complement routine?
π Explanation: CMA stands for Complement Accumulator; it flips each bit of the accumulator, producing the 1's complement of the original byte. This step is essential before adding 1 (via ADI 01h) to obtain the 2's complement. The other options describe different operations: adding 1 is performed by ADI, storing uses STAX, and rotation is achieved with RLC/RRC instructions.
Q7. Why does the program use register B to hold a value after testing the carry flag?
π Explanation: After each addition, the program checks the carry flag with JNC. If a carry occurred, it loads B with 01h; otherwise, B receives 00h. This value is then added to the next byte (ADD B), effectively propagating the carry from the previous byteβs 2's complement calculation. The other choices misinterpret Bβs role: it is not a constant, not a complement result, and loop counting is handled by C.
Q8. If the instruction ADI 01h were replaced by ADI 00h, how would the programβs output change?
π Explanation: Removing the addition of 01h means the program only performs the CMA step, which yields the 1's complement of each source byte. Consequently, no extra 1 is added, so the results are not true 2's complements, and the carry handling for multiβbyte numbers is also altered. The other options are incorrect because the instruction is valid, the output changes, and the carry flag behavior depends on the actual addition.
Q9. Why does the program execute INX H and INX D after each iteration?
π Explanation: INX H increments the HL pair, moving the source pointer to the next byte in the input sequence, while INX D increments the DE pair, moving the destination pointer to the next location where the result will be stored. This ensures that each byte is processed sequentially. The loop counter is held in C, not in HL or DE, and the flags are unaffected by these increments.
Q10. Where is the count of bytes N stored for the program to read?
π Explanation: The program begins with LXI H,2100h and then uses MOV C,M to load the value at the address pointed to by HL into register C. Since HL was set to 2100h, the byte at 2100h holds the number of bytes N that the routine will process. The other addresses are used for the data bytes (2101h onward) or the result storage (2201h onward).