The status (idle, busy) of the IO device can be obtained by reading its status register.
So operating an IO device is essentially very similar to reading and writing memory, except that write operations to the command register will make the IO device do a certain operation.
As you know, memory locations also have addresses.
So how can you tell the difference between an address for an IO device and an address for a memory location ?
Currently, only the Intel Pentium CPU processor uses standard IO, all other CPUs (SPARC, PowerPC, Alpha, etc), uses memory-mapped IO.
Two "spaces" are separate if there is an external (explicit) signal that identify the space.
For example, there are many "lotto" games in the US. If you have a Big Game ticket with the numbers 1, 2, 3, 4, 5, 6, and the Lotto South draws the 6 winning numbers 1, 2, 3, 4, 5, 6, then although your Big Game ticket has the winning numebrs, you are not a winner.
Similarly, when the CPU signals an address 1234 on the address bus, in standard IO, that address can be used to address a memory location or an IO device.
The CPU has an extra explicit signal that indicates whether the address is a memory location or an IO device:
Similarly, when the CPU wants to access (read/write) an IO device, it asserts the IOREQ signal (and simultaneously do not assert MREQ).
In the Intel processor (which is the only processor that uses standard IO), the programmer uses:
Here is an Intel assembler code manual for your perusal: click here
The 2 sets of addresses must be disjoint (no overlap) !!!
Address (binary) Use for ----------------------------------------------------------- 00000000 00000000 00000000 00000000 Memory 00000000 00000000 00000000 00000001 Memory 00000000 00000000 00000000 00000011 Memory .... 11100000 00000000 00000000 00000000 Memory 11100000 00000000 00000000 00000000 Memory .... 11101111 11111111 11111111 11111111 Memory 11110000 00000000 00000000 00000000 IO device 11110000 00000000 00000000 00000001 IO device .... 11111111 11111111 11111111 11111111 IO device
If the last 4 bits of the address = 1111, then the CPU wants to address an IO device. Otherwise, the CPU wants to addres the memory
After determining the two (disjoint) sets, the manufacturer will construct selection circuitries that implement the partition.
In the above example, we can use the following circuit to determine whether the CPU wants to address the memory or an I/O device:
In other words:
Therefore, when the CPU sends out an address, there is no way to tell by only looking at all the signals from the CPU if the address was for a memory location or for an IO device. (But ofcourse there must be a way to tell the difference, just not by looking at the signal from the CPU).
In general, memory-mapped IO is constructed as follows:
Clearly, unlike in standard IO, there is no need to have 2 different types of assembler instructions (one type for accessing memory and the other for accesing IO device).
For example, the M68000 uses memory mapped IO and it can use the move instruction to access the memory and IO device.
(For those students that plan to take Operating Systems - you will see that the addresses 1400 - 15FF (Hex) are reserved for IO devices in emacsim)
Then we can use the remaining 31 bits of the address as the actual address portion for selecting a memory location or IO device.
The wiring scheme for the above partitioning of the address space is given in the following diagram:
Well, there is no clear advantage for either scheme, it's a matter of taste, very much like the big endian/little endian choice.
Perhaps this phenomenon is related to the big endian/little endian phenomenon, because only the Intel CPUs uses both little endian encoding and standard IO. The rest of the world uses big endian and memory-mapped IO.