Program for Generation of Fibonacci series

Q. Write an 8085 program and draw a flow chart to Generate Fibonacci series.(8085 Microprocessor Program)



Address Mnemonics Operand Opcode Comments
2000 MVI D, 08H 16 Initialize counter to display numbers in series.
2001 08
2002 MVI B, 00H 06 Initialize reg. B to store the previous number.
2003 00
2004 MVI C, 01H 0E Initialize reg. C to store current number.
2005 01
2006 LXI H, 3000H 21 Initialize H-L pair to point to memory.
2007 00
2008 30
2009 MOV M, B 70 Move 00H from reg. B to memory.
200A INX H 23 Increment H-L pair.
200B MOV M, C 71 Move 01H from reg. C to memory.
200C MOV A, B 78 Move previous number from reg. B to reg. A.
200D ADD C 81 Add the two numbers.
200E MOV B, C 41 Assign current number to the previous number.
200F MOV C, A 4F Save result as the new current number.
2010 INX H 23 Increment H-L pair.
2011 MOV M, A 77 Move number from reg. A to memory.
2012 DCR D 15 Decrement counter.
2013 JNZ 200DH C2 Jump to address 200DH if the counter is not zero.
2014 0D
2015 20
2016 HLT 76 Halt


After Execution:

3000H: 00H

3001H: 01H

3002H: 01H

3003H: 02H

3004H: 03H

3005H: 05H

3006H: 08H

3007H: 0DH

3008H: 15H

3009H: 22H

Program Explanation

  1. This program generates the Fibonacci series. The Fibonacci series is:
          0   1   1   2   3   5   8   13   21   34
  2. In hexadecimal, it will be:
          00   01   01   02   03   05   08   0D   15   22
  3. The first two numbers of the series are 0 and 1. The third number is computed as 0 + 1 = 1, fourth number is 1+ 1 = 2, fifth number is 1 + 2 = 3 and so on.
  4. The count is initialized in register D to display the numbers in series.
  5. Initialize register B to first number 00H and register C to second number 01H.
  6. Initialize H-L pair to point to memory location 3000H.
  7. Move the first two numbers from registers B and C to memory locations 3000H and 3001H.
  8. Add the two numbers and store the result as the first number.
  9. Increment H-L pair and move the result from accumulator to memory location.
  10. The next term is then computed by making the result equal to the previous number.
  11. The process is repeated until all the numbers are calculated.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need fund to operate the site, and almost all of it comes from our online advertising.

Please add to your ad blocking whitelist or disable your adblocking software.