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

**Flowchart/Algorithm**

**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 |

**Output**

*After Execution:*

3000H: 00H

3001H: 01H

3002H: 01H

3003H: 02H

3004H: 03H

3005H: 05H

3006H: 08H

3007H: 0DH

3008H: 15H

3009H: 22H

**Program Explanation**

- This program generates the Fibonacci series. The Fibonacci series is:

0 1 1 2 3 5 8 13 21 34 - In hexadecimal, it will be:

00 01 01 02 03 05 08 0D 15 22 - 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.
- The count is initialized in register D to display the numbers in series.
- Initialize register B to first number 00H and register C to second number 01H.
- Initialize H-L pair to point to memory location 3000H.
- Move the first two numbers from registers B and C to memory locations 3000H and 3001H.
- Add the two numbers and store the result as the first number.
- Increment H-L pair and move the result from accumulator to memory location.
- The next term is then computed by making the result equal to the previous number.
- The process is repeated until all the numbers are calculated.

Program for Generation of Fibonacci series