Does reading an I/O port have any side effects? What about in Programmed I/O?

222 views Asked by At

Does reading a CPU port (through the in/out instructions) have any side effects whatsoever?

For example:

  1. Does it "tell" a device that the port has been read?

  2. Could reading an arbitrary port carelessly cause any harm?

I'm assuming it shouldn't, but then something doesn't make sense to me:

If there is no side effect, then how does an ATA drive, when doing programmed I/O, "know" when a word has been read, so it can supply the next word of data?

1

There are 1 answers

3
Jerry Coffin On BEST ANSWER

Yes, reading a port can have side effects, but whether it does (and if so, what they are) varies between devices.

I've never heard of a device that could be damaged by reading a port. A few (but mostly old ones) could be damaged/cause damage by writing an incorrect value, but I don't know of any that reading could cause damage. In most cases, the side-effects of reading are fairly mild.

The act of reading can tell a device it's being read. To read from a device, you place a command and an address on the bus. If the command is "read" and the address corresponds to the device, then the device is being read.