8051 Assembly Program Code for finding Factorial of a Number - AT89C51 - Keil


The program is compiled in Keil for 8051 - AT89C51 in assembly language.

Program to find factorial of a number,

Flowchart:-


Program:-

ORG 0000H
MOV DPTR,#2000H
MOVX A,@DPTR
MOV R0,A
MOV R2,#00H
MOV R1,#01H
CJNE R0,#01H,CONTINUE
SJMP RESULT
CONTINUE : JC RESULT
MOV R1,00H
DEC R0
LOOP : MOV A,R1
MOV B,R0
MUL AB
MOV R1,A
MOV R3.B
MOV A,R0
MOV B.R2
MUL AB
ADD A, R3
MOV R2,A
DJNZ R0,LOOP
RESULT : INC DPTR
MOV A,R2
MOVX@DPTR,A
MOV A,R1
INC DPTR
MOVX @DPTR,A
SJMP $
END


Output:-



For more ASM programs - click here

Popular posts from this blog

Mini Militia Chat Codes - Shortforms

8051 Assembly Program Code for Sorting in Ascending Order - Keil -AT89C51