0% found this document useful (0 votes)
6 views9 pages

I - O and The CPU

The document discusses the interaction between the CPU and I/O devices, highlighting the need for data exchange in both directions. It explains two main methods for CPU access to I/O device registers: memory-mapped I/O, which uses memory addresses, and port-mapped I/O, which employs special instructions and separate port addresses. The advantages and disadvantages of each method are also outlined, along with their historical context in early and modern computing systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views9 pages

I - O and The CPU

The document discusses the interaction between the CPU and I/O devices, highlighting the need for data exchange in both directions. It explains two main methods for CPU access to I/O device registers: memory-mapped I/O, which uses memory addresses, and port-mapped I/O, which employs special instructions and separate port addresses. The advantages and disadvantages of each method are also outlined, along with their historical context in early and modern computing systems.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

I/O and the CPU

Memory-mapped vs. port-mapped I/O


I/O and the CPU

The CPU needs to receive data from and send data to I/O
devices.
Why send to input devices?
E.g. set sensitivity, calibrate, switch on/off, …
Why receive from output devices?
E.g. check if ready, check if successful, …
I/O registers
Inside the device, not inside the CPU!

Each I/O device has its own registers.


E.g. keyboard: register holds the currently pressed key.
How can the CPU access these registers?
Two (main) methods:
● memory-mapped I/O
● port-mapped I/O
Memory-mapped I/O

Each I/O register is “mapped” to a special memory address.


Use Load/Store to access the device.
Example: keyboard register mapped to A000.
● Load A000 loads currently pressed key into AC register.
Example: printer register is mapped to A100.
● Store A100 stores current AC value in printer register (which
then gets printed out).
Memory-mapped I/O

Advantages:
● No new instructions needed
● Simple
Disadvantages:
● Uses up some memory addresses (overall amount of
addressable memory is reduced)
● Programs may accidentally access I/O
(when the program has a bug)
Port-mapped I/O

● Add special I/O instructions to the ISA


● Each I/O register still has an address
(as in memory-mapped I/O)
● But these addresses are now separate from memory, and
called ports
● For example
○ Load A000 loads from memory address A000
○ Input A000 loads from I/O register A000 (e.g. the keyboard)
● Also known as instruction-based I/O
Memory- vs port-mapped I/O

Early PCs:
● 1 MB of memory addressable (220 addresses)
● But only 640 kB usable for programs, rest partly used for I/O
● ISA could handle both port-mapped and memory-mapped
Modern computers:
● 64 bit address space leaves more than enough room for
memory-mapped I/O
● Small embedded microcontrollers may still use ports
Summary

● Most I/O devices need to communicate with the CPU in


both directions
● I/O devices have hardware registers for communication
● CPU handles I/O using either
○ Memory-mapped I/O, using some memory addresses to
communicate with I/O device; or
○ Port-mapped I/O, using special CPU instructions and a separate
address space (these addresses are called ports)
● Next: when to communicate
EOF

You might also like