In this program, we will write an 8085 program to Unpack the two packed BCD numbers in the 8085 microprocessor with a program flow chart and explanation of the program.

**8085 program to Unpack the two packed BCD numbers**

**Program Statement**

Write a program to unpack the packed BCD number. A two-digit BCD number is stored at memory location C200H. unpack the BCD numbers and store the two digits in memory locations C300H and C301H such that memory location C300H will have the lower BCD digit.

**Explanation of Program**

- A packed BCD digit is at memory location C200H. We have to unpack the BCD number i.e. we have to separate the BCD digits. e.g. if the number is given 92H then in unpack form the digits will be 09H and 02H.

- We have to mask the lower nibble to get the MSB digit. Then, rotate the masked number by 4 times to the right using instruction RRC to get the MSB digit. Store the result.

- Then to get the LSB digit, mask the upper nibble and then store the result.

**Assembly Language Program**

Instruction | Comments | Operation |
---|---|---|

LDA C200H | Load the packed BCD number in the accumulator. | A = 92H |

ANI F0 H | Mask the lower nibble i.e. AND number with F0H. | A = 1001 0010 F0 = 1111 0000 A ANDing with F0 H = 90H A = 1001 0000 |

RRC | Rotate the number to the right by 1. | A = 0100 1000 = 48H |

RRC | Rotate the number to the right by 1. | A = 0010 0100 = 24H |

RRC | Rotate the number to the right by 1. | A = 0001 0010 = 12H |

RRC | Rotate the number to the right by 1 to get the MSB digit. | A = 0000 1001 = 09H |

STA C301H | Store the unpacked MSB BCD digit. | C301H = 09H |

LDA C200H | Load the original BCD number in the accumulator. | A = 92H |

ANI 0F H | mask the higher nibble. i.e. AND number with 0F H. | A = 1001 0010 0F = 0000 1111 A ANDing with 0F H = 02H A = 0000 0010 |

STA C300H | Store the unpacked LSB BCD digit. | C300H = 02H |

HLT | Terminate program execution | Stop |

**Flow Chart of Program**

Also Learn other 8085 Programs