Adam’s Engineering College, Paloncha ECE Department –MPI LAB Experiment No.: 11 Page 1 of 3
Year : III/IV B.Tech II Semester
FACTORIAL OF A GIVEN NUMBER
Aim: - To write an assembly language program to find the factorial of the given number. Registers: - Al, BL Description: - Factorial of a given number is found and the result is stored in the pointer. Ports:- None. DATA SEGMENT X DB ? FACT DB 2 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA START:
MOV AL, 01 MOV BL, X LOOK: MUL BL DEC BL JNZ LOOK MOV FACT, AL CODE ENDS END START
Lab in-charge
HOD, ECE
Adam’s Engineering College, Paloncha ECE Department –MPI LAB Experiment No.: 11 Page 2 of 3
Year : III/IV B.Tech II Semester
(2) DATA SEGMENT X DB ? FACT DB 2 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA START:
MOV AL, 01 MOV BL, X LOOK: JZ NEXT MUL BL JNZ LOOK NEXT: MOV FACT, AL CODE ENDS END START
(3) DATA SEGMENT X DB ? FACT DB 2 DUP(0) DATA ENDS CODE SEGMENT ASSUME CS: CODE, DS: DATA, ES: DATA START:
LOOK: Lab in-charge
MOV AL, 01 MOV CL, X JZ NEXT
HOD, ECE
Adam’s Engineering College, Paloncha ECE Department –MPI LAB Experiment No.: 11 Page 3 of 3
Year : III/IV B.Tech II Semester
MUL CL LOOP LOOK NEXT: MOV FACT, AL CODE ENDS END START Result: Factorial of a given number is obtained.
Lab in-charge
HOD, ECE