- Related Questions & Answers
- 8085 Program to multiply two 2-digit BCD numbers
- 8085 Program to convert a 16-bit binary number to BCD
- 8085 Program to convert an 8-bit binary to BCD
- Program to multiply two 2-digit BCD numbers in 8085 Microprocessor
- 8085 Program to convert BCD to HEX
- 8085 Program to convert HEX to BCD
- Program to convert a 16-bit binary number to BCD in 8085 Microprocessor
- 8085 Program to convert two-digit hex to two ASCII values
- 8085 program to subtract two BCD numbers
- Program to convert BCD to HEX in 8085 Microprocessor
- Program to convert HEX to BCD in 8085 Microprocessor
- Program to convert two-digit hex to two ASCII values in 8085 Microprocessor
- 8085 Program to Add two multi-byte BCD numbers
- 8085 Program to convert ASCII to binary
- 8085 program to convert gray to binary

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

In this program we will see how to convert BCD numbers to binary equivalent.

A BCD number is stored at location 802BH. Convert the number into its binary equivalent andstore it to the memory location 802CH.

In this problem we are taking a BCD number from the memory and converting it to its binaryequivalent. At first we are cutting each nibble of the input. So ifthe input is 52 (0101 0010) then we can simply cut it by masking the number by 0FH and F0H. When the Higher order nibble is cut, thenrotate it to the left four times to transfer it to lower nibble.

Now simply multiply the numbers by using decimal adjust method to get final decimal result.

Address | Data |
---|---|

. . . | . . . |

802B | 52 |

. . . | . . . |

Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|

8000 | 31, FF, 80 | LXI SP,80FFH | Initialize stack pointer | |

8003 | 21, 2B, 80 | LXI H, 802BH | Pointer to the IN-BUFFER | |

8006 | 01, 2C, 80 | LXI B, 802CH | Pointer to the OUT-BUFFER | |

8009 | 7E | MOV A, M | Move the contents of 802BH to A | |

800A | CD, 0F, 80 | CALL BCDBIN | Subroutine to convert a BCD number to HEX | |

800D | 02 | STAX B | Store Acc to memory location pointed by BC | |

800E | 76 | HLT | Terminate the program | |

800F | C5 | BCDBIN | PUSH B | Saving B |

8010 | 47 | MOV B, A | Copy A to B | |

8011 | E6, 0F | ANI 0FH | Mask of the most significant four bits | |

8013 | 4F | MOV C, A | Copy A to C | |

8014 | 78 | MOV A, B | Copy B to A | |

8015 | E6, F0 | ANI F0H | Mask of the least significant four bits | |

8017 | 0F | RRC | Rotate accumulator right 4 times | |

8018 | 0F | RRC | ||

8019 | 0F | RRC | ||

801A | 0F | RRC | ||

801B | 57 | MOV D, A | Load the count value to the Reg. D | |

801C | AF | XRA A | Clear the contents of the accumulator | |

801D | 1E, 0A | MVI E, 0AH | Initialize Reg. E with 0AH | |

801F | 83 | SUM | ADD E | Add the contents of Reg. E to A |

8020 | 15 | DCR D | Decrement the count by 1 until 0 is reached | |

8021 | C2, 1F, 80 | JNZ SUM | ||

8024 | 81 | ADD C | Add the contents of Reg. C to A | |

8025 | C1 | POP B | Restoring B | |

8026 | C9 | RET | Returning control to the calling program |

Address | Data |
---|---|

. . . | . . . |

802C | 34 |

. . . | . . . |

Advertisements