You are on page 1of 16

Write Program With Microprocessor (8085) to add ten packed

BCD numbers.

DEPARTMENT OF INFORMATION TECHNOLOGY

B.Sc.IT-SEMESTER 2
PROJECT REPORT
BY
APARNA DUBEY (22162)
SHIVAM RAJBHAR (22164)
SHIVNATH BALAWAT (22161)
YASH JAISWAL (22163)
SHIVNATH KUSHWAHA (22165)

Under the guidance of :- Miss Neenu Johnson

MICROPROCESSOR & MICROCONTROLLER [MPMC]


PROJECT C.E-2
(2022-23)
Certificate
This to certify that the project entitled “to add ten packed BCD
numbers using 8085” Undertaken at the by -Ms. APARNA DUBEY
(22162) ,Mr. SHIVAM RAJBHAR (22164) , Mr. SHIVNATH
BALAWAT (22161)in Partial fulfillment of B.Sc. IT degree
(Semester-II) Examination had not been submitted for any other
examination and does not form part of any other course undergone by
the candidate .This is further certified that they have completed all
required phases of the project.

Signature of HOD Signature of


Teacher
TABLE OF CONTENTS

INDEX

Sr Topics Page
No. no.
1 AIM OF THE PROJECT 4

2 Flow Diagram 6

3 8085 PROGRAMS 7

3 CLASSIFICATION Of 12
INSTRUCTION IN A TABLE

4 SUBROUTINES 13

5 CONCLUSION 14
AIM:-
Write a Assembly Program with Microprocessor (8085) To
set of ten packed BCD numbers and stored in the memory
location starting from 8040H to 8049H.

a. Write a program with a subroutine to add these numbers in


BCD. If a carry is generated save it to register B, and adjust it to
BCD. The final sum will be less than 9999BCD. Store the sum
at locations 8060H and 8061H.

b. Write a second subroutine to unpack the BCD sum stored in


registers A and B, and store them in the Output Buffer memory
starting at 8062H. The most significant digit (BCD4) should be
stored at 8065H and the least significant digit (BCD1) at 8062H.

Discussion
The numbers are present at 8040 onwards. As the B will store the
carry, we have to clear the B first. In the first phase we have to take
the number from memory, then add them as BCD numbers, and store
them accordingly. In the next phase the Unpacking task will be
completed. In that part we are taking the 16-bit BCD number then
break it into 4 digits. Then store them into given location.
Address Data

… …

8040 12

8041 23

8042 42

8043 55

8044 10

8045 99

8046 35

8047 45

8048 76

8049 81

… …

Input:-
Flow Diagram
PROGRAM :-

Address HEX Labels Mnemonics Comments


Codes

8000 21 LXI H 8040H Initialize pointer with the first


location of IN-BUFFER

8001 40

8002 80

8003 0E MVI C 0AH Initialize counter with the number


of data to be add

8004 0A

8005 AF XRA A Clear the contents of the


accumulator and the Reg. B

8006 47 MOV B, A

8007 CD NEXTBCD CALLBCDAD A subroutine that add BCD


: D numbers

8008 23

8009 80

800A 23 INX H Go to next location

800B 0D DCR C Decrement count until 0 is reached

800C C2 JNZNEXTBCD

800D 07

800E 08

800F 32 STA 8060 H Store the result byte available in A

8010 60

8011 80

8012 57 MOV D, A Temporarily D = A

8013 78 MOV A, B Putting B in A


Address HEX Labels Mnemonics Comments
Codes

8014 32 STA 8061 H To store it in OUT-BUFFER

8015 61

8016 80

8017 7A MOV A, D Restoring back A

8018 21 LXI H 8062H Initialize pointer with the last


location of OUT-BUFFER

8019 62

801A 80

801B CD CALLUNPAK A subroutine that separates two


nibbles from a packed BCD
number

801C 2E

801D 80

801E 78 MOV A, B Copy B to A

801F CD CALL UNPAK A subroutine that separates two


nibbles from a packed BCD
number

8020 2E

8021 80

8022 76 HLT Terminate the program

8023 86 BCDADD: ADD M Add the contents of the memory


location specified by the HL
register pair with A

8024 27 DAA Decimal adjust accumulator

8025 D0 RNC If no carry is produced then return


to the calling program

8026 57 MOV D, A Copy A to D

8027 78 MOV A, B If a carry is produced then adjust


the contents of the Reg. B
Address HEX Labels Mnemonics Comments
Codes

8028 C6 ADI 01H

8029 01

802A 27 DAA

802B 47 MOV B, A

802C 7A MOV A, D Copy D to A

802D C9 RET Return to the calling program

802E 57 UNPAK: MOV D, A Copy A to D

802F E6 ANI 0FH Mask off the most significant four


bits

8030 0F

8031 77 MOV M, A Writing A to the memory

8032 23 INX H Go to next location

8033 7A MOV A, D Copy D to A

8034 E6 ANI F0H Mask off the least significant four


bits

8035 F0

8036 0F RRC Rotate accumulator 4 times to get


the first BCD digit

8037 0F RRC

8038 0F RRC

8039 0F RRC

803A 77 MOV M, A Writing A to the memory

803B 23 INX H Go to next location

803C C9 RET Return to the calling program


Output:-

Address Data

… …

8060 78

8061 04

8062 08

8063 07

8064 04

8065 00

… …
Classification:-
Sr.no Instruction Types

1 LXI H 8040H Load register pair


immediate

2 MVI Move immediate 8-bit

3 XRA Exclusive OR register or


memory with
accumulator

4 MOV Copy from source to


destination.

5 CALL Call unconditionally

6 INX Increment register pair by 1

7 DCR Decrement register or


memory by 1

8 STA Store accumulator direct

9 HLT Halt

10 ADD Add register or memory to


accumulator

11 ADI Add immediate to


accumulator

12 ANI Logical AND immediate


with accumulator

13 RRC Rotate accumulator right

14 RET Return unconditionally


Subroutines :-
A subroutine is a sequence of program instructions that
perform a specific task, packaged as a unit. This unit can then
be used in programs wherever that particular task has to be
performed. A subroutine is often coded so that it can be
started (called) several times and from several places during
one execution of the program , including from other
subroutines, and then branch back (return) to the next
instruction after the call, once the subroutine’s task is done .It
is implemented by using Call and Return instructions.
Subroutine:-
ADD M
DAA
RNC
MOV D, A
MOV A, B
ADI 01 H
DAA
MOV B, A
MOV A, D
RET

CONCLUSION:-
The above program taught us how to write an assembly
language code to find the ten packed BCD numbers It helped
us to learn more about different types of instructions that we
can use in our program that are present in 8085 and also how
to use a subroutine in assembly language program to perform
a specific task.

These are essential skills for anyone interested in working


with microprocessors and embedded system as well as
programming in assembly language or low level language. By
practicing and developing the skills you can gain a deeper
understanding of how computers and microprocessors work
and how to develop efficient and effective programs for
specific applications.

You might also like