- 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
8085 program to show masking of lower and higher nibbles of 8-bit number
In this program we will see how to lower and upper nibbles are masked in 8085.
Problem Statement
Write 8085 Assembly language program to mask the upper and lower nibble of an 8-bit number. The number is stored at location 8000H. Lower and Upper nibbles will be stored at location 8001H and 8002H.
Discussion
The masking is basically ANDing two numbers. When we want to mask the upper nibble of an 8-bit number say 2D (0010 1101), then we will AND with 0F (0000 1111), so we will get 0D (0000 1101). By masking with F0 (1111 0000), the result will be 20 (0010 0000). Now by shifting the upper nibble, we will get 02 (0000 0010).
Input
Address | Data |
---|---|
… | … |
8000 | AB |
Flow Diagram
Program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 21, 00, 80 | | LXI H,8000H | Initialize HL pair to get number |
F003 | 7E | | MOV A,M | Take the number from memory to accumulator |
F004 | 47 | | MOV B,A | Store A to B |
F005 | E6, 0F | | ANI 0FH | Get the lower nibble by masking upper one. |
F007 | 23 | | INX H | Point to next location |
F008 | 77 | | MOV M,A | Store Lower nibble to memory |
F009 | 78 | | MOV A,B | Take the number from B to A |
F00A | E6, F0 | | ANI F0H | Take the upper nibble by masking lower one. |
F00C | 0F | | RRC | Rotate acc four times |
F00D | 0F | | RRC | |
F00E | 0F | | RRC | |
F00F | 0F | | RRC | |
F010 | 23 | | INX H | Point to next location |
F011 | 77 | | MOV M,A | Store the upper nibble to memory |
F012 | 76 | | HLT | Terminate the program |
Output
Address | Data |
---|---|
8001 | 0D |
8002 | 02 |
… | … |
- Related Articles
- 8085 program to perform AND operation in nibbles of 8 bit number
- 8085 program to check whether both the nibbles of 8 bit number are equal or not
- 8085 program to reverse 8 bit number
- 8085 program to find square of a 8 bit number
- 8085 program to find sum of digits of 8 bit number
- 8085 Program to Divide a 16-bit number by an 8-bit number
- 8085 program to count number of once in the given 8-bit number
- 8085 program to convert an 8 bit number into Grey number
- 8085 program to find minimum value of digit in the 8 bit number
- 8085 program to convert 8 bit BCD number into ASCII Code
- 8085 program to find larger of two 8 bit numbers
- 8085 program to find maximum of two 8 bit numbers
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 Program to Add two 8 Bit numbers
- 8085 Program to Subtract two 8 Bit numbers

Advertisements