
110
Chapter 3: General-Purpose Programming
AMD 64-Bit Technology
24593—Rev. 3.09—September 2003
There are two methods for communicating with I/O devices in
AMD64 processor implementations. One method involves
accessing I/O through ports located in I/O-address space (“I/O
Addressing” on page 110), and the other method involves
accessing I/O devices located in the memory-address space
(“Memory Organization” on page 11). The address spaces are
separate and independent of each other.
I/O-address space was originally introduced as an optimized
means for accessing I/O-device control ports. Then, systems
usually had few I/O devices, devices tended to be relatively low-
speed, device accesses needed to be strongly ordered to
guarantee proper operation, and device protection
requirements were minimal or non-existent. Memory-mapped
I/O has largely supplanted I/O-address space access as the
preferred means for modern operating systems to interface
with I/O devices. Memory-mapped I/O offers greater flexibility
in protection, vastly more I/O ports, higher speeds, and strong
or weak ordering to suit the device requirements.
3.8.1
I/O Addressing
Access to I/O-address space is provided by the IN and OUT
instructions, and the string variants of these instructions, INS
and OUTS. The operation of these instructions are described in
“Input/Output” on page 76. Although not required, processor
implementations generally transmit I/O-port addresses and I/O
data over the same external signals used for memory addressing
and memory data. Different bus-cycles generated by the
processor differentiate I/O-address space accesses from
memory-address space accesses.
I/O-Address Space.
Figure 3-18 on page 111 shows the 64 Kbyte
I/O-address space. I/O ports can be addressed as bytes, words, or
doublewords. As with memory addressing, word-I/O and
doubleword-I/O ports are simply two or four consecutively-
addressed byte-I/O ports. Word and doubleword I/O ports can be
aligned on any byte boundary, but there is typically a
performance penalty for unaligned accesses. Performance is
optimized by aligning word-I/O ports on word boundaries, and
doubleword-I/O ports on doubleword boundaries.