🎓 BookMCQ
← Back to 6. Programming of 8085

📝 Binary to BCD (Unpacked) Conversion in 8085 Microprocessor (13 MCQs)

Representation of Binary Numbers as Unpacked BCD Digits

Binary to unpacked BCD conversion transforms an ordinary binary number into separate decimal digits, with each digit occupying one eight-bit memory location. Unlike packed BCD, unpacked BCD uses only the lower four bits of each byte for its decimal digit. The 8085 performs this conversion through repeated subtraction and counting operations.

Extracting Hundreds, Tens and Units from an Eight-Bit Value

An eight-bit unsigned binary number ranges from 0 to 255, requiring at most three decimal digits. Repeated subtraction of 64H, representing decimal 100, determines the hundreds count. Repeated subtraction of 0AH, representing decimal 10, determines the tens count, and the remaining value becomes the units digit.

Repeated Subtraction and Carry-Based Loop Control

The accumulator initially contains the binary input. CPI 64H compares it with one hundred, and JC exits the hundreds loop when the remaining value becomes smaller. SUI 64H reduces the value and INR increments the hundreds counter. The same method using CPI 0AH and SUI 0AH determines tens and units.

Program to Convert C7H into Three Unpacked BCD Digits

Load the binary input from 2050H into A, initialize B to zero, and repeatedly subtract 64H while incrementing B. Next, initialize C to zero and repeatedly subtract 0AH while incrementing C. Store A, C and B at 2053H, 2052H and 2051H respectively. Input C7H produces 01H, 09H and 09H.

Memory Storage and Decimal Display Applications

Unpacked BCD simplifies decimal digit handling because each digit occupies an independently addressable byte. Programs can use these values for display conversion, decimal counters and numerical output. The separate storage arrangement also makes it easier to extract, compare or transmit individual decimal digits through memory and input/output interfaces.

Misconceptions About Unpacked BCD Representation

'Unpacked BCD stores two decimal digits per byte' describes packed BCD instead. 'C7H represents decimal 127' confuses ordinary hexadecimal notation with binary-to-decimal interpretation. 'The units digit must always be extracted first' overlooks methods that calculate hundreds and tens through successive subtraction.

BCD Conversion Algorithms and Memory-Content Questions

Practise converting binary values between 00H and FFH into hundreds, tens and units digits. Understand repeated subtraction, counter increments and carry-based loop termination. Identify the order of output bytes and distinguish unpacked BCD digits from packed BCD. Examination questions may also require tracing accumulator contents after each subtraction.

Unpacked BCD and Conversion Algorithm Terms

  • Unpacked BCD - Stores one decimal digit per byte.
  • Hundreds Counter - Counts subtractions of decimal 100.
  • Tens Counter - Counts subtractions of decimal 10.
  • Remainder - Provides the remaining units digit.
  • CPI - Compares accumulator with immediate data.
  • SUI - Subtracts immediate data from A.
3
Easy
6
Medium
4
Hard

📝 All Binary to BCD (Unpacked) Conversion in 8085 Microprocessor MCQs

Q1. What does BCD stand for?

A.Binary Coded Decimal ✅
B.Basic Computer Data
C.Binary Control Device
D.Byte Code Definition
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Binary Coded Decimal (BCD) is a coding scheme where each decimal digit (0‑9) is represented by its four‑bit binary equivalent. The acronym therefore expands to Binary Coded Decimal. The other options are unrelated abbreviations that do not describe this representation. Recognizing the correct meaning is crucial because all conversion algorithms assume the BCD definition when mapping decimal digits to binary patterns in 8085 programs.

Q2. Why might a designer choose unpacked BCD over packed BCD when interfacing with a 7‑segment display?

A.Because unpacked BCD uses one byte per digit, simplifying wiring ✅
B.Because unpacked BCD reduces memory usage
C.Because packed BCD allows direct arithmetic without conversion
D.Because unpacked BCD is compatible with floating‑point units
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: Unpacked BCD stores each decimal digit in a full byte, so the high‑order nibble is unused. This matches the typical 8‑bit input of a 7‑segment driver, eliminating the need for masking or shifting before sending data to the display. The other choices are inaccurate: it actually consumes more memory, does not affect arithmetic directly, and has no relationship to floating‑point hardware.

Q3. A microcontroller reads the binary value 010120101_2. What is the correct unpacked BCD representation to store in memory?

A.5
B.80 ✅
C.10
D.160
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The binary value 010120101_2 equals decimal 5. In unpacked BCD each decimal digit occupies a full byte, so the digit 5 is stored as 0x05. Option B places the digit in the high nibble, which is not unpacked BCD. Options C and D represent hexadecimal or reversed nibble forms, neither of which correspond to the standard unpacked BCD encoding.

Q4. In an 8085 program, after converting a binary number to unpacked BCD, why is it necessary to clear the upper nibble of each result byte?

A.To ensure each byte contains only a decimal digit 0‑9 ✅
B.To double the numeric value
C.To prepare the bytes for packed BCD conversion
D.To set the sign flag
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: Unpacked BCD reserves the upper four bits of each byte for no purpose; clearing them guarantees that each byte holds a valid decimal digit (0‑9) and prevents accidental interpretation as a larger hexadecimal value. Doubling the value or setting flags is unrelated to BCD formatting, and preparation for packed BCD would involve different packing steps, not merely clearing the upper nibble.

Q5. How does the double‑dabble (shift‑add‑3) algorithm guarantee that each 4‑bit group never exceeds the BCD digit range during conversion?

A.By adding three whenever a group reaches five ✅
B.By subtracting one after each shift
C.By rotating bits left
D.By masking with 0xF0
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: The algorithm examines each 4‑bit BCD group after a left shift; if the group is 5 or greater, adding three forces the value back into the 0‑9 range after the next shift. This prevents any group from ever becoming 10 or higher, which would be invalid for BCD. Subtraction, rotation, or masking do not provide this corrective mechanism and would not maintain proper BCD digit limits.

Q6. An 8085 routine receives the binary number 0x9B (155 decimal). Using the double‑dabble method, which three bytes will hold the unpacked BCD result?

A.0x01 0x05 0x05
B.0x15 0x05 ✅
C.0x01 0x55
D.0x15 0x55
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The decimal value 155 consists of the digits 1, 5, and 5. In unpacked BCD each digit occupies its own byte, so the correct representation is 0x01 for the hundreds digit, followed by 0x05 for the tens and ones digits. Option B merges digits, option C places a two‑digit value in a single byte, and option D misorders the digits, making them unsuitable for unpacked BCD storage.

Q7. If an 8085 program stores the unpacked BCD digits of a number in consecutive memory locations starting at 3000H, which address will contain the least significant digit after converting the binary value 0x3C (60 decimal)?

A.3000H
B.3001H ✅
C.3002H
D.3003H
💡 Difficulty: medium | ✅ Correct: B

📖 Explanation: The decimal number 60 has two digits: 6 (most significant) and 0 (least significant). When storing unpacked BCD sequentially, the first digit (6) is placed at the starting address 3000H, and the next digit (0) is stored at the next address, 3001H. Therefore the least significant digit resides at 3001H. The other addresses would hold either unrelated data or higher‑order digits for larger numbers.

Q8. During a conversion, an 8085 programmer uses the instruction sequence: MVI A,0x00; RLC; DAA. What is the purpose of the DAA instruction in the context of binary‑to‑BCD conversion?

A.To adjust the accumulator to a valid BCD after a binary addition ✅
B.To rotate bits left
C.To clear the accumulator
D.To store the result in memory
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: DAA (Decimal Adjust Accumulator) examines the accumulator after a binary addition and adds 6 (0x06) to any nibble that exceeds nine, thereby converting the binary result into a proper BCD format. This step is essential when the accumulator holds a binary sum that must be displayed as decimal digits. The other options describe unrelated operations: RLC rotates bits, clearing the accumulator would use XRA A, and storing requires MOV or STA instructions.

Q9. Explain why the double‑dabble algorithm requires a left shift of the entire shift register before checking and possibly adding three to each BCD digit.

A.Because shifting aligns the next binary bit for processing and ensures the add‑3 correction maintains BCD limits ✅
B.Because shifting reduces the number of bits
C.Because it converts the number to hexadecimal
D.Because it sets the carry flag
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A left shift moves the next most‑significant binary bit into the lowest position of the shift register, making it available for the subsequent add‑3 correction. This ordering ensures that each BCD digit is examined only after the new bit has been incorporated, so adding three when the digit is ≥5 keeps the digit within the 0‑9 range. The other statements mischaracterize the purpose of the shift; it does not simply reduce bit count, convert bases, or affect the carry flag directly.

Q10. When converting a 16‑bit binary number to unpacked BCD on an 8085, why might a programmer prefer to use a lookup table over the double‑dabble method?

A.Lookup tables eliminate runtime shifts and additions, speeding up conversion ✅
B.Lookup tables increase code size without benefit
C.Lookup tables only work for packed BCD
D.Lookup tables require floating‑point hardware
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A pre‑computed lookup table contains the BCD representation for every possible 8‑bit value, allowing the program to fetch the result with a single memory read instead of performing iterative shifts and add‑3 corrections. This reduces execution time at the cost of additional ROM space, which is often acceptable in embedded systems. The other options are incorrect: tables do not inherently increase size without benefit, they can store unpacked BCD, and they do not depend on floating‑point units.

Q11. A program must convert the 8‑bit binary value 0x7F (127 decimal) to unpacked BCD using only the instructions: RRC, INR, DAA, and MOV. Which sequence correctly yields the three BCD bytes 0x01,0x02,0x07?

A.Shift right, increment accumulator, apply DAA after each shift, store each digit sequentially ✅
B.Shift left, decrement accumulator, apply DAA only once
C.Use RRC twice then DAA, store result directly
D.Apply INR before any shifts, then DAA, store
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: The correct approach is to rotate the binary value right (RRC) to bring each bit into the carry, increment the accumulator (INR) to build the decimal digit, and apply DAA after each increment to adjust the accumulator to a valid BCD digit. Repeating this process three times produces the digits 0x01, 0x02, and 0x07, which are then moved to memory with MOV. The other options either use the wrong direction, omit necessary DAA adjustments, or change the order of operations, leading to incorrect BCD results.

Q12. In a system where the unpacked BCD result must be transmitted over a UART that expects ASCII characters, what additional step is required after obtaining the BCD bytes?

A.Add 0x30 to each byte to convert to ASCII ✅
B.Subtract 0x30
C.Perform a bitwise NOT
D.Reverse the byte order
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: UART modules that send printable characters expect ASCII codes, where the character '0' corresponds to 0x30. To turn a BCD digit like 0x05 into its ASCII representation, you add 0x30, producing 0x35, which the UART will transmit as the character '5'. Subtracting 0x30 would produce non‑printable values, and bitwise NOT or byte reversal do not perform the required character conversion.

Q13. A programmer needs to display the result of a binary addition (0x23 + 0x17) on a seven‑segment display that reads unpacked BCD from memory locations 4000H and 4001H. After performing the addition, which sequence of instructions correctly converts the sum to unpacked BCD before storing it?

A.ADD, DAA, MOV to 4000H, MOV to 4001H ✅
B.ADD, RLC, DAA, MOV
C.ADD, DAA, INR, MOV
D.ADD, DAA, DAA, MOV
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: First the ADD instruction produces the binary sum (0x3A). Executing DAA adjusts the accumulator so that it contains a valid BCD representation of the result, which for 0x3A becomes 0x40 (representing decimal 60). The MOV instructions then store the most‑significant digit at 4000H and the least‑significant digit at 4001H, matching the unpacked BCD format required by the display. The other options either misuse RLC, apply unnecessary increments, or perform DAA twice, leading to incorrect BCD values.

🔗 Related Topics (MCQs)