🎓 BookMCQ
← Back to 8. Programmable Peripheral Interface (PPI) 8255A

📝 Programming in Mode 0 for 8255A (28 MCQs)

Basic Port Configuration Without Handshaking

Mode 0 programming configures the 8255A for simple input and output operations through Port A, Port B and Port C. Each eight-bit port and each four-bit section of Port C can be independently assigned as input or output. There are no handshaking or interrupt signals in this mode, making it suitable for straightforward peripheral connections.

Preparing the I/O Mode Control Word

The control word must have D7 equal to one and D6D5 and D2 equal to zero to select Mode 0 for both groups. D4 determines Port A direction, D3 upper Port C direction, D1 Port B direction and D0 lower Port C direction. One selects input, while zero selects output.

Initializing the 8255A Through the Control Register

The processor loads the required control word into the accumulator and transfers it to the 8255A control-register address using OUT. Once configured, individual port addresses can be accessed independently. IN reads data from an input port into A, while OUT transfers accumulator contents to an output port.

Example Program for Port A Output and Port B Input

Assume Port A is at 80H, Port B at 81H and the control register at 83H. Execute MVI A,83H; OUT 83H; MVI A,55H; OUT 80H; IN 81H; STA 2050H; HLT. This configures Port A as output and Port B as input, with both Port C sections configured as inputs.

Applications of Simple Input and Output Configuration

Mode 0 is suitable for connecting LEDs, switches, simple displays and digital signal sources. Independent direction selection allows input and output functions to coexist across different ports. Because the data does not use hardware handshaking, software must ensure that external devices provide or receive valid information when the processor performs each transfer.

Misconceptions About Mode 0 Programming

'Mode 0 automatically generates interrupt requests' is incorrect because it has no handshake interrupt facility. 'Input data is stored in the 8255A input latch' is incorrect because Mode 0 inputs are not latched. 'All three ports must have the same direction' is incorrect because their directions are independently programmable.

Control Word Calculation and Port Programming Questions

Practise constructing Mode 0 control words by examining D4, D3, D1 and D0. Trace accumulator contents during IN and OUT operations and identify the selected port addresses. Questions may involve configuring mixed input/output directions, interpreting binary control words or determining the result of a short assembly-language program.

Mode 0 Programming and Port-Access Terms

  • Mode 0 - Provides simple I/O without handshaking.
  • Control Word - Defines port directions.
  • IN - Reads port data into A.
  • OUT - Sends accumulator data to a port.
  • Input Port - Receives external digital data.
  • Output Port - Supplies data to external devices.
7
Easy
12
Medium
9
Hard

📝 All Programming in Mode 0 for 8255A MCQs

Q1. What does the CMA instruction do in an 8085 assembly program?

A.Store accumulator to memory
B.Complement the contents of the accumulator ✅
C.Copy accumulator to register B
D.Add immediate value to accumulator
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The CMA instruction stands for Complement Accumulator. It flips each bit of the accumulator, turning 0s into 1s and vice‑versa, which is exactly how a 1's complement is produced. Option B describes this behavior, so it is correct. Option A describes a store operation, which is performed by STA, not CMA. Option C suggests copying to register B, which would use MOV, and Option D implies addition, which uses ADI. Understanding the specific role of each mnemonic helps you choose the right instruction when manipulating data in real‑world embedded systems.

Q2. Which mnemonic loads a byte from a specific memory address into the accumulator?

A.STA
B.LDA ✅
C.LDI
D.LDAX
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The LDA (Load Accumulator Direct) instruction fetches a byte from the memory address given as its operand and places it in the accumulator. This matches the description, making option B correct. STA stores the accumulator to memory, not loads it. LDI is not an 8085 mnemonic; the immediate load is MVI. LDAX loads from a register pair (BC or DE) and does not use a direct address. Knowing the exact purpose of each instruction prevents mis‑coding when reading sensor values in embedded applications.

Q3. What is the size of a memory address in the 8085 microprocessor?

A.8 bits
B.12 bits
C.16 bits ✅
D.24 bits
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: The 8085 uses a 16‑bit address bus, allowing it to address up to 64 KB of memory, which corresponds to option C. An 8‑bit address would limit the range to 256 bytes, which is insufficient for typical programs. A 12‑bit address could address 4 KB, but the 8085 does not support this width. A 24‑bit address is used by larger 32‑bit processors, not by the 8‑bit 8085. Recognizing the address width is essential when planning memory maps for microcontroller‑based projects.

Q4. How does a hand assembler differ from a machine assembler in 8085 programming?

A.Hand assembler converts mnemonics to binary automatically
B.Machine assembler requires manual entry of op‑codes via a hexadecimal keypad
C.Hand assembler uses a hexadecimal keypad for op‑codes while machine assembler accepts mnemonics from an alphanumeric keyboard ✅
D.Both methods produce identical source code without any difference
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A hand assembler expects the programmer to input the hexadecimal op‑code and operand directly using a hex keypad, meaning the conversion from mnemonic to machine code is done manually. A machine assembler, on the other hand, accepts the mnemonic program and performs the translation internally, allowing entry through a regular alphanumeric keyboard. Option C captures this distinction. Option A reverses the roles, and option B misstates the requirement for manual op‑code entry. Understanding these workflows helps engineers choose the appropriate tool for rapid development versus low‑level control.

Q5. Why might a programmer prefer assembly language over a high‑level language for 8085 development?

A.Because assembly runs slower, giving more time for debugging
B.Because it provides direct control over registers and flags ✅
C.Because high‑level languages cannot be compiled for 8085
D.Because assembly eliminates the need for any documentation
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Assembly language allows the programmer to manipulate registers, flags, and memory locations directly, which is essential when precise timing or hardware control is required. Option B reflects this advantage. Option A is incorrect; slower execution is a drawback, not a benefit. Option C is false because high‑level languages can be compiled for the 8085 with appropriate compilers. Option D misrepresents assembly’s role; documentation is still important. Direct control is often needed in embedded systems such as motor controllers or communication interfaces.

Q6. What is the primary purpose of Mode 0 programming in the 8085 microprocessor?

A.To execute binary data as instructions ✅
B.To provide a graphical user interface
C.To enable multitasking between processes
D.To increase the clock speed of the CPU
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Mode 0 allows the 8085 to treat incoming binary data on the data bus as executable instructions, which is useful for loading small programs or test routines directly from external devices. This matches option A. The other options describe features unrelated to Mode 0: a GUI is beyond the 8085’s capabilities, multitasking requires an operating system, and the clock speed is fixed by the hardware. Recognizing Mode 0’s role helps designers implement boot‑strap loaders or diagnostic checks in real hardware.

Q7. What role does the accumulator play in most 8085 arithmetic operations?

A.It stores the address of the next instruction
B.It holds one of the operands and receives the result ✅
C.It controls the clock frequency of the CPU
D.It acts as a secondary program counter
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: In 8085 arithmetic instructions such as ADD, SUB, INR, and DCR, the accumulator contains one operand and is updated with the result of the operation, making option B correct. It does not store instruction addresses (that is the program counter), nor does it influence clock speed or serve as a secondary PC. Knowing the accumulator’s central role is crucial when designing routines that perform calculations on sensor data or control algorithms.

Q8. How does immediate addressing differ from direct addressing in 8085 assembly?

A.Immediate uses a register pair, direct uses a constant value
B.Immediate embeds the data byte in the instruction, direct specifies a memory address ✅
C.Both use the same opcode format
D.Immediate requires two bytes, direct only one byte
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Immediate addressing includes the actual data byte within the instruction itself (e.g., MVI A, 5H), whereas direct addressing provides a memory address from which the data is fetched (e.g., LDA 3000H). Option B captures this distinction. Option A swaps the concepts, and option C is false because the formats differ. Option D misstates the byte count; immediate typically uses two bytes (opcode + data), while direct uses three (opcode + 16‑bit address). Understanding these modes aids programmers in choosing the most efficient form for a given task.

Q9. After executing an LDA 2500H instruction, how does the program counter change?

A.It increments by 1 byte
B.It increments by 2 bytes
C.It increments by 3 bytes ✅
D.It remains unchanged
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: LDA is a three‑byte instruction: one byte for the opcode and two bytes for the 16‑bit address. Therefore, the program counter advances by three bytes, making option C correct. Incrementing by only one or two bytes would correspond to single‑byte or two‑byte instructions, respectively, which is not the case here. The program counter never stays static during execution; it always moves to the next instruction address. This behavior is vital for ensuring sequential flow in real‑world firmware loops.

Q10. Why are labels useful in an 8085 source program?

A.They increase execution speed
B.They provide human‑readable names for addresses ✅
C.They automatically generate machine code
D.They replace the need for registers
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Labels allow the programmer to assign meaningful names to memory locations or instruction addresses, making the code easier to read and maintain; this matches option B. They do not directly affect execution speed, nor do they generate machine code themselves—assembly tools handle translation. Labels also do not replace registers, which are needed for data manipulation. Clear labeling is especially important in larger projects such as automotive control units where code clarity reduces debugging time.

Q11. How can instruction timing affect I/O operations on the 8085?

A.Faster timing always improves I/O reliability
B.Longer instruction cycles can cause missed peripheral signals ✅
C.Timing has no impact on I/O because the CPU and peripherals are independent
D.Only NOP instructions influence I/O timing
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Each 8085 instruction consumes a specific number of machine cycles, and peripherals often expect data within precise timing windows. If an instruction takes longer than the peripheral’s required response time, the CPU may miss or delay the signal, leading to errors—hence option B is correct. Faster timing does not guarantee reliability; it must match the peripheral’s specifications. NOP does affect timing (it consumes cycles) but is not the sole influencer. Recognizing timing constraints is essential when designing real‑time interfaces like UART or keypad scanners.

Q12. Why is the 1's complement result typically stored at the next memory location (e.g., 2501H) after the original data at 2500H?

A.To keep related data contiguous for easy access ✅
B.Because the accumulator cannot hold the result
C.To avoid overwriting the original value
D.Because the 8085 requires a jump after each operation
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Storing the complement at the next address maintains a logical grouping of the original byte and its processed result, facilitating sequential reads or further calculations—option A explains this. Overwriting the original would lose the input data, which is undesirable in many algorithms. The accumulator can hold the result temporarily, so option B is incorrect. No mandatory jump is needed after a simple complement operation, making option D false. Keeping related data together simplifies debugging and memory‑map design in embedded systems.

Q13. Which sequence correctly increments the byte stored at memory location 3000H by 1 and stores the result back at the same location?

A.LDA 3000H; INR A; STA 3000H ✅
B.INR 3000H; LDA 3000H; STA 3000H
C.STA 3000H; INR A; LDA 3000H
D.LDA 3000H; STA 3000H; INR A
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The proper order is to load the byte (LDA 3000H), increment the accumulator (INR A), and then store the updated value back (STA 3000H). This matches option A. Option B attempts to increment before loading, which is illegal because INR cannot operate directly on a memory address. Option C stores before loading, leaving the accumulator unchanged. Option D increments after storing, meaning the stored value never changes. Using the correct sequence ensures a reliable increment operation in real‑world applications such as counter registers.

Q14. If the accumulator contains 0x3C and the CMA instruction is executed, what value will be in the accumulator?

A.195 ✅
B.196
C.59
D.0
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: CMA complements each bit of the accumulator. The binary of 0x3C is 00111100; complementing yields 11000011, which is 0xC3 in hexadecimal. Therefore option A is correct. Option B (0xC4) differs by one bit, option C (0x3B) is the two's complement, and option D (0x00) would only occur if the accumulator were already zero. Knowing how bitwise operations transform data is vital when implementing error‑checking or data‑encoding schemes in embedded firmware.

Q15. Which opcode correctly stores the accumulator's content into memory address 4000H?

A.LDA 4000H
B.STA 4000H ✅
C.INR A
D.CMA
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: STA (Store Accumulator) writes the current accumulator value to the specified direct address, so STA 4000H is the correct opcode—option B. LDA loads from memory, not stores. INR increments the accumulator, and CMA complements it; neither perform a store operation. Selecting the appropriate store instruction is crucial when saving computed results, such as sensor readings, to non‑volatile memory.

Q16. How can you copy the byte at memory location 2500H to location 2501H using 8085 instructions?

A.LDA 2500H; STA 2501H ✅
B.MOV A,2500H; MOV 2501H,A
C.LDAX B; STAX B
D.INX H; MOV M,A
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: The LDA instruction loads the byte from 2500H into the accumulator, and STA then stores the accumulator's content at 2501H, which accomplishes the copy—option A. MOV cannot directly reference memory addresses without using register indirect modes, making option B invalid. LDAX and STAX operate on register pairs, not arbitrary addresses. INX H changes the HL pair but does not move data. Understanding these basic data‑transfer patterns is essential for tasks like buffering or duplicating configuration bytes.

Q17. Given the following code, what will be the value stored at memory location 3100H after execution?\nLDA 3000H\nCMA\nSTA 3100H\nIf memory 3000H initially contains 0xAA, what is at 3100H?

A.85 ✅
B.170
C.0
D.255
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: 0xAA in binary is 10101010; applying CMA flips each bit, yielding 01010101, which is 0x55. The STA instruction then stores this result at 3100H, so option A is correct. Option B would be the unchanged original value, option C (0x00) would require clearing the accumulator before storing, and option D (0xFF) would be the complement of 0x00. This illustrates how bitwise complement operations transform data, a common step in checksum or encoding algorithms.

Q18. How many machine cycles does the sequence LDA 2000H; CMA; STA 2001H consume on an 8085?

A.7 cycles
B.9 cycles
C.11 cycles ✅
D.13 cycles
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: LDA is a 3‑cycle instruction, CMA takes 1 cycle, and STA requires 3 cycles, totaling 7 + 1 + 3 = 11 cycles. Hence option C is correct. Option A underestimates by omitting the STA cycles, option B assumes a 2‑cycle LDA, and option D over‑counts by adding extra cycles. Accurately estimating cycle counts is essential when designing time‑critical routines such as motor‑control PWM generation.

Q19. Which instruction should be used to add the immediate value 0x05 to the accumulator?

A.ADI 05H ✅
B.ADD 05H
C.INR A
D.CMA
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: ADI (Add Immediate) adds the specified 8‑bit constant directly to the accumulator, making ADI 05H the correct choice—option A. The ADD instruction requires a register operand, not an immediate constant. INR increments by one, not by an arbitrary value, and CMA performs a complement, not addition. Selecting the proper immediate‑add instruction is vital for implementing constant offsets in calculations such as temperature calibration.

Q20. If a programmer mistakenly uses the register pair HL instead of DE for a memory reference in a loop, what is the most likely consequence?

A.The loop will execute twice as fast
B.The program will access the wrong memory region ✅
C.The accumulator will overflow
D.The processor will halt immediately
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: Register pairs define which memory area is accessed by indirect instructions (e.g., MOV M, A). Using HL instead of DE changes the base address, causing the program to read or write unintended locations—option B. Execution speed (option A) is unaffected by the choice of register pair. Overflow (option C) depends on data values, not address registers. The 8085 does not halt due to a wrong register pair; it simply accesses the wrong address, potentially corrupting data.

Q21. Which addressing mode is most appropriate for implementing a countdown loop that decrements a counter stored at memory location 5000H?

A.Direct addressing with LDA and STA each iteration
B.Immediate addressing with MVI each iteration
C.Register indirect addressing using HL pair ✅
D.Stack pointer relative addressing
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: A countdown loop benefits from register‑indirect addressing: load HL with the address 5000H, then use DCR M to decrement the memory byte directly, avoiding repeated LDA/STA cycles. This matches option C. Direct addressing would require extra load/store steps each iteration, making it less efficient. Immediate addressing cannot modify memory without a register. Stack‑pointer relative mode is not suited for arbitrary memory locations. Choosing the right mode reduces cycle count and simplifies loop logic in real‑time countdown timers.

Q22. Write a short program to compute the two's complement of the byte at 2600H and store the result at 2601H. Which of the following sequences is correct?

A.LDA 2600H; CMA; INR A; STA 2601H ✅
B.LDA 2600H; INR A; CMA; STA 2601H
C.LDA 2600H; CMA; STA 2601H; INR A
D.LDA 2600H; STA 2601H; CMA; INR A
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: Two's complement is obtained by complementing the bits (CMA) and then adding one (INR A). The correct order is LDA 2600H → CMA → INR A → STA 2601H, which is option A. Option B adds one before complementing, yielding the one's complement of (value + 1). Option C stores before incrementing, leaving the stored value unchanged. Option D stores before complementing, resulting in an incorrect value. Knowing the precise sequence is critical when implementing signed arithmetic in microcontroller firmware.

Q23. A programmer wants to minimize execution time for the routine that computes the two's complement of a byte at 2600H and stores it at 2601H. Which optimization yields the greatest cycle reduction?

A.Replace CMA and INR with a single instruction that directly computes two's complement ✅
B.Use immediate addressing instead of direct addressing
C.Swap the order of LDA and STA
D.Add a NOP after each instruction
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The 8085 does not have a single instruction that directly computes two's complement; however, using the instruction DCR M on the memory location itself (after loading HL) can replace both CMA and INR, cutting several cycles. This conceptual optimization (option A) provides the biggest reduction. Immediate addressing (option B) would not help because the operand is stored in memory. Swapping LDA and STA (option C) would produce incorrect results, and inserting NOPs (option D) only adds cycles. Efficient cycle management is essential for high‑speed control loops.

Q24. Consider a nested loop where the inner loop runs 5 times and the outer loop runs 4 times, each iteration executing a 3‑cycle instruction. How many total machine cycles are consumed by the nested loops?

A.15 cycles
B.45 cycles
C.60 cycles ✅
D.75 cycles
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: The inner loop executes 5 × 3 = 15 cycles per outer‑loop iteration. The outer loop runs 4 times, so total cycles are 4 × 15 = 60 cycles, which corresponds to option C. Option A counts only one iteration, option B mistakenly multiplies 5 × 4 × 3 = 60 but presents as 45, and option D adds an extra factor. Accurate cycle counting is vital when designing time‑critical nested loops, such as those used in signal‑processing filters on the 8085.

Q25. If a program uses JNZ to exit a loop but the zero flag is never set, what will happen?

A.The loop will execute exactly once
B.The program will enter an infinite loop ✅
C.The processor will generate an interrupt
D.The loop will be skipped entirely
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: JNZ (Jump if Not Zero) branches when the zero flag is clear. If the flag never becomes set, the condition for exiting the loop is never met, causing the program to repeatedly jump back—an infinite loop, option B. Executing only once (option A) would require the flag to be set after the first iteration. The 8085 does not automatically generate interrupts for this condition, and the loop is not skipped (option D). Recognizing jump‑condition logic prevents runaway code in embedded systems.

Q26. A student writes the following code to store the complement of a byte:\nLDA 2700H\nCMA\nSTA 2700H\nWhy does the original data get overwritten?

A.Because STA writes to the same address as LDA ✅
B.Because CMA modifies the address register
C.Because the accumulator is cleared before STA
D.Because the program counter points to the wrong location
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: After LDA loads the original byte into the accumulator, CMA complements it, and STA stores the result back to the same address (2700H). Therefore the original data is overwritten—option A. CMA does not affect addresses, and the accumulator is not cleared before STA; it holds the complemented value. The program counter proceeds sequentially, so option D is irrelevant. Understanding the flow of load‑modify‑store sequences prevents accidental data loss in firmware that must preserve original values.

Q27. When choosing between hand assembler and machine assembler for a large 8085 project, which factor most strongly favors the machine assembler?

A.The need to manually calculate op‑codes
B.The desire for faster code entry using an alphanumeric keyboard ✅
C.The requirement to avoid using any mnemonics
D.The necessity to work with only hexadecimal keypads
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: Machine assemblers translate mnemonic source code automatically, allowing programmers to type instructions directly on an alphanumeric keyboard, which speeds up development for large programs—option B. Hand assemblers demand manual calculation and entry of op‑codes, slowing progress. Options C and D misrepresent the capabilities: mnemonics are essential for readability, and hexadecimal keypads are not exclusive to hand assembly. Selecting the appropriate assembler impacts productivity and error rates in complex embedded projects.

Q28. What is the likely outcome if the accumulator is not cleared before executing CMA on an unknown memory value?

A.The result will always be 0xFF
B.The complement will be applied to whatever random data is present, possibly leading to unpredictable results ✅
C.CMA will automatically clear the accumulator first
D.The processor will raise an exception
💡 Difficulty: hard | ✅ Correct: B

📖 Explanation: CMA complements the current contents of the accumulator regardless of its prior state. If the accumulator holds an unknown or stale value, the complement operation yields a result that may be unrelated to the intended data, producing unpredictable behavior—option B. CMA does not clear the accumulator (option C), nor does it guarantee a constant result (option A). The 8085 does not generate exceptions for such logical operations, making option D incorrect. Properly initializing registers is a key practice in reliable embedded software.

🔗 Related Topics (MCQs)