---
title: "Port-based and bus-based I/O"
subject: "Embedded System"
chapter: 5
key: "semester_6/embedded_system:port-based-vs-bus-based-io"
source: https://www.bctengineer.com/q/semester_6/embedded_system/port-based-vs-bus-based-io
site: BCT Engineering
---

# Port-based and bus-based I/O

Embedded System · Chapter 5: Interfacing

- Asked in: 2072 Magh, 3 marks; 2076 Baisakh, 2 marks (asked 2 times)
- Video: [Memory Mapped I-O vs Port Based I-O](https://www.youtube.com/watch?v=VfaTAXiLFn8) — Bruce Schreiner
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_6/embedded_system/port-based-vs-bus-based-io
- Whole chapter: https://www.bctengineer.com/md/semester_6/embedded_system/chapter-5

## Question

Explain port-based and bus-based I/O. (Which I/O, port based or bus based, is used in the 8051 microcontroller? Describe in brief.)

## Short answer

Port-based I/O connects peripherals directly to processor port pins, accessed as registers (e.g., 8051 SFRs) without buses. Bus-based I/O attaches peripherals to system buses, requiring address decoding and using memory-mapped or isolated I/O. The 8051 primarily uses port-based I/O via its four 8-bit ports.

## Answer

#### Port-based I/O
The processor has special I/O **ports** built into it and the peripheral is connected directly to the port pins. The port is seen by the programmer as one or more registers (special function registers) read and written like ordinary registers, e.g. MOV P1, A or MOV A, P1. No address or data bus is used for the peripheral. Example: reading a switch on P1 and driving an LED on P2.

#### Bus-based I/O
The processor has address, data and control buses, and the peripherals are attached to these buses. It uses special logic (address decoder and registers) to access them, either as **memory-mapped I/O** (same instructions as memory) or **standard (isolated) I/O** (IN/OUT instructions). The processor reads or writes a peripheral by placing its address on the bus. Example: a UART connected to a microprocessor bus.

| Point | Port-based | Bus-based |
|---|---|---|
| Access | Direct register/pin access | Through address, data and control buses |
| Instructions | Normal register instructions | Memory or IN/OUT instructions |
| Hardware | Simple, no decoder | Needs address decoding |
| Number of peripherals | Limited by number of pins | Many |

#### In the 8051
The 8051 mainly uses **port-based I/O**: four 8-bit parallel ports P0, P1, P2 and P3 (32 pins), which are special function registers that can be bit-addressed (SETB P1.0). Peripheral registers such as timers and serial port (SBUF, TMOD, SCON) are also accessed as SFRs. The 8051 can also use a bus (P0 as multiplexed address/data, P2 as high address) for external memory and memory-mapped peripherals, but in that case ports P0 and P2 are no longer available as I/O ports.

## Check yourself

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

1. In port-based I/O, how is the peripheral connected?
   A. Directly to port pins, accessed as registers
   B. Through address and data buses
   C. Through DMA
   D. Through memory only
   Answer: A. Ports are seen as registers, e.g. MOV P1, A, with no address bus needed. (Key point: Port-based I/O)

2. Bus-based I/O requires:
   A. Address decoding and bus access, memory-mapped or IN/OUT
   B. No logic
   C. Only port pins
   D. Only interrupts
   Answer: A. The processor places the peripheral address on the bus, which needs decoding. (Key point: Bus-based I/O)

3. Which I/O does the 8051 mainly use?
   A. Port-based I/O with P0-P3
   B. Bus-based I/O only
   C. DMA only
   D. Isolated IN/OUT
   Answer: A. The 8051 has four 8-bit ports; using external memory takes P0 and P2 for the bus. (Key point: 8051)

## Related in Embedded System

- [Purpose of port 3 and port 2 of 8051](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-port3-port2-purpose) — Embedded System, chapter 9, asked 2×
- [Port 3 of 8051](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-port3-explain) — Embedded System, chapter 9
- [Microcontroller vs microprocessor; 8051 features](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Amicro-vs-microprocessor-8051-features) — Embedded System, chapter 9, asked 2×
- [Microprocessor vs microcontroller; 8051 addressing](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-addressing-modes-micro-vs-processor) — Embedded System, chapter 9
- [Addressing modes of 8051](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3A8051-addressing-modes) — Embedded System, chapter 9, asked 4×
- [Why 8051 / its operational features](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Awhy-8051-features) — Embedded System, chapter 9, asked 2×

## Related in other subjects

- [Microcontroller-based thyristor firing circuit](https://www.bctengineer.com/question.md?key=semester_7%2Fpower_electronics%3Amicrocontroller-firing-opto) — Power Electronics, chapter 1
- [Microprocessor based system and bus organization](https://www.bctengineer.com/question.md?key=semester_4%2Fmicroprocessor%3Amp-based-system-bus-organization) — Microprocessor, chapter 1, asked 5×
- [PCI bus in brief](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Apci-bus) — Instrumentation II, chapter 2, asked 2×
- [PC based concrete purifying factory with 8255](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Aconcrete-purifying-ppi-4000h) — Instrumentation II, chapter 2
