Introduction :
The 8255 is a programmable peripheral interface chip that can be interfaced with the 8085 microprocessor to provide additional I/O capabilities. One of the operations that can be performed using the 8255 is to subtract the contents of two ports.
To perform this operation, the following steps can be followed:
- Configure the 8255 in mode 1 to enable bidirectional data transfer.
- Assign the two ports that will be used for the subtraction operation.
- Load the data from the two ports into the accumulator of the 8085 microprocessor.
- Subtract the contents of one port from the other using the SUB instruction of the 8085 microprocessor.
- Store the result in a third port.
Here is an example code that illustrates how to subtract the contents of Port A from Port B and store the result in Port C:
; Initialize the 8255 in mode 1
MOV A, 80 H ; Initialize control register A
OUT 80 H, A
; Assign the ports MOV A, 00 H ; Port A
OUT 81 H, A
MOV A, 01 H ; Port B
OUT 82 H, A
MOV A, 02 H ; Port C
OUT 83 H, A
; Load data from Port A and Port B into accumulator IN A, 81 H
MOV B, A IN A, 82 H
; Subtract the contents of Port A from Port B SUB B ; Store the result in Port C OUT 83 H, A
|
This code initializes the 8255 in mode 1 and assigns ports A, B, and C. It then loads the contents of Port A and Port B into the accumulator and subtracts the contents of Port A from Port B. The result is stored in Port C.
Note that the specific port addresses used in the code may vary depending on the system configuration.
How to Subtract content of two ports by interfacing 8255 with 8085 microprocessor :
To subtract the contents of two ports using the 8255 with the 8085 microprocessor, you can follow these steps:
- Initialize the 8255 in mode 1 to enable bidirectional data transfer.
- Assign the two ports that will be used for the subtraction operation.
- Load the data from the two ports into the accumulator of the 8085 microprocessor.
- Subtract the contents of one port from the other using the SUB instruction of the 8085 microprocessor.
- Store the result in a third port.
Here is a step-by-step guide to implementing these steps in code:
- Initialize the 8255 in mode 1: The 8255 has three control registers: Control Register A (CRA), Control Register B (CRB), and Control Register C (CRC). To initialize the 8255 in mode 1, you need to set the appropriate bits in Control Register A.
- Assign the ports: You need to assign two ports for the subtraction operation. In this example, we will use Port A and Port B for the input values, and Port C for the output result.
- Load the data into the accumulator: You need to load the data from the two input ports (Port A and Port B) into the accumulator of the 8085 microprocessor.
- Subtract the contents of one port from the other: Subtract the contents of Port A from Port B using the SUB instruction.
- Store the result in a third port: Finally, store the result of the subtraction in Port C.
Here is the complete code:
; Initialize the 8255 in mode 1
MOV A, 80 H ; Initialize control register A
OUT 00 H, A ; Send the initialization value to the 8255
; Assign the ports MOV A, 00 H ; Port A
OUT 01 H, A ; Assign Port A to the 8255
MOV A, 01 H ; Port B
OUT 02 H, A ; Assign Port B to the 8255
MOV A, 02 H ; Port C
OUT 03 H, A ; Assign Port C to the 8255
; Load data into accumulator IN A, 01 H ; Load data from Port A into accumulator
MOV B, A ; Move the data to register B for later use IN A, 02 H ; Load data from Port B into accumulator
; Subtract the contents of Port A from Port B SUB B ; Store the result in Port C OUT 03 H, A ; Store the result in Port C
|
Problem – Write an assembly program which determine the subtraction of contents of port B from port A and store the result in port C by interfacing 8255 with 8085 microprocessor. Example –
- Construct the control word register
- Input the data from port A and port B
- Subtract the contents of port A and port B
- Display the result in port C
- Halt the program
Program –
MNEMONICS | COMMENTS |
---|---|
MVI A, 92 | A <- 92 |
OUT 83 | Control Register <- A |
IN 81 | A <- Port B |
MOV B, A | B <- A |
IN 80 | A <- Port A |
SUB B | A <- A – B |
OUT 82 | Port C <- A |
RET | Return |
Explanation –
- MVI A, 92: means that the value of control register is 92.
D7=1 I/O mode D6=0 & D5=0 Port A is in mode 0 D4=1 Port A is taking input D3=0 & D0=0 Port C is not taking part D2=0 Port B is in mode 0 D1=1 Port B is taking input
- OUT 83: putting the value of A in 83H which is the port number of port control register.
- IN 81: take input from 81H which is the port number of port B.
- MOV B, A: copies the content of A register to B register.
- IN 80: taking input from 80H which is the port number of port A.
- SUB B: subtract the contents of A register and B register.
- OUT 82: display the result in 81H which is the port number of port C.
- RET: return