0% found this document useful (0 votes)
312 views

Factorial of 8 Bit Number

This document provides an algorithm to calculate the factorial of a number between 0 and 8 using an 8085 microprocessor. It involves initializing the stack pointer and accumulator, checking if the number is greater than 1, loading a counter and result, calling a subroutine to calculate the factorial by multiplying the register pair HL by the value in B and decrementing the counter until it reaches zero, and storing and halting the final result.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
312 views

Factorial of 8 Bit Number

This document provides an algorithm to calculate the factorial of a number between 0 and 8 using an 8085 microprocessor. It involves initializing the stack pointer and accumulator, checking if the number is greater than 1, loading a counter and result, calling a subroutine to calculate the factorial by multiplying the register pair HL by the value in B and decrementing the counter until it reaches zero, and storing and halting the final result.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

FACTORIAL OF 8 BIT NUMBER

Aim:
To write an program to calculate the factorial of a number (between 0 to 8)

Apparatus required:
8085 microprocessor kit
(0-5V) power supply

Algorithm:
Step 1 : Intialize the stack pointer
Step 2 : Get the number in accumulator
Step 3 : Check for if the number is greater than 1. If no store the result otherwise go to
next step.
Step 4 : Load the counter and initialize result
Step 5 : Now factorial program in sub-routine is called.
Step 6 : In factorial,
initialize HL RP with 0.
Move the count value to B
Add HL content with Rp.
Decrement count (for multiplication)
Step 7 : Exchange content of Rp (DE) with HL.
Step 8 : Decrement counter (for factorial) till zero flag is set.
Step 9 : Store the result
Step 10 : Hault

You might also like