08 Lab Manual - Program To Find Out Factorial of A Number
08 Lab Manual - Program To Find Out Factorial of A Number
EXPERIMENT NO: 08
Background:
Procedures are a group of instructions stored as a separate program in memory and it is called
from the main program whenever required. The type of procedure depends on where the
procedures are stored in memory. If it is in the same code segment as that of the main program
then it is a near procedure otherwise it is a far procedure.
Near Call: A call to a procedure within the current code segment (the segment currently pointed
to by the CS register), sometimes referred to as an intra-segment call.
Syntax
Name PROC NEAR
<Instructions>
Name ENDP
Pre-Lab Task:
Required interrupt functions:-
Interrupt No.
INT 21H
Function
Description
AH= 09H
AH= 4CH
AH = 02H
Instruction
Description
MUL
ROR
Rotate All Bits of Operand Right: This instruction rotates all bits in
a specified byte or word to the right, some number of bit positions.
LSB is placed as a new MSB and a new CF.
Program Template:
DATA SEGMENT
; Declare required HEX_CHART and NUMBER (i.e. input)
DATA ENDS
CODE SEGMENT
ASSUME CS: CODE, DS: DATA
MOV AX, DATA
MOV DS, AX ; Initialization of DS register
; To terminate a program
In-Lab Task:
Students will execute a complete program as per following algorithm and will write down the
Result/Output.
Algorithm:
1. Define an input NUMBER in Data segment, for finding out factorial.
2. Define Counter = NUMBER.
3. If the NUMBER
= 0, then
Factorial is 1, display the result and terminate a program.
Else
Decrement the number by 1, multiply with original number and repeat this
Step till Counter becomes 0.
4. Call Near Procedure to display the result character by character.
Result/Output: - ____________________________________________________
__________________________________________________________________
__________________________________________________________________
Post-Lab Task:
Outcomes:
1. The concept of factorial of a number
2. The Concept of a Procedure.
Reference Books:1. John E. Uffenbeck , The 8086/ 8088 Family: Design, Programming and Interfacing, Pearson.
2. Douglas V. Hall Microprocessor and Interfacing Programming and Hardware Pearson.
3. Peter Abel, IBM PC Assembly Language and Programming Pearson.
Name of Teacher
Sign