- 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

In this program we will see how to count number of odd numbers in a block of elements.

Write 8085 Assembly language program to count number of odd numbers in a block of data, where the block size is 10D. The block is starting from location 8000H.

The Odd Even checking is very simple. we can determine one number is odd or even by checking only the LSb. When LSb is 1, the number is odd, otherwise it is even. In this program we are taking a number from memory and then ANDing 01H with it. if the result is nonzero, then the number is odd, otherwise it is even.

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

| . . . |

8000 | DA |

8001 | 53 |

8002 | 26 |

8003 | 41 |

8004 | 17 |

8005 | AC |

8006 | 78 |

8007 | D8 |

8008 | 9C |

8009 | 3F |

| . . . |

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

F000 | 21, 00, 80 | | LXI H,8000H | Point to the starting byte |

F003 | 0E, 0A | | MVI C,0AH | Initialize count to 0AH |

F005 | 06, 00 | | MVI B, 00H | Clear B register |

F007 | 7E | LOOP | MOV A,M | Load the item from memory |

F008 | E6, 01 | | ANI 01H | AND A with 01H |

F00A | CA, 0E, F0 | | JZ SKIP | If Z = 0, jump to skip |

F00D | 04 | | INR B | Increase B by 1 |

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

F00F | 0D | | DCR C | Decrease C by 1 |

F010 | C2, 07, F0 | | JNZ LOOP | if Z = 0, go to loop |

F013 | 78 | | MOV A,B | Load the count to A |

F014 | 32, 50, 80 | | STA 8050H | Store the result at 8050H |

F017 | 76 | | HLT | Terminate the program |

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

| . . . |

8050 | 04 |

| . . . |

- Related Questions & Answers
- 8085 program to count total even numbers in series of 10 numbers
- 8085 program to find maximum and minimum of 10 numbers
- 8085 program to find the sum of series of even numbers
- 8086 program to find sum of odd numbers in a given series
- Python program to Count Even and Odd numbers in a List
- Program to count odd numbers in an interval range using Python
- Sum of the series 1, 3, 6, 10… (Triangular Numbers) in C++
- 8086 program to generate AP series of n numbers
- 8086 program to generate G.P. series of n numbers
- Count numbers which are divisible by all the numbers from 2 to 10 in C++
- Program to find count of numbers having odd number of divisors in given range in C++
- 8085 program to add 2-BCD numbers
- 8085 program to subtract two BCD numbers
- Program to count total number of set bits of all numbers in range 0 to n in Python
- 8085 program to add numbers in an array

Advertisements