Section 18.2
Review Questions

How I/O actually works

  1. What are the three groups of wires that are usually needed to communicate between a CPU and a peripheral?
answer...
  1. control (commands)
  2. status (the state of the peripheral)
  3. data
  1. If there are 8 data bits that get transmitted, 2 bits of status information and 2 bit commands, how many ports are needed?
answer...
only 3, one port for each group of wires
  1. Which of the following commands would the CPU use to find out what state the tape reader is in? Circle one.
     START   HALT   REWIND   ALERT    QUERY   PAUSE
answer...
QUERY
  1. Do any of the above commands transmit information?
answer...
not real data coming off the tape! only control information.
However, the START command tells the tape reader to go ahead and begin reading bytes.
  1. The tape reader example in this section uses two bits: DA = Data Accepted, and DR = Data Ready. What does Data Ready = 1 mean?
answer...
that the tape reader has extracted a byte from the tape and placed it on the data wires so that the CPU can accept it and copy it into its own memory
  1. Which wire does the CPU set to 1 when it is ready for the tape reader to move on to the next byte?
answer...
DA (Data Accepted)
  1. Which bit value combination for DA/DR is not used?
answer...
DA=1 DR=0
  1. How does the tape reader ever stop?
answer...
when the CPU sends it a HALT command, or when it finds the end of the tape and tells the CPU about that through the status register
  1. What does it mean to poll?
answer...
In the world of computers, it means to explicitly ask a device what its status is. It may also mean to repeatedly ask until the device responds with an affirmative status value.
  1. Suppose port 0 is the status port, 1 is the control port, and 2 is the data port. Write an instruction which the CPU would issue to find out if there is any data to obtain.
answer...
IN 0
  1. Continuing, write an instruction which the CPU would issue to tell the tape reader to begin reading.
answer...
OUT 1
  1. Continuing, write an instruction which the CPU would issue to obtain a byte of data.
answer...
IN 2
  1. What register is implictly used with every IN and OUT instruction?
answer...
the accumulator
  1. In the polling program below, which instructions actually get a data byte and save it in main memory?
                    LDI  "10b"     ;send GO command to the tape reader
                    OUT  1
          CHECKCTL: IN   0         ;read data ready bit from control port
                    SUB  "01"b     ;compare to 01b
                    JNZ  CHECKCTL  ;if not equal jump up to top of loop
                    IN   2         ;read data byte on port 2
                    STD  X         ;store into main memory somewhere
                    LDI  "11"b     ;get ready to write 1 into data accepted
                    OUT  0         ;write to status port
                    JMP  CHECKCTL  ;do it all over again
answer...
     IN   2         ;read data byte on port 2
     STD  X         ;store into main memory somewhere