Assembly-Guidebook

Factorial Of A Number

ORG 100h
.DATA 
    ANS DB ?         
    IP DB 5 ; Replace 5 by the number whose factorial you want to calculate
.CODE   
    MAIN PROC
        MOV AX, @DATA
        MOV DS, AX
        MOV AL, IP
        MOV CL, IP
        SUB CL, 1  
        MOV BL, AL
        SUB BL, 1
      L: 
        MUL BL
        SUB BL, 1
        LOOP L
        MOV ANS, AL
    END MAIN
RET