# 8085 program to find the sum of a series

**Problem –** Write a program to find the sum of a series where series starts from **3001** memory address and count of series is at **3000** memory address where starting address of the given program is **2000** store result into **4000** memory address.

**Example –**

**Algorithm –**

- Move 00 to register B immediately for carry
- Load the data of memory [3000] into H immediately
- Move value of memory into register C
- Decrease C by 1
- Increase H-L pair by 1
- Move value of memory into accumulator
- Increase H-L pair by 1
- Add value of memory with accumulator
- Jump if no carry to step 11
- Increase value of register B by one
- Decrease register C by 1
- Jump if not zero to step-7
- Store content of accumulator into memory [4000] (
**result**) - Move content of register B into accumulator
- Store content of accumulator into memory [4001] (
**carry**) - Stop

**Program –**

Memory | Mnemonics | Operands | Comment |
---|---|---|---|

2000 | MVI | B, 00 | [B] <- 00 |

2002 | LXI | H, [3000] | [H-L] <- [3000] |

2005 | MOV | C, M | [C] <- [M] |

2006 | DCR | C | [C] <- [C] – 1 |

2007 | INX | H | [H-L] <- [H-L] + 1 |

2008 | MOV | A, M | [A] <- [M] |

2009 | INX | H | [H-L] <- [H-L] + 1 |

200A | ADD | M | [A] <- [A] + [M] |

200B | JNC | 200F | jump if no carry |

200E | INR | B | [B] <- [B] + 1 |

200F | DCR | C | [C] <- [C] – 1 |

2010 | JNZ | 2009 | jump if not zero |

2013 | STA | [4000] | result |

2016 | MOV | A, B | [A] <- [B] |

2017 | STA | [4001] | carry |

201A | HLT | Stop |

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

**MVI**is used to load an 8-bit given register immediately (2 Byte instruction)**LXI**is used to load register pair immediately using 16-bit address (3 Byte instruction)**MOV**is used to transfer the data from accumulator to register(any) or register(any) to accumulator (1 Byte)**RAR**is used to shift ‘A’ right with carry (1 Byte instruction)**STA**is used to store data from accumulator into memory direct using 16-bit address (3 Byte instruction)**INR**is used to increase given register by 1 (1 Byte instruction)**JNC**is used to jump to the given step if their is no carry (3 Byte instruction)**JNZ**is used to jump to the given step if their is not zero (3 Byte instruction)**DCR**is used to decrease given register by 1 (1 Byte instruction)**INX**is used to increase register pair by 1 (1 Byte instruction)**ADD**is used to add value of accumulator with the given value (1 Byte instruction)**HLT**is used to halt the program

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: **DSA Self Paced**. Become industry ready at a student-friendly price.

## Recommended Posts:

- 8085 program to find the sum of series of even numbers
- 8085 program to generate Fibonacci series
- 8085 program to find the set bit of accumulator
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to count total odd numbers in series of 10 numbers
- 8085 program to find 1’s and 2’s complement of 16-bit number
- 8085 program to find the element that appears once
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to find square of a 8 bit number
- 8085 program to find nth power of a number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find the sum of first n natural numbers
- 8085 program to find the factorial of a number
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find smallest number between two numbers
- 8085 program to find minimum value of digit in the 8 bit number
- 8085 program to find square root of a number
- 8085 program to find maximum and minimum of 10 numbers
- 8085 program to find 2's complement of the contents of Flag Register

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.