How it works
The 8255 has three 8-bit I/O ports (A, B, C) and a control register. Port C is split into upper (PC7–PC4) and lower (PC3–PC0) nibbles, each independently configurable. Mode 0 (basic I/O): ports used as simple input or output. Mode 1 (strobed I/O): ports A and B use handshaking signals from port C. Mode 2 (bidirectional bus): only port A, full bidirectional with handshaking. The control word format (D7=1 for mode set): D6D5 = mode for port A, D4 = port A direction, D3 = port C upper direction, D2 = mode for port B (0 or 1 only), D1 = port B direction, D0 = port C lower direction.
Key points to remember
BSR (Bit Set/Reset) mode: D7=0 in control word selects BSR mode; D3D2D1 selects port C bit (000=PC0 to 111=PC7); D0=1 sets the bit, D0=0 resets it. BSR mode affects only one bit of port C without disturbing others — useful for controlling individual handshake signals. The 8255 is mapped into the I/O space of 8085; A1A0 pins select port A (00), B (01), C (10), control (11). Chip select is generated by address decoding. Mode 1 provides IBF, OBF, STB, ACK handshake signals for synchronised parallel I/O. In mode 2, port A uses OBF-bar, ACK-bar, STB-bar, IBF, and INTR signals — five port C lines consumed for one bidirectional port.
Exam tip
The examiner always asks you to derive the control word for a specified 8255 configuration and write the initialisation code — construct the control word bit by bit from the mode definition table and use OUT instruction to write it to the control register address.