---
title: "8255 mode 1 keyboard and printer with decoding"
subject: "Instrumentation II"
chapter: 2
key: "semester_5/instrumentation_ii:ppi-keyboard-printer-mode1-fig"
source: https://www.bctengineer.com/q/semester_5/instrumentation_ii/ppi-keyboard-printer-mode1-fig
site: BCT Engineering
---

# 8255 mode 1 keyboard and printer with decoding

Instrumentation II · Chapter 2: Parallel Interfacing With Microprocessor Based System

- Asked in: 2076 Chaitra, 9 marks
- Video: [Control Word and Modes of 8255: BSR Mode, IO Modes, and Detailed Mode 0, 1, & 2](https://www.youtube.com/watch?v=la-EoWUcSp4) — Engineering Funda
- Answer checked by Claude Sonnet 5.5 on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_5/instrumentation_ii/ppi-keyboard-printer-mode1-fig
- Whole chapter: https://www.bctengineer.com/md/semester_5/instrumentation_ii/chapter-2

## Question

Port A is to design as the input for a keyboard in interrupt driven I/O and Port B as the output for a printer in status check I/O using mode 1 of 8255 with 8085 microprocessor as shown below: (a) Find port addresses by analyzing decoding logic. (b) Determine the control word to set up port A as input and port B as output. (c) Determine the BSR word to enable INTEA. (d) Determine the masking byte to verify the OBFB line. (e) Write main program and a read and write subroutines to accept characters from keyboard and to send them to print. [Figure: 8255 with +5 V on Vcc and GND; data bus D7-D0. A multi-input NAND gate with inputs A7, A6, A5, A4, A3, A2 drives CS (active low). A1 and A0 connect to the 8255 A1 and A0. IOR connects to RD and IOW to WR; RESET OUT connects to RESET. Port A (PA7-PA0) is the input from the keyboard. PC4 is STB (active low) from the peripheral; PC5 is IBF to the peripheral; PC3 is INTRA going to the 8085 interrupt RST 6.5. PC1 is OBFB (to the printer); PC2 is ACKB (from the printer). Port B (PB7-PB0) is the output to the parallel printer.]

## Short answer

Port addresses: A=FCH, B=FDH, C=FEH, Control=FFH (A7–A2=111111). Control word B4H sets port A mode 1 input, B mode 1 output. BSR word 09H enables INTEA; OBFB' mask is 02H. Keyboard ISR reads port A, sets flag; main loop calls write routine that polls OBFB' then outputs to port B.

## Answer

#### (a) Port addresses
CS' = NAND(A7, A6, A5, A4, A3, A2), so the chip is selected only when A7-A2 = 111111. Port A = **FCH** (1111 1100), Port B = **FDH**, Port C = **FEH**, Control = **FFH** (I/O mapped, IOR'/IOW').

#### (b) Control word
Port A mode 1 input; port B mode 1 output. D7 = 1; D6D5 = 01; D4 = 1 (A input); D3 = 0 (PC6, PC7 output); D2 = 1 (B mode 1); D1 = 0 (B output); D0 = 0 = 1011 0100 = **B4H**.

#### (c) BSR word to enable INTEA
In mode 1 input, INTE_A is controlled by PC4. D7 = 0, D3D2D1 = 100, D0 = 1: 0000 1001 = **09H**. (INTR_A on PC3 goes to RST 6.5, vector 0034H.)

#### (d) Masking byte for OBFB
Port C status word (A input, B output): D7 D6 I/O, D5 IBF_A, D4 INTE_A, D3 INTR_A, D2 INTE_B, D1 OBF_B', D0 INTR_B. OBFB' is bit D1, so the mask is 0000 0010 = **02H**. OBF_B' = 1 means the printer has accepted the last byte.

#### (e) Program
```text
        ORG 0034H            ; RST 6.5 vector
        JMP KBDISR
        ORG 2000H
START:  LXI SP,27FFH
        MVI A,B4H
        OUT FFH              ; mode set
        MVI A,09H
        OUT FFH              ; INTEA = 1
        MVI A,0DH            ; SIM: unmask RST 6.5 (MSE=1, M7.5=1, M6.5=0, M5.5=1)
        SIM
        EI
        LXI H,3000H          ; buffer pointer
        MVI D,00H            ; D = 1 when a character has arrived
MAIN:   MOV A,D
        ORA A
        JZ MAIN              ; wait for keyboard interrupt
        MVI D,00H
        CALL WRITE           ; print the character
        JMP MAIN

KBDISR: PUSH PSW             ; read subroutine (interrupt service)
        IN FCH               ; read keyboard character from port A
        MOV M,A              ; store in buffer
        MVI D,01H            ; flag
        POP PSW
        EI
        RET

WRITE:  IN FEH               ; write subroutine: read port C
        ANI 02H              ; mask OBFB'
        JZ WRITE             ; wait until printer has taken last byte
        MOV A,M
        OUT FDH              ; send character to printer
        INX H
        RET
```
The keyboard needs interrupt service because key presses are random; the printer is slow, so its status is checked before each byte.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. With CS' = NAND(A7..A2), at which addresses is the 8255 selected?
   A. 00H-03H
   B. FCH-FFH
   C. F0H-F3H
   D. 3FH-FFH
   Answer: B. The NAND output is low only when A7-A2 = 111111, so the ports are FCH (A), FDH (B), FEH (C) and FFH (control). (Key point: Chip select decoding)

2. What is the control word for port A mode 1 input and port B mode 1 output (PC6, PC7 output)?
   A. B4H
   B. B6H
   C. 94H
   D. A4H
   Answer: A. D7=1, D6D5=01, D4=1 (A input), D3=0, D2=1 (B mode 1), D1=0 (B output), D0=0 gives 1011 0100 = B4H. (Key point: Control word)

3. In mode 1 input, which port C bit controls INTEA, and what BSR word sets it?
   A. PC6, 0DH
   B. PC4, 09H
   C. PC2, 05H
   D. PC4, 08H
   Answer: B. INTE_A for input is PC4. BSR with D3D2D1 = 100 and D0 = 1 is 0000 1001 = 09H. (Key point: BSR word for INTEA)

4. Which masking byte is used to test OBF_B' from the port C status word?
   A. 01H
   B. 04H
   C. 02H
   D. 20H
   Answer: C. OBF_B' is bit D1 of port C, so the mask is 0000 0010 = 02H; 1 means the printer accepted the last byte. (Key point: OBFB mask)

## Related in Instrumentation II

- [Keyboard and printer interface in 8255 mode 1](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Akeyboard-printer-mode1) — Instrumentation II, chapter 2
- [Keyboard and printer with 8255A at 4044H](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Akbd-printer-ppi-4044h) — Instrumentation II, chapter 2
- [Centronics printer with 8255A in mode 1](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Acentronics-printer-8255-mode1) — Instrumentation II, chapter 2
- [8255A at 80H: addresses, mode 0/1 words, BSR](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-80h-addresses-control) — Instrumentation II, chapter 2
- [8255A card at F3H with keyboard and display](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Appi-f3h-keyboard-display) — Instrumentation II, chapter 2
- [ADC804 with 8255 control word and program](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aadc804-8255-program) — Instrumentation II, chapter 4

## Related in other subjects

- [Address decoding for input and output ports](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adecoder-input-output-port-block-decoder) — Microprocessor, chapter 4
- [Address decoding for input port at 8050H](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adecoder-input-port-lda-8050h) — Microprocessor, chapter 4
- [Address decoding for 8 LEDs output port](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Adecoder-output-port-8-leds) — Microprocessor, chapter 4
