In this section we will see how a computer that has external ports connected to peripherals and IN and OUT instructions actually accomplishes I/O transfers. Fig. 18.2.1 shows a CPU is connected to a tape reader. Four ports are needed for proper communication: two for control, one for commands and a third for actual data. Ports 0 and 1 are the status ports, port 2 is the command port, and port 3 is the data port. Only the tape drive will put values on the data port, and only the CPU will put commands on the command port, but both the CPU and the tape drive will read and write the two status ports.
The reason there are two status ports is because one is under the command of the CPU while the second is controlled by the tape reader. Each port should have exactly one writer, although it could have many readers. |