📝 Simple Programs in 8085 Microprocessor (47 MCQs)
Fundamental Structure of 8085 Assembly Programs
Simple 8085 programs demonstrate how the processor performs calculations, transfers information, compares values and manipulates memory through assembly-language instructions. Each program consists of mnemonics, operands and memory addresses arranged in a logical sequence. The program counter fetches instructions, the instruction decoder interprets them and the ALU performs required operations. Results are retained in registers or stored in external memory.
Register Selection and Memory-Based Operand Handling
The accumulator is the principal working register for arithmetic and logical operations. General-purpose registers B, C, D, E, H and L temporarily store operands, while HL frequently identifies memory locations. Instructions such as MVI, MOV, LDA and STA initialize registers, transfer data and access memory.
Instruction Sequencing and Program Execution
A program begins at a defined memory address, and the program counter identifies each successive instruction. The processor fetches and decodes instructions before executing them. Conditional jumps modify the normal sequence according to flags, while HLT stops execution. Memory addresses and register contents determine the actual results.
Example Program for Adding Two Eight-Bit Numbers
Assume memory locations 2050H and 2051H contain 25H and 15H. Execute LDA 2050H, MOV B,A, LDA 2051H, ADD B and STA 2052H. The accumulator receives 3AH, which is stored at 2052H. The carry flag indicates any overflow beyond eight bits.
Applications of Basic Programs in Microprocessor Systems
Simple assembly programs support calculations, data conversion, searching, sorting and communication with peripheral devices. Repeated instructions implement loops, while comparison and branching provide decision-making. These programming techniques combine the instruction set, register organization, addressing modes and memory operations into practical solutions for computational tasks.
Common Programming Errors in 8085 Assembly
'Every arithmetic result is automatically stored in memory' is incorrect because the accumulator normally receives the result. 'MOV A,B removes the original value from B' confuses copying with moving. 'JNZ tests whether the accumulator is nonzero' is incorrect because it checks the zero flag generated by a previous operation.
Program Tracing and Instruction-Sequence Examination Questions
Practise tracing register contents, memory addresses and status flags after every instruction. Identify valid operands and addressing modes, calculate arithmetic results and determine final memory contents. Examination questions frequently involve writing short programs, identifying incorrect instructions and predicting the effect of conditional jumps, loops and data-transfer operations.
8085 Programming and Instruction Terminology
- Mnemonic - Symbolic instruction name.
- Operand - Data used by an instruction.
- Accumulator - Main arithmetic working register.
- Label - Identifies a program location.
- Loop - Repeats a sequence of instructions.
- HLT - Stops program execution.
📝 All Simple Programs in 8085 Microprocessor MCQs
Q1. What does the mnemonic LDA represent in 8085 assembly language?
📖 Explanation: The correct answer is \Load Accumulator Directly\ because LDA loads the contents of a specified memory address directly into the accumulator. Option B is vague and does not specify the direct nature. Option C describes loading an address, not data. Option D suggests indirect addressing, which uses different mnemonics. Understanding LDA is essential for correctly moving data in microcontroller applications such as reading sensor values.
Q2. Which component converts a high‑level language program into assembly language?
📖 Explanation: An assembler translates assembly language to machine code, but the conversion from high‑level language to assembly is done by a compiler. Therefore, option B is correct. Option A describes a tool that works at a higher level, not directly to assembly. Option C executes code line‑by‑line without translation. Option D combines object files and does not perform language translation. Knowing this helps students choose the right tool when developing firmware.
Q3. In the context of 8085 programming, what is a source program?
📖 Explanation: The source program is the human‑readable mnemonic code that the programmer writes. Option A refers to machine code, which is the output after assembly. Option C is the final executable after linking, not the original source. Option D is a memory snapshot. Recognizing the source program is vital when debugging or modifying code for embedded systems.
Q4. What is the primary advantage of using assembly language over high‑level languages for microprocessor programming?
📖 Explanation: Assembly language allows direct control over registers and instructions, leading to faster execution compared to high‑level languages. Option B is incorrect because assembly syntax is more complex. Option C is a feature of high‑level languages, not assembly. Option D is opposite; assembly is less portable. This advantage is crucial when optimizing performance‑critical tasks like real‑time motor control.
Q5. Which of the following is NOT a type of assembler for 8085?
📖 Explanation: Hand and machine assemblers are standard; hybrid assemblers combine features of both. There is no widely recognized 'Virtual assembler' for 8085, making D the correct choice. Options A, B, and C describe real tools used to translate mnemonics to machine code. Knowing assembler types aids students when selecting tools for development environments.
Q6. If a programmer wants to store the 1's complement of the byte at memory location 2500H into 2501H, which instruction sequence is correct?
📖 Explanation: The correct sequence loads the byte, complements it with CMA, and stores it, matching option A. Option B uses rotate left which changes bits differently. Option C adds unnecessary register pair loading but still works; however, it repeats steps and is less optimal. Option D uses rotate right, not complement. Understanding the correct instruction flow is essential for tasks like error‑checking data.
Q7. A student writes the following code: LDA 3000H, CMA, STA 3001H. What will be stored at 3001H if the original byte at 3000H is 0x5A?
📖 Explanation: CMA flips each bit; the complement of 0x5A (01011010) is 0xA5 (10100101). Option B is the original value, not complemented. Option C would be the result of a NOT operation on 0xFF, not applicable here. Option D implies zero, which never results from a complement operation. This demonstrates how bitwise operations affect stored data in embedded memory.
Q8. Which register pair is typically used by the LXI instruction to load a 16‑bit immediate address?
📖 Explanation: LXI loads a 16‑bit constant into a register pair; the most common usage is LXI H,addr to set HL for memory operations. Option C is correct. Options A and B are also valid for LXI, but HL is standard for address handling. Option D (SP) is a stack pointer and not loaded via LXI. Knowing the proper register pair ensures correct address manipulation in programs.
Q9. When converting assembly mnemonics to machine code manually, which numeral system is most convenient for representing op‑codes?
📖 Explanation: Hexadecimal aligns neatly with 8‑bit op‑codes (two hex digits per byte), making it the most convenient. Decimal is cumbersome for binary patterns. Binary is accurate but lengthy. Octal is less common for 8085. Mastery of hexadecimal aids in debugging and manual assembly tasks.
Q10. Why might an engineer prefer a hand assembler over a machine assembler for a small 8085 project?
📖 Explanation: Hand assemblers let the user input hexadecimal op‑codes directly, which can be quicker for tiny programs without a full development environment. Option A is unrelated to assembly method. Option C is false; hand assembly can increase syntax errors. Option D is inaccurate because a computer is still needed to operate the kit. This preference is relevant in low‑resource labs.
Q11. In an 8085 program, which instruction would you use to increment the contents of memory location 4000H by one?
📖 Explanation: INR M increments the byte at the address pointed to by the HL pair (M refers to memory). Assuming HL is set to 4000H, INR M works. INX H increments the HL pair itself, not the memory content. ADD M adds the memory content to the accumulator, not incrementing the memory directly. ADI 01H adds immediate 1 to accumulator. Correct use of INR is key for simple counter implementations.
Q12. A program needs to compare two bytes stored at 5000H and 5001H and set the zero flag if they are equal. Which instruction sequence accomplishes this?
📖 Explanation: SUB subtracts the second operand from the accumulator, setting the zero flag when the result is zero, indicating equality. CMP is not an 8085 instruction. ANI performs logical AND, not subtraction. XRA XORs the bytes, which also sets zero flag only when identical, but SUB is the standard compare method. Understanding flag effects is central to decision‑making code.
Q13. Which of the following best describes the role of the program counter (PC) in 8085?
📖 Explanation: The PC always holds the address of the next instruction to fetch, making option A correct. Option B describes the accumulator or flags. Option C is the instruction register. Option D is the stack pointer (SP). Recognizing PC behavior is crucial when designing loops and jumps.
Q14. If an 8085 program uses the instruction sequence: MVI A,0FFH, RRC, RRC, which final value will be in accumulator A?
📖 Explanation: MVI loads A with 0xFF (11111111). RRC rotates right through carry; after two rotations, bits shift right twice, resulting in 11111100 (0xFC). However, the carry bits are discarded, leaving 0xFC. Option C (0xFC) is correct. Options A and B represent different rotations, and D would be result of two RLCs. This illustrates bit‑rotation effects used in bit‑masking.
Q15. A programmer needs to create a loop that repeats ten times. Which register pair and instruction combination is most appropriate for counting iterations?
📖 Explanation: BC is commonly used for counters; DCR B decrements B, and JNZ jumps if not zero, forming a ten‑iteration loop. DE and HL can also be used, but DCR operates on 8‑bit registers; using B is conventional. SP is the stack pointer and should not be used for counting. Proper loop construction is vital for repetitive tasks like scanning inputs.
Q16. Why is it important to initialize the accumulator before performing arithmetic operations in 8085?
📖 Explanation: Initializing the accumulator guarantees that previous unknown data does not affect the outcome, providing predictable results. Option A is about flags, not accumulator content. Option C refers to PC, unrelated. Option D concerns SP. Initialization is a best practice for reliable embedded computations.
Q17. Which instruction would you use to copy the contents of register B into register C?
📖 Explanation: MOV C,B copies the value directly. XCHG swaps DE and HL, not B and C. LDAX loads accumulator from memory addressed by DE. PUSH stores B on stack. Knowing MOV is essential for data movement between registers.
Q18. In 8085 assembly, what is the effect of the CMA instruction on the accumulator?
📖 Explanation: CMA complements each bit of the accumulator (bitwise NOT). Option A describes INR. Option C is RLC. Option D would be XRA A. Understanding CMA is key for operations like generating 1's complement as in example programs.
Q19. When an 8085 program uses the instruction STA 2600H, what operation is performed?
📖 Explanation: STA stores the accumulator's content directly into the specified memory address. Option B reverses direction. Option C describes MOV M,A with HL. Option D is unrelated. This operation is common for saving computed results.
Q20. A developer wants to create a subroutine that returns control to the calling program after execution. Which instruction should terminate the subroutine?
📖 Explanation: RET pops the return address from the stack and jumps back, correctly ending a subroutine. JMP performs an unconditional jump, not returning. CALL invokes a subroutine. RST is a restart instruction. Proper subroutine termination ensures program flow continuity.
Q21. Which flag is set when the result of an addition operation exceeds 8 bits in 8085?
📖 Explanation: The Carry flag indicates overflow beyond 8 bits during addition. Zero flag indicates a zero result. Sign flag reflects the most significant bit. Parity flag indicates even number of set bits. Recognizing flag behavior is essential for arithmetic error detection.
Q22. If a program uses the instruction sequence: LXI H,3000H, MOV A,M, ANI 0F0H, what is the purpose of the ANI operation?
📖 Explanation: ANI performs a logical AND between accumulator and immediate value, effectively masking bits. Option A describes addition. Option C is a shift operation, not AND. Option D would be CMA. Masking is useful for extracting high‑order bits from a byte.
Q23. Which of the following statements about the 8085 instruction set is true?
📖 Explanation: The 8085 set contains both single‑byte (e.g., INR) and multi‑byte (e.g., LDA) instructions. Option A is false; instructions vary in length. Option C is false; there are many branch instructions like JMP, JNZ. Option D is false; arithmetic operations like ADD exist. Understanding instruction variety aids program design.
Q24. A loop needs to process an array of 20 bytes starting at address 4000H. Which register pair is best suited to hold the address pointer?
📖 Explanation: HL is conventionally used as a memory address pointer, especially with instructions like MOV A,M. DE can also hold addresses, but HL is standard for array traversal. BC is often a counter. SP is for stack operations. Selecting HL simplifies code and aligns with typical assembly patterns.
Q25. What is the result of executing the instruction DCR A when the accumulator contains 00H?
📖 Explanation: Decrementing 0x00 wraps to 0xFF, and since the result is non‑zero, the Zero flag is cleared. However, many resources state Zero flag is cleared, but the question expects the wrap behavior. Option A reflects the wrap to FFH; the Zero flag detail may vary, but the key point is wrap to FFH. This illustrates underflow handling.
Q26. In 8085, which instruction is used to compare the accumulator with a memory byte without altering the accumulator?
📖 Explanation: 8085 does not have a CMP instruction; instead, SUB M is used to perform a compare by subtracting the memory byte from the accumulator, affecting flags but not preserving the original value. Option D is the correct method. Options A, B, and C are not valid 8085 mnemonics. Understanding comparison techniques is crucial for conditional branching.
Q27. Why is it advisable to use labels instead of hard‑coded addresses in assembly programs?
📖 Explanation: Labels provide symbolic names that make code easier to read and modify; hard‑coded addresses are error‑prone. Option A is false; execution speed is unchanged. Option C is incorrect; code size remains the same. Option D is unrelated. Using labels aids debugging and future updates.
Q28. A programmer needs to store the 2's complement of a signed number located at 6000H into 6001H. Which sequence correctly accomplishes this?
📖 Explanation: To obtain 2's complement, you complement the bits (CMA) then add one (INR A). The sequence in option A does exactly that before storing. Option B rotates bits, not complementing. Option C decrements, which is not the correct method. Option D adds the accumulator to itself, doubling the value. Mastery of complement operations is vital for signed arithmetic.
Q29. If an 8085 program uses the instruction sequence: MVI A,0AAH, RLC, RLC, what will be the contents of the accumulator after execution?
📖 Explanation: MVI loads 0xAA (10101010). Two RLC operations rotate left twice, moving the two most‑significant bits to the low positions, resulting in 00101010 (0x2A). Option C is correct. Option B (0x55) would be the result of a single rotate right. Option D repeats the original. Understanding rotation is essential for bit‑manipulation algorithms.
Q30. Which flag(s) are affected by the INR instruction?
📖 Explanation: INR increments a byte and updates Zero, Sign, Parity, and Auxiliary Carry flags, but not the Carry flag. Option B correctly lists the affected flags. Option A omits Auxiliary Carry and Parity. Option C is wrong because Carry is not affected. Option D is false. Flag knowledge is critical for conditional branches after increment operations.
Q31. A system requires toggling a specific bit (bit 3) of a port at address 00H repeatedly. Which instruction sequence efficiently achieves this?
📖 Explanation: XRI performs XOR, which toggles the specified bit without affecting others. Using 0x08 (00001000) toggles bit 3. Option A uses RLC and AND, which would not toggle correctly. Option C sets the bit (OR) rather than toggling. Option D is a compare, not an output operation. Mastery of bitwise XOR is essential for hardware control.
Q32. Why might an engineer choose to implement a delay loop using nested DJNZ instructions rather than a single large loop?
📖 Explanation: Nested DJNZ loops allow the programmer to achieve long delays with smaller counter values, giving finer granularity and reducing the need for large immediate values. Option A is not a primary concern. Option C is false; more loops increase execution time. Option D is irrelevant. Understanding delay generation is vital for timing‑critical embedded designs.
Q33. In 8085 assembly, which instruction is used to transfer the contents of the accumulator to the memory location pointed by HL?
📖 Explanation: MOV M,A stores the accumulator directly into the memory address referenced by HL. Option B is not valid syntax. STAX H stores accumulator into the address pointed by DE. MOV A,M loads from memory to accumulator. Correct usage of MOV M,A is essential for direct memory writes.
Q34. A programmer wants to implement a simple password check where the correct password byte is stored at 7000H. Which sequence correctly compares input in accumulator with stored password and branches if they match?
📖 Explanation: The correct method is to load the stored password, subtract the input (already in accumulator) using SUB, then use JZ to branch if zero (match). Option D follows this logic. Option A incorrectly subtracts accumulator from itself. Option B uses non‑existent CMP. Option C branches on not zero, opposite of desired behavior. Implementing such checks is common in secure embedded systems.
Q35. What is the effect of the XRA A instruction on the accumulator and flags?
📖 Explanation: XRA A XORs the accumulator with itself, yielding 0x00. This sets the Zero flag and the Parity flag (even number of 1s) while clearing Sign, Carry, and Auxiliary Carry. Option C correctly describes this behavior. Option A omits Parity. Option B incorrectly mentions Sign. Option D describes CMA. Understanding flag effects of XRA is crucial for clearing registers efficiently.
Q36. When using the 8085 instruction DAD B to add the contents of BC to HL, which flags are affected?
📖 Explanation: DAD B adds the 16‑bit BC pair to HL and only affects the Carry flag if there is an overflow beyond 16 bits. No other flags are altered. Option B is correct. Option A is false; Zero and Sign are unchanged. Option C is incorrect; only Carry changes. Option D is wrong because Carry can be set. Knowing flag impact is vital for multi‑word arithmetic.
Q37. A program needs to copy 10 bytes from source address 8000H to destination address 9000H. Which loop structure correctly accomplishes this using LXI, MOV, and INX instructions?
📖 Explanation: The correct loop uses LDAX H to load from source, STAX D to store to destination, then increments both pointers and decrements the counter. Option D matches this pattern. Option A incorrectly uses MOV A,M and STAX D without loading via LDAX. Option B writes back to source. Option C omits INX D. Accurate pointer manipulation is essential for block memory transfers.
Q38. Why is the Carry flag cleared after executing the CMA instruction?
📖 Explanation: CMA only complements the accumulator bits; it does not modify the Carry flag, leaving it unchanged. Option A states this correctly. Option B is false; CMA does not clear Carry. Option C incorrectly claims it sets Carry. Option D suggests toggle behavior, which is not defined. Recognizing flag independence ensures accurate flag‑based logic.
Q39. In an 8085 program, which instruction would you use to test whether the accumulator is zero without altering its contents?
📖 Explanation: ANA A performs a logical AND of the accumulator with itself, leaving the value unchanged but setting flags based on the result; Zero flag is set if accumulator is zero. Option B is correct. CMP is not an 8085 instruction. ORA A also leaves the accumulator unchanged and can be used, but ANA is more conventional for zero testing. NOP does nothing. Understanding non‑destructive flag testing is important for conditional execution.
Q40. A system requires rotating a byte left through the carry flag three times. Which instruction sequence achieves this?
📖 Explanation: RLC rotates left through carry; performing it three times rotates the byte left three positions. Option A is correct. RRC rotates right, opposite direction. RAL and RAR rotate through carry but also involve the accumulator's previous carry; they are not pure rotates. Mastery of rotate instructions is essential for implementing circular shifts.
Q41. When implementing a lookup table at addresses 1000H‑100FH, which register pair should be used to index the table efficiently?
📖 Explanation: DE is often used as a base register for indexed addressing with the DAD instruction, allowing efficient table lookup. Option C (HL) could also be used but DE is preferred for this pattern. Option A (BC) is commonly a counter. SP is for stack operations. Selecting DE aligns with typical 8085 table‑lookup conventions.
Q42. Why might an engineer use the instruction XCHG in a program that manipulates two 16‑bit numbers?
📖 Explanation: XCHG exchanges the contents of DE and HL, allowing the programmer to reposition registers for subsequent operations such as addition or subtraction without moving data manually. Option B captures this purpose. Option A would require ADD. Option C would need CMP. Option D would need STA. Understanding register swapping simplifies complex arithmetic.
Q43. A programmer wants to implement a conditional branch that executes when the result of a subtraction is negative. Which flag should be tested?
📖 Explanation: The Sign flag indicates a negative result (most significant bit set) after subtraction. Option B is correct. Zero flag checks for zero result. Carry flag indicates borrow in subtraction, not directly negativity. Parity flag relates to even number of set bits. Proper flag testing enables correct branching in signed arithmetic.
Q44. In 8085, which instruction pair is used to push and later retrieve a 16‑bit register pair onto/from the stack?
📖 Explanation: PUSH D stores the DE pair onto the stack, and POP D retrieves it. Option C is correct. PUSH B works with BC, not DE. PUSH H works with HL. PUSH PSW handles accumulator and flags. Knowing stack operations is vital for subroutine calls and interrupt handling.
Q45. When using the instruction sequence: LDA 2000H, ADD A, STA 2001H, what arithmetic operation is performed on the byte at 2000H?
📖 Explanation: Loading the byte into A and then adding A to itself results in A = A + A, effectively doubling the original value. Option A is correct. Option B would require INR. Option C requires CMA and INR. Option D would need XRA A. Doubling values is common in scaling operations for embedded signal processing.
Q46. Why is it important to clear the accumulator (e.g., using XRA A) before performing a series of logical AND operations?
📖 Explanation: Clearing the accumulator ensures that the first AND operation starts with a known value (all ones after XRA A), preventing residual bits from previous computations from influencing the outcome. Option B correctly explains. Option A is unrelated. Option C is not a significant factor. Option D is unrelated to accumulator state. Proper initialization is key for reliable bitwise logic.
Q47. A firmware update requires writing a constant pattern 0xAA to 50 consecutive memory locations starting at 3000H. Which loop construct efficiently accomplishes this?
📖 Explanation: Option B sets a counter of 50 (0x32) and uses MVI A,AAH to load the pattern, then STAX H to store it at the address pointed by HL, incrementing HL each iteration. Option A incorrectly uses 32 as counter. Option C misuses MOV A,B and stores at fixed address. Option D repeats the same error. Efficient looping is essential for bulk memory initialization in firmware.