- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- 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
8085 Program to Check the fourth bit of a byte
In this program, we will see how to check the 4th bit of an 8-bit number.
Problem Statement
Write 8085 Assembly language program to check whether the fourth bit of a byte is 0 or 1.When it is 0, store 00H at any specified location, and when it is 1, store FFH at the specified location.
Discussion
We are considering the 8-bit number, and storing 00H or FFH by checking the 4th bit on the number from left.
The logic behind it is very simple. We are just performing bit-wise and operation on the given data with 08H. If the result is non-zero, then the 4th bit is 1, otherwise, it is 0.
Input
first input
Address | Data |
---|---|
. . . | . . . |
8000 | AF |
. . . | . . . |
second input
Address | Data |
---|---|
. . . | . . . |
8000 | B3 |
. . . | . . . |
Flow Diagram
Program
Address | HEX Codes | Labels | Mnemonics | Comments | |
---|---|---|---|---|---|
F000 | 21, 00, 80 | LXI H,8000H | Load address to get data | ||
F003 | 7E | MOV A, M | Load memory content to Acc | ||
F004 | 21, 50, 80 | LXI H,8050H | Load the destination address | ||
F007 | E6, 08 | ANI 08H | AND acc with 0000 1000 | ||
F009 | C2,11, F0 | JNZ N ONZ | When Z flag is set, save 00H | ||
F00C | 36,00 | MVI M, 00H | Save FFH when Z is not set | ||
F00E | C3,13, F0 | JMP END | Jump to stop the program | ||
F011 | 36, FF | NONZ | MVI M, FFH | Save 00H | |
F013 | 76 | END | HLT | Terminate the program |
Output
first output
Address | Data |
---|---|
. . . | . . . |
8050 | FF |
. . . | . . . |
second output
Address | Data |
---|---|
. . . | . . . |
8050 | 00 |
. . . | . . . |
Advertisements