# 8085 program to generate Fibonacci series

**Problem –** Write an assembly language program in 8085 microprocessor to generate Fibonacci series.

**Example –** Assume Fibonacci series is stored at starting memory location 3050.

**Note –** This program generates Fibonacci series in hexadecimal numbers.

**Algorithm –**

- Initialize register H with 30 and register L with 50, so that indirect memory M points to memory location 3050.
- Initialize register B with 00, register C with 08 and register D with 01.
- Move the content of B in M.
- Increment M by 1 so that M points to next memory location.
- Move the content of D in M.
- Move the content of B in accumulator A.
- Add the content of D in A.
- Move the content of D in B.
- Move the content of A in D.
- Increment M by 1 so that M points to next memory location.
- Move the content of A in M.
- Decrements C by 1.
- Jump to memory location 200C if ZF = 0 otherwise Halt the program.

**Program –**

MEMORY ADDRESS | MNEMONICS | COMMENT |
---|---|---|

2000 | LXI H, 3050 | H <- 30, L <- 50 |

2003 | MVI C, 08 | C <- 08 |

2005 | MVI B, 00 | B <- 00 |

2007 | MVI D, 01 | D <- 01 |

2009 | MOV M, B | M <- B |

200A | INX H | M <- M + 01 |

200B | MOV M, D | M <- D |

200C | MOV A, B | A <- B |

200C | ADD D | A <- A + D |

200E | MOV B, D | B <- D |

200F | MOV D, A | D <- A |

2010 | INX H | M <- M + 01 |

2011 | MOV M, A | M <- A |

2012 | DCR C | C <- C – 01 |

2013 | JNZ 200C | Jump if ZF = 0 |

2016 | HLT | END |

**Explanation –** Registers A, B, C, D, H, L are used for general purpose.

**LXI H 3050:**assigns 30 to H and 50 to L.**MVI B, 00:**assigns 00 to B.**MVI C, 08:**assigns 08 to C.**MVI D, 01:**assigns 01 to D.**MOV M, B:**moves the content of B in M.**INX H:**increment M by 1.**MOV M, D:**moves the content of D in M.**MOV A, B:**moves the content of B in A.**ADD D:**add the content of D and A. Store the result in A.**MOV B, D:**moves the content of D in B.**MOV D, A:**moves the content of A in D.**INX H:**increment M by 1.**MOV M, A:**moves the content of A in M.**DCR C:**decrements C by 1.**JNZ 200C:**jump to memory location 200C if ZF = 0.**HLT:**stops executing the program and halts any further execution.

## Recommended Posts:

- 8086 program to generate Fibonacci Sequence
- 8085 program to find the sum of a series
- 8085 program to find the sum of series of even numbers
- 8086 program to generate AP series of n numbers
- 8086 program to generate G.P. series of n numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to add two 8 bit numbers
- 8085 program to add two 16 bit numbers
- 8085 program to add 2-BCD numbers
- 8085 program to divide two 8 bit numbers
- 8085 program to swap two 8-bit numbers
- 8085 program to reverse 8 bit number
- 8085 program for Binary search
- 8085 program for pulse waveform

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.