Design a hardware scheme to interface 8255 (programmable peripheral interface) with 8085, and configure its Port ‘A’ and Port ‘C’ as input ports and Port ‘B’ as output port.
Write an assembly language program to take two different numbers from Port ‘A’ and Port ‘C’ and display the summation of these numbers on Port ‘B’ as output.
Assume the port addresses are :
Port A = 00H
Port B = 01H
Port C = 02H
Control word register address : 03H.
10 marks · directive: Design
The core of a good answer
The 8255 is I/O-mapped with A1, A0 selecting the ports and chip select generated when A7 to A2 = 0 and IO/M̅ = 1; control word 99H (mode 0, Port A in, Port C in, Port B out) is written to 03H, and the program reads 00H and 02H, adds them and outputs the sum to 01H.
An outline written by upsc.help, not an official UPSC answer; every fact checked by a separate review. How we work
What the question asks
An interfacing design question: address decoding for the four given addresses, control signal connections, the mode 0 control word derived bit by bit, and a short 8085 program using IN, ADD and OUT.
Answer outline
Introduction
Addresses 00H to 03H differ only in A1 A0, so A1 and A0 of the 8085 drive A1 and A0 of the 8255, and the remaining lines A7 to A2 must be all zero to select the chip.
Step 1: Hardware scheme
- Data: AD7 to AD0 of the 8085 to D7 to D0 of the 8255
- Address: A0 and A1 of the 8255 can be driven from A8 and A9 of the 8085, because during IN and OUT the 8-bit port address is placed on both halves of the address bus (or from latched A0, A1)
- Chip select: CS̅ = 0 only when A7 to A2 are all 0, for example through a 6-input OR gate (or a 74LS138 decoder enabled by IO/M̅)
- Control: IOR̅ (from RD̅ and IO/M̅) to RD̅ of the 8255, IOW̅ (from WR̅ and IO/M̅) to WR̅ of the 8255
- RESET OUT of the 8085 to RESET of the 8255 (after reset all 8255 ports are inputs); Port A and Port C lines to the input devices, Port B lines to the output display or LEDs
Step 2: Control word
- D7 = 1 (I/O mode), D6 D5 = 00 (group A mode 0), D4 = 1 (Port A input), D3 = 1 (Port C upper input)
- D2 = 0 (group B mode 0), D1 = 0 (Port B output), D0 = 1 (Port C lower input)
- Control word = 1001 1001 = 99H
Step 3: Program
- MVI A, 99H ; control word
- OUT 03H ; initialise 8255
- IN 00H ; read first number from Port A
- MOV B, A ; save it
- IN 02H ; read second number from Port C
- ADD B ; A = A + B
- OUT 01H ; display sum on Port B
- HLT
Step 4: Notes
- Only an 8-bit sum is displayed; a carry beyond FFH can be shown on another device or by a JNC check if needed
- In mode 0 there is no handshaking, so data are read as they are present on the port lines
Conclusion
With control word 99H at 03H, the program reads Port A and Port C, adds them and writes the 8-bit result to Port B.
Examples and data to cite
- In the 8255 control word, D7 = 0 selects the bit set/reset mode for Port C instead of the I/O mode.
- Port C can be split into two 4-bit halves, each separately programmed as input or output in mode 0.
Facts to remember
- 8255 has three 8-bit ports A, B, C and a control register selected by A1 A0 = 00, 01, 10, 11.
- Modes: mode 0 simple I/O, mode 1 strobed I/O, mode 2 bidirectional (Port A only).
- Control word I/O mode format: D7 = 1, D6 D5 group A mode, D4 Port A, D3 Port C upper, D2 group B mode, D1 Port B, D0 Port C lower (1 = input).
- IN port and OUT port each take 10 clock cycles and use 8-bit port addresses.