
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 Numbers in Range 3CH and 64H in an Array
Here we will see we can take all numbers which are in range 3CH and 64H from an array using 8085.
Problem Statement
Write 8085 program to take all numbers which are greater or equal to 3CH, and lesser than 64H from an array. 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 will take the numbers from memory. Then compare it with 3C. If the Carry flag is set, then it indicates that the number is less than 3C, so just skip it. otherwise compare it with 64H, now if the carry is not set it indicates that the number is larger, so skip it, else we will store the number into proper location.
Input
Address |
Data |
---|---|
… |
… |
8000 |
0A |
8001 |
89 |
8002 |
56 |
8003 |
23 |
8004 |
48 |
8005 |
3D |
8006 |
2A |
8007 |
4F |
8008 |
59 |
8009 |
67 |
800A |
72 |
… |
… |
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 |
FE, 3C |
|
CPI 3CH |
Compare it with 3C |
F00B |
DA, 15, F0 |
|
JC SKIP |
if number is small, SKIP it |
F00E |
FE, 64 |
|
CPI 64H |
else check with 64H |
F010 |
D2, 15, F0 |
|
JNC SKIP |
if number is large, skip it |
F013 |
12 |
|
STAX D |
Else store A into memory pointed by DE |
F014 |
13 |
|
INX D |
point to next location |
F015 |
0D |
SKIP |
DCR C |
decrease counter by 1 |
F016 |
C2, 07, F0 |
|
JNZ LOOP |
if c is not 0, jump to LOOP |
F019 |
76 |
|
HLT |
Terminate the program |
Output
Address |
Data |
---|---|
… |
… |
9000 |
56 |
9001 |
48 |
9002 |
3D |
9003 |
4F |
9004 |
59 |
… |
… |
Advertisements