Google Search

Thursday, October 13, 2011

FACTORIAL OF A GIVEN NUMBER To write an assembly language program to find the factorial of the given number.


FACTORIAL OF A GIVEN NUMBER

Aim: -   To write an assembly language program to find the factorial of the given number.
(1)
                      MOV AL, 01
                      MOV BL, X
  LOOK:       MUL BL
DEC BL
JNZ LOOK
                      MOV FACT, AL
END

(2)
                      MOV AL, 01
                      MOV BL, X
  LOOK:       JZ NEXT
MUL BL
JNZ LOOK
NEXT:        MOV FACT, AL
END

(3)
                      MOV AL, 01
                      MOV CL, X
  LOOK:       JZ NEXT
MUL CL
LOOP LOOK
  NEXT:        MOV FACT, AL         
                        END

Result: Factorial of a given number is obtained.

0 comments:

Post a Comment