Write Assembly Program to Calculate the Factorial

Calculate the Factorial

In this program, we are learning how to write an Assembly Program to Calculate the Factorial.

Check more about How to Calculate Fibonacci series using Assembly Level Programming.

title"to print the factorial of a given number"
.model small
 val dw 4
 str db"the factorial is:$"

prnt macro
 mov dl,ah
 mov dh,al
 mov ah,02h
 int 21h
 mov dl,dh
 mov ah,02h
 int 21h
main proc
 mov ax,@data
 mov ds,ax
 mov dx,offset str
 mov ah,09h
 int 21h
 mov cx,val
 mov ax,1
 mul cx
 loop top
 mov dx,0
 mov bx,100
 div bx

 add ax,3030h
 push dx
 pop ax
 add ax,3030h
 mov ah,4ch
 int 21h
 main endp
 end main


Tutsmaster.org provides tutorials related to tech and programmings. We are also setting up a community for the users and students.