- 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
Subtract content of two ports by interfacing 8255 with 8085 microprocessor
In this program we will see how to perform subtraction by using ports to take data and send the result into the port.
Problem Statement
Write 8085 Assembly language program for interfacing between 8085 and 8255. Here Port A and Port B are holding two values, take the numbers from port A and B, subtract B from A, and send the result at port C.
Discussion
The task is very simple. At first we have to setup the control word register of 8255 chip. After that we will take the input from port A and B, add the content, and send it to port C.
The control word register is looks like this. It is holding 92H.
Bit Position | D7 | D6 | D5 | D4 | D3 | D2 | D1 | D0 |
---|---|---|---|---|---|---|---|---|
Value | 1 | 0 | 0 | 1 | 0 | 0 | 1 | 0 |
The bits of control register signify like this
We are taking 92H into A. Then D7 is 1, so it is working as IO mode, the (D6 and D5) are 00, so it tells that port A is in Mode 1. D4 = 1, so port A is taking the input. The (D3 and D0) are 0 and 0. So port C is not working. And D2 = 0 as B is also in Mode 0, D1 = 1 as it is acts as input port.
In the instruction we will see OUT 83. Here 83 is the port number of Control register port. Similarly, IN 80 indicates that taking the input from port A whose port address is 80. And IN 81 indicates that taking input from port B also. The OUT 82 tells we are sending the result to port C.
Input
Port | Data |
---|---|
A | 5C |
B | 23 |
Program
Address | HEX Codes | Labels | Mnemonics | Comments |
---|---|---|---|---|
F000 | 3E, 92 | | MVI A,92 | Load A with Control Word |
F002 | D3, 83 | | OUT 83 | Send output to control register |
F004 | DB, 80 | | IN 80 | Take first input from port A |
F006 | 47 | | MOV B,A | Store A to B |
F007 | DB, 81 | | IN 81 | Take second input from B |
F009 | 90 | | SUB B | subtract B with A |
F00A | D3, 82 | | OUT 82 | Send output to C |
F00C | C9 | | RET | Return |
Output
Port | Data |
---|---|
C | 39 |