- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

# 8085 program to find the sum of series of even numbers

In this program we will see how to find the sum of all even numbers.

## Problem Statement

Write 8085 Assembly language program to find sum of all even numbers stored in an array. The size of the array is stored at location F100; the numbers are stored from memory location F101 onwards. The result will be stored at F150.

## Discussion

To check whether a number is odd or even, we can to AND operation. If a number is odd, then it will contain 1 as LSb, for even LSb will be 0. So after AND operation if the result is 0, then it is even. By using loop, we are adding the numbers only when it is even.

## Input

Address | Data |
---|---|

| . . . |

F100 | 08 |

F101 | 0C |

F102 | 0F |

F103 | 0A |

F104 | 0B |

F105 | 02 |

F106 | 03 |

F107 | 05 |

F108 | 08 |

| . . . |

## Flow Diagram

## Program

Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|

F000 | 3A, 00, F1 | | LDA F100 | Load number of elements into A |

F003 | 4F | | MOV C,A | Load counter |

F004 | 06, 00 | | MVI B,00 | Clear B to store Sum |

F006 | 21, 01, F1 | | LXI H,F101 | Initialize pointer to take numbers |

F009 | 7E | LOOP | MOV A,M | Take number from memory |

F00A | E6, 01 | | ANI 01 | Mask bits to check even or not |

F00C | C2, 12, F0 | | JNZ SKIP | If it is not zero, skip it |

F00F | 78 | | MOV A,B | Load B to A |

F010 | 86 | | ADD M | Add A and memory element |

F011 | 47 | | MOV B,A | Store A to B |

F012 | 23 | SKIP | INX H | Point to next location |

F013 | 0D | | DCR C | Decrease Counter |

F014 | C2, 09, F0 | | JNZ LOOP | Until Z = 1, jump to LOOP |

F017 | 32, 50, F1 | | STA F150 | Store result |

F020 | 76 | | HLT | Terminate program |

## Output

Address | Data |
---|---|

| . . . |

F150 | 20 |

| . . . |

- Related Questions & Answers
- 8085 program to find the sum of a series
- 8085 program to count total even numbers in series of 10 numbers
- 8086 program to find sum of Even numbers in a given series
- 8085 program to find the sum of first n natural numbers
- Java Program to Find Even Sum of Fibonacci Series till number N
- 8085 program to count total odd numbers in series of 10 numbers
- Python program to find the sum of sine series
- 8086 program to find sum of odd numbers in a given series
- Sum of squares of the first n even numbers in C Program
- C program to find the sum of arithmetic progression series
- C++ Program to find sum of even factors of a number?
- Java Program to Find sum of even factors of a number
- 8085 program to find sum of digits of 8 bit number
- 8085 program to sum of two 8 bit numbers without carry
- Program to find sum of harmonic series in C++

Advertisements