You are on page 1of 10

CONVERSION

BCD TO HEX

AIM:
To convert two BCD numbers in memory to the equivalent HEX
number using 8085
instruction set
ALGORITHM
:
Initialize memory pointer to
1
4150 H
)
Get the Most Significant Digit
2
(MSD)
Multiply the MSD by ten using repeated
)
addition
3
Add the Least Significant Digit (LSD) to the result obtained in
)
previous step
4
Store the HEX data in
)
Memory
5
)

PROGRAM
:

LXI
MOV
A DD
MOV
A DD
A DD
A DD
INX
A DD
INX
MOV
HLT

OBSERVATION
:

H, 4 1
50
A,
M
A
B,A
A
A
B
H
M
H
M,A

Initialize memory
pointer
MSD X 2
Store MSD X 2
MSD X 4
MSD X 8
MSD X 10
Point to LSD
Add to form HEX
Store the
result

Input:

4150 : 02 (MSD)
4151 : 09 (LSD)

Output:

4152 : 1D H

R E SU L T :
Thus the program to convert BCD data to HEX data was
executed.

CONVERSION

HEX TO BCD

AIM:
To convert given Hexa decimal number into its equivalent BCD
number using 8085
instruction set
ALGORITHM
:
Initialize memory pointer to
4150 H
1
Get the Hexa decimal number in C )
register
2
Perform repeated addition for C number
)
of times
3
)
Adjust for BCD in each
4
step
)
Store the BCD data in
5
Memory
)

PROGRAM
:

LOOP2:

LOOP1:

LXI
MV
I
XR
A
MO
VA
DI
DAA
JNC
INR
DC
R
JNZ
STA
MOV
STA
HL
T

H, 4 1 5 0
D, 0 0
A
C ,M
01
LOOP1
DC
LOOP2
4151 A ,D 4152

m
e
m
o
r
y

I
n
i
t
i
a
l
i
z
e

p
o
i
n
t
e
r

Cle
ar
Dreg
for
Mo
st
sig
nifi
can
t
Byt
e
C

lear Accumulator
Get HEX data
Count the number one by
one
Adjust for BCD
count

Store the Least


Significant Byte
Store the Most Significant
Byte

OBSERVATION
:
Input:

4150 : FF

Output:

4151 : 55 (LSB)
4152 : 02 (MSB)

R E SU L T :
Thus the program to convert HEX data to BCD data
was executed.

CONVERSION

HEX TO ASCII

AIM:
To convert given Hexa decimal number into its equivalent ASCII
number using
8085 instruction set.
ALGORITHM
:
Load the given data in A- register and move to B 1 register
. Mask the upper nibble of the Hexa decimal number in
2 A - register
. Call subroutine to get ASCII of lower
3 nibble
. Store it in memory
4 Move B -register to A - register and mask the
. lower nibble
5 Rotate the upper nibble to lower nibble
. position
6 Call subroutine to get ASCII of upper
. nibble
7 Store it in memory
. Terminate the program.
8
.
9
.

PROGRAM
:

RLC
RLC
RLC
LDA
MO
VA
NI
CAL
L
STA
MOV
A NI
RLC

4200 B,A 0F
SUB1 4201 A ,B F0

H
e
x
a

G
e
t

SUB
1:
SKIP
:

CALL
nibble
STA
HLT
CPI
JC
A DI
A DI
R
ET

a
t
a
M
a

sk Upper Nibble
Get ASCII code for upper
nibble

Mask Lower
Nibble
SUB1 Get ASCII code for lower
4202
0A
SKIP
07 30

OBSERVATION
:
Input:

4200 E4(Hexa data)

Output:
4)

4201 34(ASCII Code for


4202 45(ASCII Code for E)

R E SU L T :
Thus the given Hexa decimal number was converted into its
equivalent ASCII Code.

ASCII TO HEX

CONVERSION
AIM:

To convert given ASCII Character into its equivalent Hexa Decimal


number using
8085 instruction set.
ALGORITHM
:
Load the given data in A1 register
. Subtract 30 H from A 2 register
. Compare the content of A - register with
3 0A H
. If A < 0A H, jump to step6. Else proceed to
4 next step.
. Subtract 07 H from A 5 register
. Store the result
6 Terminate the program
.
7
.
t:
PROGRAM
:

Output:
R
E
S
U

SKIP:
OBSERVATION
:
Inpu

L
T
:

LDA SU I CPI
JC
SU I STA HLT

4500
30
0A
SKIP
07
4501

450
0
450
1

31
0B

Thus the given ASCII character was converted into its equivalent
Hexa Value.

You might also like