
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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 Take All Data Except 00h from an Array
Here we will see we can take all numbers which are not 00H from an array using 8085.
Problem Statement
Write 8085 program to take all numbers which are not 00H from array, and store them into different location. Numbers are stored at 8001 onwards, 8000 is holding the size of array, the results will be stored from 9000.
Discussion
To solve this problem, we are taking the number from memory, then perform OR operation on the number and 00H. If the zero flag is enabled, then we can understand that the number was 00, so we just ignore that. Otherwise we just store it into the correct location.
Input
Address |
Data |
---|---|
… |
… |
8000 |
0A |
8001 |
45 |
8002 |
21 |
8003 |
00 |
8004 |
FD |
8005 |
00 |
8006 |
00 |
8007 |
36 |
8008 |
98 |
8009 |
00 |
800A |
AC |
… |
… |
Flow Diagram
Program
Address |
HEX Codes |
Labels |
Mnemonics |
Comments |
---|---|---|---|---|
F000 |
21, 00, 80 |
|
LXI H,8000 |
Load the size of array |
F003 |
4E |
|
MOV C,M |
Store size into C |
F004 |
11, 00, 90 |
|
LXI D,9000 |
Load the destination address |
F007 |
23 |
LOOP |
INX H |
Point to next location |
F008 |
7E |
|
MOV A,M |
Take number from memory to A |
F009 |
F6, 00 |
|
ORI 00H |
OR A with 00H |
F00B |
CA, 10, F0 |
|
JZ SKIP |
if A is 0, then skip it |
F00E |
12 |
|
STAX D |
Else store A into memory pointed by DE |
F00F |
13 |
|
INX D |
point to next location |
F010 |
0D |
SKIP |
DCR C |
decrease counter by 1 |
F011 |
C2, 07, F0 |
|
JNZ LOOP |
if c is not 0, jump to LOOP |
F014 |
76 |
|
HLT |
Terminate the program |
Output
Address |
Data |
---|---|
… |
… |
9000 |
45 |
9001 |
21 |
9002 |
FD |
9003 |
36 |
9004 |
98 |
9005 |
AC |
… |
… |
Advertisements