8085-programming

Need help with a project? Trying to find a component? Post any general technical questions here.
Post Reply
happy_boy
Posts: 1
Joined: Mon Nov 09, 2009 8:31 am

8085-programming

Post by happy_boy » Mon Nov 09, 2009 8:36 am

how to generate factorial using 8085 instuctions?
means write a program for get factorial.

:)

henrygrik
Posts: 1
Joined: Fri Nov 20, 2009 12:37 pm

Re: 8085-programming

Post by henrygrik » Sat Nov 21, 2009 2:04 pm

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


I hope so this will help you.

Post Reply