📝 Memory Mapped I/O in 8085 Microprocessor (12 MCQs)
Shared Memory Address Space for Input and Output Devices
Memory-mapped input/output assigns ordinary sixteen-bit memory addresses to peripheral registers connected to the 8085. The processor accesses these devices as if they were memory locations, using its normal memory read and write operations. This method allows peripheral data to be transferred through the accumulator and general-purpose registers, providing access to devices through the processor's 64 KB address space.
Address Decoding and Peripheral Register Selection
Each mapped peripheral receives a designated address range selected by external decoding circuitry. The address bus identifies the device or internal register, while IO/M remains low to indicate a memory operation. The RD and WR signals control reading and writing, respectively. Appropriate address decoding prevents an unintended memory chip or peripheral from responding to the same operation.
Memory Read and Write Operations for Mapped Devices
During a read operation, the processor presents the assigned address and activates RD low. The selected peripheral places its data on the data bus. During writing, the processor supplies the data and activates WR low. Ordinary memory instructions can access these peripheral registers because the processor treats their addresses as memory locations.
Example of Accessing a Memory-Mapped Output Register
Assume an output interface is assigned address 8000H. Executing MVI A,5AH followed by STA 8000H places 5AH in the accumulator and writes it to the peripheral register. The address decoder selects the interface, and WR activates the transfer. This demonstrates peripheral control using an ordinary memory-store instruction.
Advantages and Limitations of Memory-Mapped Interfacing
Memory-mapped I/O allows arithmetic, logical and data-transfer instructions to operate on peripheral registers. It also supports a larger range of device addresses than the eight-bit isolated I/O scheme. However, mapped peripheral addresses occupy part of the available memory address space, reducing the range available for ordinary RAM and ROM.
Misconceptions About Memory-Mapped Peripheral Access
'Memory-mapped I/O requires IN and OUT instructions' is incorrect because ordinary memory instructions are used. 'Every peripheral receives a separate I/O address' overlooks its allocation within memory space. 'IO/M is high during memory-mapped access' is incorrect because low identifies a memory operation.
Address Decoding and Memory-Mapped I/O Examination Questions
Identify the sixteen-bit address requirement and distinguish peripheral addresses from ordinary memory addresses. Practise tracing LDA, STA and register-indirect memory operations. Interpret the address decoder, IO/M, RD and WR signals, and calculate how an assigned peripheral address range affects the memory space available for RAM and ROM.
Memory-Mapped Interfacing and Addressing Terms
- Memory-Mapped I/O - Assigns memory addresses to peripherals.
- Address Decoder - Selects a peripheral using address bits.
- Peripheral Register - Holds device input or output data.
- RD - Controls memory-mapped reading.
- WR - Controls memory-mapped writing.
- IO/M - Remains low during memory operations.
📝 All Memory Mapped I/O in 8085 Microprocessor MCQs
Q1. Which opcode complements the accumulator in the 8085 instruction set?
📖 Explanation: The correct answer is CMA because it directly inverts every bit of the accumulator, producing the one’s complement. DAA adjusts a binary‑coded decimal result, RLC rotates bits left, and STC simply sets the carry flag; none of these alter the accumulator contents. Understanding the specific role of CMA helps a programmer select the right instruction when implementing two’s complement logic, ensuring the correct bitwise operation is performed.
Q2. Why is the carry flag essential when forming the two’s complement of a multi‑byte number?
📖 Explanation: The carry flag must be propagated because two’s complement addition may generate a carry out of the least‑significant byte. That carry becomes the next byte’s addition input, ensuring the overall complement is correct across all bytes. Ignoring the flag would leave higher bytes unchanged, producing an incorrect result. Recognizing this behavior is crucial when extending the algorithm to larger data structures.
Q3. What purpose does register B serve in the program that computes two’s complement for N bytes?
📖 Explanation: Register B is used to hold either 01 H or 00 H, representing the carry from the previous byte’s addition. When the next byte is processed, the instruction ADD B adds this carry to the complemented value, correctly propagating the overflow. The other options describe unrelated roles: B is not a pointer, does not retain N, and does not store data bytes. This design enables accurate multi‑byte two’s complement computation.
Q4. Given N = 03 H and the three source bytes at 2101 H–2103 H are FF H, 00 H, 01 H, what will be stored at 2201 H–2203 H after the program finishes?
📖 Explanation: The program first complements FF H (11111111₂) to 00 H, adds 01 H yielding 01 H, but a carry is generated and stored in B for the next byte. The second byte 00 H is complemented to FF H, B adds the previous carry, resulting in 00 H with no new carry. The third byte 01 H becomes FE H after complement and adding zero carry. Thus the destination contains 00 H, FF H, FE H, matching option A. All other options mis‑handle the carry propagation.
Q5. To relocate the result buffer from 2201 H to 2300 H, which instruction should be altered?
📖 Explanation: The destination address is controlled by the D‑E register pair, which is initialized by the LXI D instruction. Updating that instruction to load 2300 H moves the base of the result buffer. Changing LXI H would affect the source address, not the destination. Replacing STAX D with STA would lose the indirect addressing advantage, and altering INX D would only affect subsequent increments, not the initial start address.
Q6. If the JNC NXT instruction were omitted, what consequence would most likely occur?
📖 Explanation: Without the JNC NXT test, the program would always assume no carry after each addition. When a byte generates a carry, the subsequent byte would miss the required increment of B, leading to an erroneous complement for higher‑order bytes. The other choices describe unrelated effects: omitting JNC does not change opcode legality, does not affect pointer movement, and does not forcibly clear the carry flag.
Q7. What is the role of the INX H instruction inside the processing loop?
📖 Explanation: INX H adds one to the HL register pair, which points to the current source memory location. By incrementing HL, the program fetches the next byte in the sequence for processing. The other options misinterpret the function: INX H does not affect the carry flag, does not load immediate data, and does not modify the program counter directly. This step is essential for sequentially handling multi‑byte data.
Q8. If N = 01 H and the single byte at 2101 H is 80 H, what two’s complement value will be stored at 2201 H?
📖 Explanation: The byte 80 H (10000000₂) is complemented to 7F H (01111111₂). Adding 01 H yields 80 H, and a carry is generated but discarded because there is no higher‑order byte. Therefore the stored result is 80 H, matching option C. Options involving a persistent carry are incorrect because the program terminates after the single byte, and the option 7F H ignores the required addition of 01 H.
Q9. Why does the program use DCR C followed by JNZ LOOP after processing each byte?
📖 Explanation: C holds the count of remaining bytes. DCR C reduces this count after each iteration, and JNZ LOOP branches back only while the count is non‑zero, ensuring the loop processes exactly N bytes. Clearing the accumulator or resetting the carry flag are performed by other instructions, and the destination address is advanced by INX D, not by this pair.
Q10. How does the program guarantee that the least significant byte is processed first?
📖 Explanation: The source data begins at 2101 H, and the specification states that this location contains the least significant byte. By loading HL with 2100 H and then incrementing it once (INX H), the program points to 2101 H as the first byte to complement. No swapping or hardware reordering is needed; the address layout itself enforces the correct order.
Q11. When adapting the program to compute the ten’s complement instead of two’s complement, which instruction must be altered?
📖 Explanation: Ten’s complement for a decimal digit is obtained by subtracting the digit from 9, which in binary is equivalent to adding 09 H after taking the one’s complement. Therefore the ADI 01 H instruction, responsible for converting one’s complement to two’s complement, must be changed to ADI 09 H. The other instructions either handle binary adjustments or address storage and are unrelated to the decimal complement operation.
Q12. In a memory‑mapped I/O system, why is it advantageous to place the result buffer at a different address range than the source data?
📖 Explanation: Keeping the result buffer separate ensures that as each source byte is read, the transformed byte can be written without risking overwriting bytes that have not yet been processed. This separation simplifies verification and debugging. While performance and bus considerations may matter, the primary benefit in this algorithm is data integrity, which directly supports correct two’s complement computation across multiple bytes.