; factorial of a given number
; input:R0
; output: BA
ORG 0H
MAIN:
MOV R0,#05 ;Input number
MOV A,R0
LCALL FACT
SJMP $
FACT: CJNE R0,#01,loop
RET
loop: DEC R0
MOV B,R0
MUL AB
LJMP FACT
END
Related topics:
8051 Program - smallest element in an array | 8051 Program - largest element in an array | 8051 Program - fibonacci series | 8051 Program - lcm of two numbers | 8051 Program - gcf of two numbers | 8051 Program - memory subroutines | 8051 Program - math subroutines | 8051 Program - conversion subroutines
List of topics: 8051
This comment has been removed by the author.
ReplyDeleteit is not working for 6!?
ReplyDeletegive code for n > 5.