Write ALP to Find Sum of Series of BCD Numbers
A
MICRO PROJECT
ON
“Write an ALP to Find Sum of Series of BCD
Numbers”
Under The Guidance
Mr A.P.Patil
DEPARTMENT OF COMPUTER ENGINEERING
K.P. PATIL INSTITUTE OF TECHNOLOGY (POLY)
MUDAL-416209
Academic Year
2023-24
KPIT Page 1
Write ALP to Find Sum of Series of BCD Numbers
K. P. PATIL INSTITUTE OF TECHNOLOGY, MUDAL.
MICRO PROJECT ON
“Write an ALP to Find Sum of Series of BCD
Numbers”
CLASS: FOURTH SEMESTER
COURSE: COMPUTER ENGINEERING
SR.NO. STUDENT NAME ENR.NO ROLL. NO
1 SHRADDHA V. MANDAVE 2216610074 22
2 SAI A. POWAR 2216610075 23
3 JANHAVI V. MANDAVKAR 2216610076 24
Signature of Signature of Signature of
Teacher Guide Head of Department Principal
KPIT Page 2
Write ALP to Find Sum of Series of BCD Numbers
INTRODUCTION:
Welcome to the micro-project on finding the sum of series of BCD numbers using
Assembly Language Programming (ALP). In this project, we will delve into the world
of low-level programming to accomplish a fundamental task: identifying the extreme
values within an array.
Assembly Language is a low-level programming language that closely resembles
machine code and allows direct control over the hardware. Despite its complexity and
intricacies, mastering Assembly Language can offer a deep understanding of computer
architecture and system operations.
Our objective is to write efficient Assembly Language code to find the sum of series
of BCD numbers. This task may seem straightforward, but it presents an excellent
opportunity to explore various programming techniques, such as iteration, conditional
statements, and data manipulation, in the context of Assembly Language.
Throughout this micro project, we will break down the problem into manageable
steps, discussing concepts, strategies, and code implementation in Assembly
Language. By the end, you will have a solid understanding of how to tackle similar
challenges and a deeper appreciation for the intricacies of low-level programming.
So, let's embark on this journey into the realm of Assembly Language programming
and discover how to efficiently find the sum of series of BCD numbers!
KPIT Page 3
Write ALP to Find Sum of Series of BCD Numbers
Problem – Write a program to find the sum of a series where series
starts from 3001 memory address and count of series is at 3000 memory
address where starting address of the given program is 2000 store result
into 4000 memory address. Example
Algorithm –
1. Move 00 to register B immediately for carry
2. Load the data of memory [3000] into H immediately
3. Move value of memory into register C
4. Decrease C by 1
5. Increase H-L pair by 1
6. Move value of memory into accumulator
7. Increase H-L pair by 1
8. Add value of memory with accumulator
9. Jump if no carry to step 11
10. Increase value of register B by one
11. Decrease register C by 1
12. Jump if not zero to step-7
13. Store content of accumulator into memory [4000] (result)
14. Move content of register B into accumulator
15. Store content of accumulator into memory [4001] (carry)
16. Stop
KPIT Page 4
Write ALP to Find Sum of Series of BCD Numbers
Program –
KPIT Page 5
Write ALP to Find Sum of Series of BCD Numbers
Explanation –
Registers A, B, C, H are used for general purpose.
1. MVI is used to load an 8-bit given register immediately (2
Byte instruction)
2. LXI is used to load register pair immediately using 16-bit
address (3 Byte instruction)
3. MOV is used to transfer the data from accumulator to
register(any) or register(any) to accumulator (1 Byte)
4. RAR is used to shift ‘A’ right with carry (1 Byte instruction)
5. STA is used to store data from accumulator into memory
direct using 16-bit address (3 Byte instruction)
6. INR is used to increase given register by 1 (1 Byte instruction)
7. JNC is used to jump to the given step if there is no carry (3
Byte instruction)
8. JNZ is used to jump to the given step if there is not zero (3
Byte instruction)
9. DCR is used to decrease given register by 1 (1 Byte
instruction)
10. INX is used to increase register pair by 1 (1 Byte
instruction)
11. ADD is used to add value of accumulator with the given
value (1 Byte instruction)
12. HLT is used to halt the program
Advantages of finding the sum:
It is a fundamental operation that is widely used in
mathematics, physics, and engineering.
It can help reveal the patterns and relationships between
numbers in a sequence, such as their ratios or differences.
It can be easily calculated using a formula or a loop in a
programming language, making it a versatile tool for solving
problems.
Disadvantages of finding the sum:
It may not be practical for very large series, as the result can
quickly become very large and difficult to represent or
KPIT Page 6
Write ALP to Find Sum of Series of BCD Numbers
manipulate.
It may require specialized knowledge or software to handle
complex patterns or infinite series, leading to computational
complexity and potential errors.
It may not be useful in certain contexts where addition is not
relevant or meaningful, such as in analyzing the frequencies
of letters in a text.
Addition of 10 BCD numbers in Series
.MODEL SMALL
.STACK 100
.DATA
ARRAY DB 1,2,3,4,5,6,7,8,9,10
SUM_LSB DB 0
SUM_MSB DB 0
.CODE
MOV AX , @DATA ; Intializing data segment
MOV DS , AX
MOV CX , 10 ; Initialize byte counter
MOV SI , OFFSET ARRAY ; INITIALIZE MEMORY POINTER
UP:
MOV AL , [SI] ; Read byte from memory
ADD SUM_LSB , AL ; Add with sum
DAA
JNC NEXT
INC SUM_MSB
NEXT:
INC SI ; Increment memory pointer
LOOP UP ; Decrement byte counter
; If byte counter==0 then exit
; else read next number
MOV DL , SUM_MSB
MOV AH , 2
INT 21H
MOV DL , SUM_LSB
MOV AH , 2
INT 21H
MOV AH , 4CH
INT 21H
END
KPIT Page 7
Write ALP to Find Sum of Series of BCD Numbers
Output:-
KPIT Page 8
Write ALP to Find Sum of Series of BCD Numbers
CONCLUSION :
In this micro-project, we ventured into the realm of Assembly Language Programming
(ALP) to tackle the task of finding the sum of series of BCD numbers. Through
diligent exploration and implementation, we've successfully developed efficient ALP
code to accomplish this fundamental task.
Throughout our journey, we've encountered challenges and complexities inherent in
low-level programming. From managing memory access to implementing iterative
algorithms, we've delved into the intricacies of Assembly Language to produce robust
solutions.
By breaking down the problem into manageable steps, discussing key concepts, and
exploring various programming techniques, we've gained valuable insights into the
world of ALP. We've witnessed firsthand how Assembly Language offers direct
control over hardware resources, providing a deep understanding of computer
architecture and system operations.
As we conclude this micro-project, we've not only achieved our objective of finding
the sum of series of BCD numbers.but also expanded our proficiency in Assembly
Language programming. Armed with this newfound knowledge and experience, we're
better equipped to tackle similar challenges and explore further possibilities in the
realm of low-level programming.
I hope this micro-project has been both enlightening and rewarding, offering a
glimpse into the power and intricacies of Assembly Language Programming. Thank
you for joining me on this journey, and I encourage you to continue exploring and
honing your skills in the fascinating world of ALP.
KPIT Page 9
Write ALP to Find Sum of Series of BCD Numbers
REFERENCE: -
1. http://www.plantation-productions.com/Webster/
2. https://www.tutorialspoint.com/assembly_programming/index.htm
KPIT Page 10