Professional Documents
Culture Documents
"Calculate Factorial Using ALP": Maharashtra Board of Technical Education, Mumbai
"Calculate Factorial Using ALP": Maharashtra Board of Technical Education, Mumbai
This report is a partial fulfillment of subject MIC(22415) for the award of the
Diploma in Computer Technology , By MSBTE, Mumbai.
HOD PRINCIPAL
1
INDEX
Sr.No. Title Page No
1. Abstract 3
2. Introduction 4
4. Conclusion 13
5. Acknowledgement 14
6 References 15
2
Abstract
This micro project of subject MIC Computer Technology course at Government Polytechnic
Solapur, dives into the world of 8086 assembly language using emu8086 software. We create a
program to calculate factorials. Imagine entering a non-negative integer - our program, coded in
calculating the factorial. Each loop iteration leverages the efficiency of 8086 instructions. Finally,
the program proudly displays the result! This project showcases emu8086's power in simulating
8086 assembly language. It demonstrates how complex math like factorials translates into
instructions the processor directly executes. More importantly, it serves as a valuable stepping
computer architecture
3
Introduction
This micro project tackles calculating factorials by merging two powerful tools: Algorithm Logic
Programs (ALPs) and 8086 assembly language. Our goal is to design a program that finds the
factorial of a number entered by the user, ensuring it's non-negative. The project unfolds in two
stages. First, we'll develop an ALP, a blueprint for the calculation logic. This ALP is hardware and
software agnostic, focusing purely on the steps needed to find the factorial. In the second stage,
we'll take the ALP logic and translate it into the language of 8086 assembly language. This code
will be designed to run on emu8086 software, a program that acts like a virtual 8086
clarifies the core concepts, while the emu8086 implementation showcases how those concepts
translate into instructions the computer can directly execute. This project serves as a valuable
language programming.
4
3.1 Problem Statement
This project defines an ALP (Algorithm Logic Program) to calculate factorials. Find factorial
of non-negative integer number. The ALP logic, independent of hardware, utilizes a loop for
iterative calculations. This ALP serves as the foundation for translating the process into 8086
5
3.2 Algorithm
1. Start.
7. Loop until counter cl is less than or equal to the number (cl<= num).
• Multiply the current factorial value fact with the loop counter cl.
9. Stop.
6
3.3 Flowchart
Image 1.1
7
3.4 Initialization & Instruction Explanations
1. Data Segment:
a. num db 04h: Declares a byte variable num with initial value 04h.
b. Fact dw 00h: Declares a word variable Fact to store the factorial result, initialized
to 00h.
a. mov ax, data: Loads the address of the data segment into AX.
b. mov ds, ax: Sets the DS register to point to the data segment.
1. Code segment:
a. mov ax, data - Moves the address of the data segment into register AX.
8
b. int 21h: Terminates the execution of the program.
4. mul: Multiplies two operands and stores the result in a specific register pair.
a. mul bl - Multiplies the value in AX with the value in BL and stores the result in
DX:AX.
9
3.5 Code
assume cs:code,ds:data
data segment ; Define the data segment and declare the variables result and fact
fact db 05h
result dw ?
data ends
code segment ;Define the code segment
start:mov ax,data
mov ds,ax
mov al,fact ;Load the number into the al register and the loop counter cl
mov cl,al
dec cl ;Decrement the loop counter
call disp ;Call the Fact procedure
mov ah,4ch
int 21h ;Termination the program
disp proc near ;Procedure to calculate the factorial of the number
mov bl,al ;Move the number into the BL register
up:dec bl ;Decrement the loop counter
mul bl ;Multiply the current factorial value with the loop counter
loop up
mov result,ax ;Update the factorial value
ret
endp
end start
code ends ;End of the program
10
3.6 Output
Image 3.1
Image 3.2
11
Image 3.3
Image 3.4
Image 3.5
12
Conclusion
This microproject explored calculating factorials using a clever combination: ALPs and
integer.
The project unfolded in two steps. First, an ALP - a hardware-neutral blueprint - outlined the
Then, we translated this ALP logic into 8086 assembly language for emu8086 software, which
acts like an 8086 microprocessor. This implementation utilized the efficiency of assembly
By combining these approaches, we gained valuable insights. The ALP clarified the algorithm,
while the emu8086 code showed how concepts translate into processor instructions. This
project effectively solidified our grasp of both algorithm design and assembly
language programming.
13
Acknowledgement
This microproject, completed for the Computer Technology course in MIC (Microprocessor
using ALP. While not explicitly implemented here, an Assembly Language Program (ALP)
initially defined the core logic for calculating factorials, independent of any specific hardware
or software. The resulting assembly language code utilized procedures to promote code clarity
and reusability. The Fact procedure encapsulated the steps to find the factorial. Essential
operators like mov, dec, and mul were instrumental in data manipulation and calculations.
emu8086 software provided the platform to run and test the code. It mimicked the execution
of the program on an 8086 microprocessor, eliminating the need for a physical chip.
14
Reference
https://www.tutorialspoint.com/index.htm
https://en.m.wikipedia.org/wiki/Assembly_language
https://www.geeksforgeeks.org/
15