Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

EXPERIMENT - II

FACTORIAL OF A NUMBER

March 21, 2020

ADITHYA D RAJAGOPAL
ROLL NO : 9
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
COLLEGE OF ENGINEERING TRIVANDRUM
TVE17CS009 ADITHYA D RAJAGOPAL

A IM
To develop an assembly language program to find the factorial of a number.

Page 1 of 5
TVE17CS009 ADITHYA D RAJAGOPAL

A LGORITHM

Algorithm 1 Factorial of a number


1: Start
2: Read the number (n).
3: f act = 1
4: for i = 1 to n do
5: f act = f ac t ∗ i
6: end for
7: Print the result ( f ac t ).
8: Stop

Page 2 of 5
TVE17CS009 ADITHYA D RAJAGOPAL

S OURCE C ODE

data segment
num db 5h
r e s u l t db ?
data ends

code segment
assume cs : code , ds : data
start :
mov ax , data
mov ds , ax
mov cl ,num
mov al , 1

up : mul c l
dec c l
jnz up

mov r e s u l t , a l
mov ah , 4 ch
i n t 21h
code ends

end s t a r t

Page 3 of 5
TVE17CS009 ADITHYA D RAJAGOPAL

O UTPUT

Page 4 of 5
TVE17CS009 ADITHYA D RAJAGOPAL

R ESULT
Assembly language program for finding the factorial of a number has been developed and
verified using emu8086.

Page 5 of 5

You might also like