---
title: "8085 ALP: BCD to binary conversion"
subject: "Microprocessor"
chapter: 2
key: "semester_4/microprocessor:alp-8085-bcd-to-binary"
source: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8085-bcd-to-binary
site: BCT Engineering
---

# 8085 ALP: BCD to binary conversion

Microprocessor · Chapter 2: Programming with 8085 Microprocessor

- Asked in: 2069 Bhadra, 8 marks
- Video: [BCD TO BINARY Conversion programming in 8085 microprocessor](https://www.youtube.com/watch?v=f9ADl_DXPOI) — Shri Ram Programming Academy
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/microprocessor/alp-8085-bcd-to-binary
- Whole chapter: https://www.bctengineer.com/md/semester_4/microprocessor/chapter-2

## Question

Write a program to convert ten BCD numbers stored at 4350H to binary and store the result at 4360H.

## Short answer

Extract the high nibble (AND F0H, rotate right 4 times), multiply by 10 using additions (×2, ×4, ×5, then ×2 to get ×10). Add the low nibble obtained via ANI 0FH. Convert ten bytes from 4350H; e.g., 47H becomes 2FH.

## Answer

Each packed BCD byte holds two decimal digits, so binary value = (high digit × 10) + low digit. The high digit is isolated, multiplied by 10 using shifts-and-adds (×10 = ×4 + ×1, then ×2), and added to the low digit.

**Algorithm**
1. HL → source (4350H), DE → destination (4360H), C = 10 (count).
2. Take the byte, mask the upper nibble (F0H) and rotate right four times to bring it to the lower nibble.
3. Multiply by 10: A×2 → A×4, add original (A×5), double (A×10).
4. Add the lower nibble (byte AND 0FH). Store the result and advance the pointers.

```asm
        LXI  H,4350H      ; HL = source address of BCD numbers
        LXI  D,4360H      ; DE = destination address
        MVI  C,0AH        ; counter = 10 numbers
NEXT:   MOV  A,M          ; A = packed BCD byte
        ANI  0F0H         ; keep high digit only
        RRC               ; rotate right 4 times -> high digit in
        RRC               ; the lower nibble
        RRC
        RRC
        MOV  B,A          ; B = high digit (x)
        ADD  A            ; A = 2x
        ADD  A            ; A = 4x
        ADD  B            ; A = 5x
        ADD  A            ; A = 10x
        MOV  B,A          ; B = 10 x high digit
        MOV  A,M          ; get the byte again
        ANI  0FH          ; A = low digit
        ADD  B            ; A = 10 x high + low = binary
        STAX D            ; store binary result
        INX  H            ; next BCD number
        INX  D            ; next destination
        DCR  C            ; one number done
        JNZ  NEXT         ; repeat until all ten are converted
        HLT
```

**Example:** BCD 47H → high digit 4 → 40 (28H); low digit 7; result 28H + 07H = 2FH (47 decimal). BCD 99H → 63H.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is the basic idea for converting a packed BCD byte to binary?
   A. Binary = high digit x 16 + low digit
   B. Binary = high digit + low digit
   C. Binary = high digit x 10 + low digit
   D. Binary = the BCD byte with its upper nibble cleared
   Answer: C. A packed BCD byte holds two decimal digits, so its value is (high digit x 10) + low digit. (Key point: Binary value = high digit x 10 + low digit)

2. Why does the program use ANI 0F0H followed by four RRC instructions?
   A. To isolate the high digit and move it into the lower nibble
   B. To isolate the low digit and clear the carry
   C. To multiply the high digit by 16
   D. To convert the BCD byte to ASCII
   Answer: A. ANI 0F0H keeps only the upper nibble, and four right rotations bring that digit into bit positions 0-3. (Key point: ANI F0H then RRC four times brings the high digit to the low nibble)

3. With B = x, which sequence correctly gives A = 10x?
   A. ADD A (2x), ADD B (3x), ADD A (6x), ADD A (12x)
   B. ADD B ten times
   C. RLC four times
   D. ADD A (2x), ADD A (4x), ADD B (5x), ADD A (10x)
   Answer: D. Doubling twice gives 4x, adding the original gives 5x, and doubling once more gives 10x, which is the shift-and-add multiply used in the answer. (Key point: x10 done as 2x, 4x, +x = 5x, then double = 10x)

4. What binary result does the program store for the BCD byte 47H?
   A. 47H
   B. 2FH
   C. 0BH
   D. 4BH
   Answer: B. High digit 4 gives 40 = 28H, plus the low digit 7 gives 2FH, which is 47 in decimal. (Key point: BCD 47H converts to 2FH (47 decimal))

## Related in Microprocessor

- [8085 ALP: square of ten numbers](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-square-numbers) — Microprocessor, chapter 2
- [8085 ALP: count ones in upper nibble](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-ones-upper-nibble) — Microprocessor, chapter 2
- [8085 ALP: add upper and lower nibbles](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-add-nibbles) — Microprocessor, chapter 2
- [8085 ALP: multiplication table of a number](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-multiplication-table) — Microprocessor, chapter 2
- [8085 ALP: divide two bytes](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-divide-bytes) — Microprocessor, chapter 2
- [8085 ALP: compare two tables of 16-bit data](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Aalp-8085-compare-tables-1ffffh) — Microprocessor, chapter 2

## Related in other subjects

- [C program: sum of two 8-bit BCD numbers](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-bcd-sum-c) — Embedded System, chapter 9
- [Protected specifier; student/test/result program](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Aprotected-three-class-program) — Object Oriented Programming, chapter 6
- [Greatest and smallest of ten numbers](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afortran-greatest-smallest-ten) — Computer Programming, chapter 11
- [Short note: Stored program control](https://www.bctengineer.com/question.md?key=semester_8%2Ftelecommunications%3Ashort-note-spc-digital-exchange) — Telecommunications, chapter 4
