Search code examples
assemblyfactorial8085

an 8085 assembly language program to find the factorial of a number


i want to find factorial a number which i take memory first.(intel 8085)

edit: i'm beginner. i don't know how to write it's assembly codes.

pseudo code:

input n
fact = 1
loop:
..multiply fact by n
..decrement n
..test n
..jump if not zero to loop
output fact

Solution

  • In the first place, you'd better learn how to write 8085 if you expect to use it. Assembler, especially for old 8-bit microprocessors, is not something you can just take canned software and patch in.

    In the second place, exactly what are you using for numbers? The 8085 has an 8-bit bus and can use registers as 16 bits. If you're limited to 16-bit numbers, you can use a lookup table, as you can't represent 9! anyway.

    In the third place, if you're doing it the algorithmic way, you might want to first look into what you're using for multiplication. The 8085 does not have on-chip multiplication. (I once won a contest for multiple-precision multiplication and division using the Z80, which had some features the 8085 didn't have. In particular, I was able to use the alternate register bank to do some useful stuff.)