Practice Exercise 18 Answers

  1. Your computer has the following peripherals attached to it.
               keyboard          monitor         speaker
               microphone        mouse           printer
               modem             CD-ROM          hard drive
               floppy drive      PCMCIA card     streaming tape drive
a.) How many ports on the processor chip would it need if only direct (isolated) I/O were to be used? Each device needs 3 ports: a command port, a status port, and a data port. There are 12 devices, so 12x3 = 36 ports would be needed. b.) How many contact pads would be needed on the chip if each port were 8 bits wide? Further suppose that each contact pad is 2 millimeters wide. How big would the circumference of the chip need to be in feet? (There are 39.37 inches in a meter and 12 inches in a foot). 36 ports and 8 bits each gives 36x8 = 288 bits. If each bit requires a 2 mm contact pad, this would be 288x2=576 mm total length. 576 mm = 0.576 meters. 0.576 x 39.37 gives 22.68 inches, which is 1.9 feet. Almost 2 feet!
  1. List a couple protocols or standards around the house that have to do with communication or electrical devices. Think of both sequences of actions and of physical shapes and sizes.
telephone -- shape and size of plugs (RJ-11 standard), voltage levels in wires, type of equipment that can connect; also the human protoco using the telephone: exchange of greetings, friendly inquiry ("May I ask who is calling?") friendly good-bye, etc.

electrical system in a house -- shape and size of plugs (3-pronged or 2-pronged), 60 Hz 120 Volts AC


  1. In the tape reader protocol example, why is it necessary for the CPU to set the DA bit to 1 after it gets the byte from the data port, even if the CPU is always a lot faster than the peripheral? (HINT: Look at the assembler code in Fig. 3 and imagine that the CPU is a lot faster than the peripheral.)
If there was just one bit used to designate that a byte was ready, the CPU might jump back to the top of the loop too quickly and see that it is (still) 1. So it would mistakenly think there is a new value on the data wires and read the byte twice, or more times if it were very much faster than the tape reader.
  1. In a certain computer that uses memory-mapped I/O, each device is given 4 addresses because it can have up to 4 registers through which it communicates with the CPU. The addresses from 0...0000100 to 0...1111111 are set aside for memory mapped I/O. How many devices can this computer have attached to it?
          00001 XX     Since there are 31 binary numbers from 00001 to 11111
          ....         inclusive, there can be 31 different devices.
                       Each gets 4 words.
          
          11111 XX     of pseudo-memory into which it can map its registers.
                       (The two X's refer to the two addresses allotted to each
                       device.)

  1. Why is location 0 usually never used for memory-mapped I/O?
Because that location holds the start of the operating system, namely its first instruction. When power is turned on, all 0's are put into PC so that the OS will begin running at a known point. Actually, the hardware designers could rig it up so that any arbitary binary number is gated into PC at power-up time, so 0 is just an easy and customary value. Its use is not a requirement of the universe!
  1. Refer to Figures 18.7.2 and 18.7.3. Suppose that a new device had to be attached and it was given addresses 00011000 to 00011111 for its registers.
a.) Show the decoder for the device active wire for this device.

b.) Show the decoder for the device active wire for memory now.


  1. A certain computer runs at 1 MIPS. The keyboard interrupts it 60 times a second and the keyboard interrupt routine is 50 instructions long.
a.) How many instructions can this computer do in 1/60th of a second? How many instructions can this computer do in 1/60th of a second? 1 MIPS = 1,000,000 instructions/sec 1000000 / 60 = 16,666 (dropping the fraction) b.) Of the 1 million instructions which this computer will do every second, what percentage is devoted to the overhead of handling the keyboard? Of the 1 million instructions which this computer will do every second, what percentage is devoted to the overhead of handling the keyboard? 60 x 50 = 3000 instructions in each second are devoted to interrupt handling (60 = # of interrupts each second, and 50 = instructions done in each interrupt). 3000 / 1000000 = 0.3%