- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
8086 program to find sum of odd numbers in a given series
In this program we will see how to add odd numbers in a given series
Problem Statement
Write 8086 Assembly language program to add the odd numbers stored in a given series starts from memory offset 501. The size of the series is stored at memory offset 500.
Discussion
To do this task we are initializing the Source Index (SI) register to the starting address of the series. We are also taking the series size into CL. The CL will be used as counter. To store add we are using AL register. Initially set AL to 0. To check the number is even or odd, we have used TEST 01 instruction. This instruction performs ANDing with the data and 01H. So if the LSB is 0, the total result will be 0, otherwise it will be 1. When LSB is 1, it indicates that the number is odd, then add them into one.
Input
Address | Data |
---|---|
… | … |
500 | 06 |
501 | CF |
502 | 24 |
503 | 2C |
504 | 51 |
505 | 3E |
506 | 45 |
… | … |
Flow Diagram
Program
Output
Address | Data |
---|---|
… | … |
600 | 65 |
… | … |
Also the carry flag will be 1, after doing this task
- Related Articles
- 8086 program to find sum of Even numbers in a given series
- PHP program to find the sum of odd numbers within a given range
- 8086 program to generate AP series of n numbers
- 8086 program to generate G.P. series of n numbers
- Program to find sum of first N odd numbers in Python
- Program to find the sum of first n odd numbers in Python
- 8085 program to count total odd numbers in series of 10 numbers
- 8086 program to find average of n numbers
- 8085 program to find the sum of series of even numbers
- C++ program to find numbers with K odd divisors in a given range
- PHP program to find the sum of cubes of natural numbers that are odd
- 8086 program to find the min value in a given array
- 8086 program to find sum of digits of 8 bit number
- Program to find count of numbers having odd number of divisors in given range in C++
- Golang Program to Print Odd Numbers Within a Given Range
