- Related Questions & Answers
- 8085 program to find the sum of series of even numbers
- 8085 program to find the sum of a series
- 8086 program to find sum of Even numbers in a given series
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to find the sum of first n natural numbers
- 8086 program to find sum of odd numbers in a given series
- Program to find sum of harmonic series in C++
- 8085 program to count total odd numbers in series of 10 numbers
- Sum of squares of the first n even numbers in C Program
- C++ Program to find sum of even factors of a number?
- Java program to find the sum of n natural numbers
- To find sum of even factors of a number in C++ Program?
- Python Program for Find sum of even factors of a number
- Find sum of even factors of a number in Python Program
- 8085 program to find sum of digits of 8 bit number

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

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

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.

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.

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

| . . . |

F100 | 08 |

F101 | 0C |

F102 | 0F |

F103 | 0A |

F104 | 0B |

F105 | 02 |

F106 | 03 |

F107 | 05 |

F108 | 08 |

| . . . |

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 |

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

| . . . |

F150 | 20 |

| . . . |

Advertisements