๐ŸŽ“ BookMCQ
โ† Back to 6. Programming of 8085

๐Ÿ“ Miscellaneous Programs in 8085 Microprocessor (18 MCQs)

Additional Data-Manipulation and Bit-Processing Programs

Miscellaneous 8085 programs demonstrate operations that do not belong exclusively to arithmetic, sorting or data-conversion routines. They include bit counting, complement generation, parity checking, data masking, byte swapping and memory manipulation. Such programs combine the accumulator, general-purpose registers, logical instructions, rotate operations and conditional branches to solve practical processing problems.

Using Rotate and Logical Instructions for Bit Analysis

RLC, RRC, RAL and RAR manipulate accumulator bits, while the carry flag records selected shifted-out bits. ANA, ORA and XRA perform bitwise operations, and CMA complements the accumulator. By combining these instructions with counters and conditional jumps, the processor can examine individual bits or modify selected portions of a byte.

Counting Binary Bits Through Repeated Rotation

A bit-counting routine initializes a counter to zero and rotates the input byte eight times. After each RRC instruction, the carry flag contains the original least significant bit. JNC skips the counter increment when that bit is zero, while INR increases the count when it is one.

Program to Count Set Bits in an Eight-Bit Number

Load the input byte from 2050H into A, initialize B to 08H and C to 00H. Execute LOOP: RRC, JNC SKIP, INR C, SKIP: DCR B, JNZ LOOP. After eight rotations, transfer C into A and store it at 2051H. For input F3H, the result is 06H because six bits are set.

Connections with Logical Processing and Status Flags

Bit manipulation routines demonstrate the use of carry as an individual-bit indicator and general-purpose registers as loop counters. Similar techniques support masking unwanted bits, checking selected conditions and preparing information for serial transfer. They strengthen the relationship between logical operations, accumulator rotation, flag evaluation and conditional program control.

Misconceptions About Bit-Manipulation Programs

'RRC shifts the accumulator without preserving its bits' is incorrect because the shifted-out bit returns to bit 7. 'JNC branches when carry is set' reverses the instruction condition. 'The bit-counting program counts zero bits' is incorrect because C increases only when the rotated-out bit is one.

Bit Counting and Logical Program-Tracing Questions

Practise converting hexadecimal bytes into binary and counting their set bits. Trace the carry flag after every RRC and determine how INR C changes the counter. Understand loop termination after eight iterations and distinguish rotate operations from logical shifts. Questions may also involve masking, complementing and testing individual bits.

Bit Manipulation and Logical Programming Terms

  • RRC - Rotates accumulator bits right circularly.
  • Carry Flag - Holds the rotated-out bit.
  • Set Bit - Binary bit containing one.
  • Bit Mask - Selects particular binary positions.
  • INR - Increments an eight-bit counter.
  • Bit Counting - Determines the number of one bits.
4
Easy
9
Medium
5
Hard

๐Ÿ“ All Miscellaneous Programs in 8085 Microprocessor MCQs

Q1. What mnemonic loads the accumulator from a memory address?

A.LDA โœ…
B.STA
C.MOV
D.ADD
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– Explanation: The correct mnemonic is LDA because it specifically loads the accumulator with the byte found at the given address. STA stores the accumulator, MOV moves data between registers, and ADD performs arithmetic, none of which load from memory. Understanding LDA is essential when writing a program that reads a value, such as retrieving sensor data stored at a known location, ensuring the correct instruction is used.

Q2. Which instruction produces the 1's complement of the accumulator?

A.CMA โœ…
B.RLC
C.RRC
D.DAA
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– Explanation: CMA stands for Complement Accumulator and flips every bit, giving the 1's complement. RLC and RRC rotate bits left or right, while DAA adjusts binary to BCD after addition. Knowing CMA is vital in tasks like inverting flags or preparing data for subtraction, where the complement operation directly yields the needed inverted byte.

Q3. Why is assembly language preferred when direct register manipulation is required?

A.It provides high level abstraction
B.It allows direct control of registers โœ…
C.It automatically optimizes code
D.It eliminates need for debugging
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– Explanation: Assembly language gives programmers explicit access to each register, enabling precise control over data flow and timing, which highโ€‘level languages abstract away. The other options describe benefits not related to register control. In realโ€‘world firmware, such as controlling motor drivers, developers need to set specific bits in control registers, making assembly the appropriate choice.

Q4. How does hand assembly differ from machine assembly regarding input method?

A.Both use alphanumeric keyboards
B.Hand assembler requires hexadecimal keypad
C.Machine assembler uses a graphical interface โœ…
D.Hand assembler automatically generates machine code
๐Ÿ’ก Difficulty: medium | โœ… Correct: C

๐Ÿ“– Explanation: Hand assembly needs the programmer to input opโ€‘codes and operands as hexadecimal values via a hex keypad, whereas machine assembly lets the programmer type mnemonic instructions directly using an alphanumeric keyboard. The other statements misrepresent the processes. This distinction matters when designing a development board: a hex keypad limits speed, while a full keyboard speeds up coding.

Q5. What role does a source program play in 8085 development?

A.It is the final executable
B.It stores only comments
C.It is the humanโ€‘readable mnemonic code
D.It contains only binary data โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: The source program is the humanโ€‘readable set of mnemonics that the assembler translates into machine code. It is not the final executable (that is the object code), nor does it consist solely of comments or binary data. In practice, engineers write and review the source to verify logic before assembling, ensuring correct microcontroller behavior.

Q6. Why store the 1's complement result at 2501H instead of overwriting the original data at 2500H?

A.To preserve the original value for later use
B.Because 2500H cannot be written to โœ…
C.To save memory space
D.Because the accumulator cannot write to 2500H
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– Explanation: Keeping the original byte untouched allows other parts of a program to reference the initial data, which is often required for verification or further calculations. Overwriting would lose that information. The other options are incorrect: both locations are writable, memory saving is not achieved by changing the address, and the accumulator can write to any address via STA.

Q7. What does a 1's complement operation achieve on a byte?

A.It adds one to the value
B.It inverts each bit
C.It multiplies the value by two โœ…
D.It shifts bits left
๐Ÿ’ก Difficulty: easy | โœ… Correct: C

๐Ÿ“– Explanation: A 1's complement flips every bit, turning 0s into 1s and vice versa, which is exactly what the CMA instruction does. Adding one yields a 2's complement, multiplication and shifting are unrelated operations. Knowing this is useful when implementing simple negation or preparing data for subtraction in lowโ€‘level firmware.

Q8. If memory location 3000H contains 5A hex, what value will be stored at 3001H after executing a program that finds the 1's complement?

A.A5
B.5A
C.55
D.A0 โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: The 1's complement of 5A (binary 01011010) is 0A5 (binary 10100101), which is A5 hex. Therefore the program stores A5 at the next address. The other options either repeat the original value or represent unrelated transformations. This demonstrates how complementing is used in errorโ€‘checking routines where the inverted byte is needed for verification.

Q9. Which sequence correctly adds two bytes stored at 4000H and 4001H and stores the result at 4002H?

A.LDA 4000H;ADD 4001H;STA 4002H โœ…
B.LDA 4000H;ADD 4002H;STA 4001H
C.LDA 4001H;ADD 4000H;STA 4002H
D.LDA 4002H;ADD 4000H;STA 4001H
๐Ÿ’ก Difficulty: hard | โœ… Correct: A

๐Ÿ“– Explanation: The correct order loads the first operand, adds the second, and stores the sum at the target address: LDA 4000H; ADD 4001H; STA 4002H. The other options either write to the wrong location or add the wrong operands. Proper sequencing is crucial in embedded systems such as calculating sensor offsets where precise memory addresses must be used.

Q10. Which register pair is best for counting addresses when copying a block of 10 bytes from 5000H to 6000H?

A.BC
B.HL โœ…
C.DE
D.SP
๐Ÿ’ก Difficulty: medium | โœ… Correct: B

๐Ÿ“– Explanation: The HL pair is commonly used for indirect memory access because many 8085 instructions (like MOV M, A) reference the address in HL. BC and DE can also be used but lack the same instruction support, and SP is the stack pointer, not intended for general data movement. Using HL simplifies loop code, making the copy operation efficient in realโ€‘time data transfer.

Q11. If the CMA instruction is omitted, what will be the content at 2501H after running the program that loads from 2500H and stores the accumulator?

A.Same as original data
B.Zero
C.FF โœ…
D.1
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

๐Ÿ“– Explanation: Without CMA, the accumulator simply holds the original byte from 2500H, and the STA stores that unchanged value at 2501H. Thus the result matches the source data. Zero, FF, and 01 would require additional operations that are not present. This scenario highlights the importance of including every required instruction when designing firmware that transforms data.

Q12. Which sequence ensures a correct BCD result when adding two packed decimal numbers using DAA?

A.ADD then DAA
B.DAA then ADD
C.ADD only
D.DAA only โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: The proper method is to perform the binary addition first (ADD) and then apply DAA to adjust the result to valid BCD. Placing DAA before ADD would adjust a nonโ€‘existent result, and using either instruction alone would not produce correct BCD. This technique is used in financial calculators where decimal accuracy is mandatory.

Q13. In machine assembler, entering 'MVI A, 0FFH' followed by 'CMA' results in what final accumulator value?

A.0
B.FF โœ…
C.1
D.FE
๐Ÿ’ก Difficulty: hard | โœ… Correct: B

๐Ÿ“– Explanation: MVI loads 0FFH into the accumulator, setting all bits to 1. CMA then complements each bit, turning 11111111 into 00000000, which is 00 hex. The other options either ignore the complement or misinterpret the bit pattern. Understanding this sequence is essential when resetting a register to zero without using a separate instruction.

Q14. Which sequence correctly tests whether a memory location contains zero using JNZ?

A.LDA addr;ORA A;JNZ label โœ…
B.LDA addr;CMA;JNZ label
C.LDA addr;ADD A;JNZ label
D.LDA addr;STA label;JNZ label
๐Ÿ’ก Difficulty: easy | โœ… Correct: A

๐Ÿ“– Explanation: Loading the byte and ORA A sets the zero flag if the value is zero; JNZ then jumps when the flag is not set. CMA would invert the bits, ADD A would double the value, and STA writes to memory, none of which correctly implement the zero test. This pattern is common in loops that process data until a terminator byte of zero appears.

Q15. Design a program that increments each byte in a 4โ€‘byte array starting at 7000H. Which loop construct is appropriate?

A.Use DCR on a counter and repeat four times
B.Use INX H to move pointer and repeat until HL reaches 7004H
C.Use RST 0 to call subroutine for each byte โœ…
D.Use JMP to infinite loop
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

๐Ÿ“– Explanation: Using RST 0 repeatedly would call the same subroutine without advancing the pointer, leading to an infinite loop. INX H with a pointer check works, but the simplest method is to set a counter with DCR and repeat exactly four times, ensuring each array element is visited and incremented. This technique is useful in firmware that updates configuration tables.

Q16. When converting a highโ€‘level loop to 8085 assembly, what is the purpose of using the DCR instruction on a counter?

A.To double the counter value
B.To decrement the counter toward zero
C.To set a flag
D.To load immediate data โœ…
๐Ÿ’ก Difficulty: medium | โœ… Correct: D

๐Ÿ“– Explanation: DCR subtracts one from a register, allowing the loop to terminate when the counter reaches zero, which is detected by the Zero flag. Doubling, setting flags, or loading data are unrelated functions. Loop counters are fundamental in embedded tasks such as iterating over sensor arrays until a condition is met.

Q17. Why is using immediate addressing for large data tables inefficient compared to using HL pair and indirect addressing?

A.Immediate addressing uses fewer cycles
B.Indirect addressing reduces code size
C.Immediate addressing requires many bytes per instruction โœ…
D.Indirect addressing cannot access memory
๐Ÿ’ก Difficulty: hard | โœ… Correct: C

๐Ÿ“– Explanation: Immediate addressing embeds the data value within each instruction, leading to a separate instruction for every table entry, which inflates code size and execution time. Indirect addressing via HL allows a single loop to fetch successive bytes, saving space and cycles. This efficiency is critical in memoryโ€‘constrained microcontroller applications.

Q18. If the accumulator contains 3CH and you execute RLC twice, what is the resulting value?

A.F0 โœ…
B.0F
C.C3
D.3C
๐Ÿ’ก Difficulty: medium | โœ… Correct: A

๐Ÿ“– Explanation: RLC rotates the accumulator left one bit, moving the highโ€‘order bit to the carry and also to the lowโ€‘order position. Starting with 3C (00111100), the first RLC yields 78 (01111000) and the second yields F0 (11110000). The other options represent different rotations or no change. This operation is useful for bitโ€‘wise manipulations such as creating masks.

๐Ÿ”— Related Topics (MCQs)