MICROPROCESSOR LAB
Ex. No: 2
8 BIT BCD OPERATIONS using 8085
a) ADDITION
ALGORITHM:
I.
II.
III.
IV.
V.
Get the 1st data into accumulator.
Get second data into B
Add the accumulator with 2nd data
Move the result from accumulator to memory.
Halt
Program:
Address
Label
Mnemonics
Machine Code
2000
2001
2002
LDA 2050
3A
50;
20
2003
MOV B A
47
LDA 2051
3A ;
01
C3
0E
00
2004
2005
2006
2007
2008
2009
200A
200B
MVI C 00
ADD B
DAA
JNC C00F D2
80 ;
27
D2
Comments
Load the
accumulator
with addend
Move the
accumulator
content to B
register
Load the
accumulator
with augend
; Move
immediately
00H to C
register C
Add the B
register
content with
accumulator
; The 8 bit
number in the
accumulator is
adjusted to
form two 4 bit
BCD digit by
Decimal adjust
accumulator
instruction
; Jump if no
carry to C00FH
OUTPUT VERIFIACTION:
INPUT
DATA 1
DATA 2
OUTPUT
16 BIT ARITHMETIC OPERATIONS using 8086
b) ADDITION
ALGORITHM:
VI.
VII.
VIII.
IX.
X.
XI.
XII.
XIII.
XIV.
XV.
Program:
Initialize the SI register to input data memory location
Initialize the DI register to output data memory location
Initialize the CL register to zero for carry
Get the 1st data into accumulator.
Add the accumulator with 2nd data
Check the carry flag, if not skip next line
Increment carry(CL Reg)
Move the result from accumulator to memory.
Also store carry register
Halt
Address
Label
STORE:
Mnemonics
Machine Code
Comments
MOV SI, 2000H
MOV DI, 3000H
MOV CL, 00H
MOV AX, [SI]
ADD AX, [SI+2]
JNC STORE
INC CL
MOV [DI], AX
MOV [DI+2], CL
INT 3
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
DATA 1
DATA 2
DATA 2
34
12
78
56
AC
68
00
c) SUBTRACTION
ALGORITHM:
I.
II.
III.
IV.
V.
VI.
VII.
VIII.
IX.
X.
XI.
Initialize the SI register to input data memory location
Initialize the DI register to output data memory location
Initialize the CL register to zero for borrow
Get the 1st data into accumulator.
Subtract the accumulator with 2nd data
Check the carry flag, if not set skip next line
Increment carry(CL Reg)
2s Compliment Accumalator
Move the result from accumulator to memory.
Also store carry register
Halt
Program:
Address
Label
Mnemonics
Machine Code
Comments
STORE:
MOV SI, 2000H
MOV DI, 3000H
MOV CL, 00H
MOV AX, [SI]
SUB AX, [SI+2]
JNC STORE
INC CL
NEG AX
MOV [DI], AX
MOV [DI+2], CL
INT 3
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
DATA 1
DATA 2
DATA 2
88
44
33
22
55
22
00
C) MULTIPLICATION
ALGORITHM:
I.
II.
III.
IV.
V.
VI.
GET MULTIPLIER INTO ACCUMULATOR FROM MEMORY
GET MULTIPLICAND INTO BX REGISTER
MULTIPLY AX AND BX
STORE LOWER ORDER WORD FORM ACCUMULATOR INTO MEMORY
STORE HIGHER ORDER WORD FROM DX INTO MEMORY
HALT
Program:
Address
Label
Mnemonics
Machine Code
Comments
MOV
MOV
MUL
MOV
MOV
INT 3
AX, [2000H]
BX, [2002H]
BX
[3000], AX
[3002], DX
OUTPUT VERIFIACTION:
INPUT
2000H
2001H
2002H
2003H
OUTPUT
3000H
3001H
3002H
3003H
DATA 1
0A
00
0A
00
64
00
00
00
DATA 2
DATA 2