8085 program to Unpack the two packed BCD numbers

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

InstructionCommentsOperation
LDA C200HLoad the packed BCD number in the accumulator.A = 92H
ANI F0 HMask the lower nibble i.e. AND number with F0H.A = 1001 0010
F0 = 1111 0000
A ANDing with F0 H = 90H
A = 1001 0000
RRCRotate the number to the right by 1.A = 0100 1000 = 48H
RRCRotate the number to the right by 1.A = 0010 0100 = 24H
RRCRotate the number to the right by 1.A = 0001 0010 = 12H
RRCRotate the number to the right by 1 to get the MSB digit.A = 0000 1001 = 09H
STA C301HStore the unpacked MSB BCD digit.C301H = 09H
LDA C200HLoad the original BCD number in the accumulator.A = 92H
ANI 0F Hmask 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 C300HStore the unpacked LSB BCD digit.C300H = 02H
HLTTerminate program executionStop

Flow Chart of Program

8085 program to Unpack the two packed BCD numbers flow chart

Also Learn other 8085 Programs

Sr. No.Name of the 8085 Programs
1.Write a program to load the data into the accumulator and any register.
2.Write a program to exchange the contents of memory locations.
3.Add two 8-bit numbers.
4.Subtract two 8-bit numbers.
5.Add two 16-bit numbers.
6.Subtract two 16-bit numbers
7.Find the 1’s complement of a Number
8.Find the 2’s complement of a Number
9.8085 Program To Mask The Lower Nibble
10.8085 Program To Mask The Upper Nibble
11.8085 program to pack the two unpacked BCD numbers
12.8085 program to Unpack the two packed BCD numbers
13.8085 program to find the sum of a series of 8-bit numbers
14.8085 Program to sort the numbers in ascending order
15.8085 Program to sort the numbers in Descending order
16.8085 Program to Multiply Two 8-bit Numbers
17.8085 Program to Divide 16-bit number by 8-bit number
18.8085 Program to Find the Number of Negative Numbers in Array
19.8085 Program to Find Maximum Number in Array
20.8085 Program to count the number of 1’s in a register
21.8085 Program to Calculate the sum of a series of even numbers
22.8085 Program to find the square of numbers
23.8085 Program to find the smallest number in the array

Hello friends, my name is Trupal Bhavsar, I am the Writer and Founder of this blog. I am Electronics Engineer(2014 pass out), Currently working as Junior Telecom Officer(B.S.N.L.) also I do Project Development, PCB designing and Teaching of Electronics Subjects.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

telegram logo Join Our Telegram Group!