8085 Program for subtraction of multi-Byte BCD numbers


Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to subtract multi-Byte BCD numbers.

Problem Statement

Write 8085 Assembly language program to subtract two multi-Byte BCD numbers.

Discussion

The numbers are stored into memory, and one additional information is stored. It will show us the Byte count of the multi-Byte BCD number. Here we are choosing 3-Byte BCD numbers. They are stored at location 8001H to 8003H, and another number is stored at location 8004H to 8006H. The location 8000H is holding the Byte count. In this case the Byte count is 03H.

For the subtraction we are using the 10’s complement method for subtraction.

In this case the numbers are: 672173 – 275188 = 376985

Input

Address
Data
.
.
.
.
.
.
8000
03
8001
73
8002
21
8003
67
8004
88
8005
51
8006
27
.
.
.
.
.
.

Flow Diagram

Program

Address
HEX Codes
Labels
Mnemonics
Comments
F000
21, 00, 80

LXI H,8000H
Point to get the count
F003
4E

MOV C,M
Get the count to C
F004
11, 01, 80

LXI D,8001H
Point to first number
F007
21, 04, 80

LXI H,8004H
Point to second number
F00A
37

STC
Set the carry flag
F00B
3E, 99
LOOP
MVI A,99H
Load 99H into A
F00D
CE,00

ACI 00H
Add 00H and Carry with A
F00F
96

SUB M
Subtract M from A
F010
EB

XCHG
Exchange DE and HL
F011
86

ADD M
Add M to A
F012
27

DAA
Decimal adjust
F013
77

MOV M,A
Store A to memory
F014
EB

XCHG
Exchange DE and HL
F015
23

INX H
Point to next location by HL
F016
13

INX D
Point to next location by DE
F017
0D

DCR C
Decrease C by 1
F018
C2, 0B, F0

JNZ LOOP
Jump to LOOP if Z = 0
F01B
76

HLT
Terminate the program

Output

Address
Data
.
.
.
.
.
.
8001
85
8002
69
8003
37
.
.
.
.
.
.

Updated on: 30-Jun-2020

344 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements