Free Electronic Circuits & 8085 projects

Electronic projects with circuit diagram and 8085 microprocessor projects.

Find the factorial of a number

Published on Nov 17 2009 // Trainees

Statement: Program to calculate the factorial of a number between 0 to 8

Source program :

  • LXI SP, 27FFH ; Initialize stack pointer
  • LDA 2200H ; Get the number
  • CPI 02H ; Check if number is greater than 1
  • JC LAST
  • MVI D, 00H ; Load number as a result
  • MOV E, A
  • DCR A
  • MOV C,A ; Load counter one less than number
  • CALL FACTO ; Call subroutine FACTO
  • XCHG ; Get the result in HL
  • SHLD 2201H ; Store result in the memory
  • JMP END
  • LAST: LXI H, 000lH ; Store result = 01
  • END: SHLD 2201H
  • HLT

Subroutine Program:

  • FACTO:LXI H, 0000H
  • MOV B, C ; Load counter
  • BACK: DAD D
  • DCR B
  • JNZ BACK ; Multiply by successive addition
  • XCHG ; Store result in DE
  • DCR C ; Decrement counter
  • CNZ FACTO ; Call subroutine FACTO
  • RET ; Return to main program

Flowchart for program

43-Find the factorial of a number

Related Programs (Click down)

Calculate the sum of series of numbers

Unpack a BCD number

Execution format of instructions

Right shift bit of data