- 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 whether both the nibbles of 8 bit number are equal or not
Here we will see how to check whether two nibbles of a number are same or not.
Problem Statement
Write 8085 Assembly language program to check whether upper nibble and lower nibbles are same or not.
Discussion
To check the nibbles, we have to mask at first. So we need to mask the lower nibble and upper nibble and store them into different registers. The upper nibble will be shifted to the right four bits to make it lower nibble. Then we can check both are same or not. If they are same store 00 at F150 location, otherwise store FF at F150 location.
Input
Address | Data |
---|---|
F050 | FE |
Address | Data |
---|---|
F050 | AA |
Flow Diagram
program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 3A, 50 F0 | | LDA F050 | memory element of F050 |
F003 | 47 | | MOV B, A | Load A into B |
F004 | E6, 0F | | ANI 0F | Mask upper nibble |
F006 | 4F | | MOV C, A | Load C with A |
F007 | 78 | | MOV A, B | Load A with B |
F008 | E6, F0 | | ANI F0 | Mask lower nibble |
F00A | 07 | | RLC | Rotate A to the left |
F00B | 07 | | RLC | Rotate A to the left |
F00C | 07 | | RLC | Rotate A to the left |
F00D | 07 | | RLC | Rotate A to the left |
F00E | B9 | | CMP C | Compare C and A |
F00F | CA, 17, F0 | | JZ LABEL | If Z flag is enabled jump to Label |
F012 | 3E, FF | | MVI A, FF | Load A with FF |
F014 | C3, 19, F0 | | JMP STORE | Jump to Store |
F017 | 3E, 00 | LABEL | MVI A, 00 | Load A with 00H |
F019 | 32, 50, F1 | STORE | STA F150 | Store result at memory F150 |
F01C | 76 | | HLT | Terminate the program |
Output
Address | Data |
---|---|
F150 | FF |
Address | Data |
---|---|
F150 | 00 |
Advertisements