8085 program to unpack 16-bit BCD, and store consecutive locations


Here we will see we can take 16-bit BCD data from memory and unpack it, then store into memory using 8085.

Problem Statement

Write 8085 program to take 16-bit BCD number from memory then store each digit by unpacking into different locations.

Discussion

To solve this problem, we will create one subroutine, that can unpack 1-byte BCD number and store into memory, then we will use that subroutine for two times to store 16-bit data. The subroutine will cut the numbers by masking upper nibble and lower nibble, and store into memory.

Input

1234 in the DE register pair

Flow Diagram

 

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
31, 00, FC
 
LXI SP,FC00
Initialize stack pointer
F003
11, 34, 12
 
LXI D,ABCD
load 16-bit number
F006
21, 00, 90
 
LXI H,9000
point to destination address
F009
7B
 
MOV A,E
take E into A
F00A
CD, 13, F0
 
CALL UNPACK
Unpack lower byte and store
F00D
23
 
INX H
point to next location
F00E
7A
 
MOV A,D
take upper byte
F00F
CD, 13, F0
 
CALL UNPACK
unpack upper byte and store
F012
76
 
HLT
Terminate the program
F013
D5
UNPACK
PUSH D
push DE into stack
F014
57
 
MOV D,A
store number into D
F015
E6, F0
 
ANI 0FH
mask upper nibble
F017
77
 
MOV M,A
store lower nibble
F018
7A
 
MOV A,D
take the number again
F019
E6, F0
 
ANI F0H
mask lower nibble
F01B
07
 
RLC
rotate left
F01C
07
 
RLC
rotate left
F01D
07
 
RLC
rotate left
F01E
07
 
RLC
rotate left
F01F
23
 
INX H
point to next location
F020
77
 
MOV M,A
store upper nibble into memory
F021
D1
 
POP D
pop DE from stack
F022
C9
 
RET
Return from subroutine

 

Output

Address
Data


9000
04
9001
03
9002
02
9003
01


 

 

 

 

Updated on: 30-Jul-2019

659 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements