“Processor register” and “IO register”

cpu-architectureregister

I was wondering if processor registers and IO registers are the same concept?

Are they registers in CPU or in some IO devices?

I picked up IO registers from this Super User question.

Best Answer

Processor registers - generally, something to do with any operation that the CPU does must be in one of its registers.

For example, look at this. It's the various forms of the Intel x86 ADD instruction. You'll notice that you can add two registers together, or add a register together with the contents of a memory location ("accumulator" is just another register, "immediate" just means the data is in the memory location directly, or "immediately" after the actual ADD opcode). There is no ADD mem,mem.

RISC CPU's such as ARM are even less flexible. Data from memory must always be copied to a register as a separate operation before the CPU can do anything like ADD, SUB, etc. to it. They have many more registers to make up for this.

I/O registers - generally, something to do with any operation that an I/O chipset or device does must be in one of its registers.

For example, look at this. It's detail about the standard VGA "CRTC registers." Of particular interest is the "Start Address High" and "Start Address Low" registers. The values in these registers tell the VGA where to begin reading memory to render a display.

There's many ways to make I/O registers accessible from a CPU. Usually it is not like processor registers above. Various methods include:

  • One way is creating the I/O device so it responds the same way on a hardware level as RAM, but only at certain addresses. Reads/writes to those addresses don't go to RAM, but the I/O device. I/O devices may then make their registers accessible at certain addresses. The CPU then reads or writes the registers using the same ones it does for RAM. Very common on 8-bit and ARM architectures.
  • x86 does have special IN and OUT instructions for I/O. These specify addresses but not ones that RAM can be connected to. I/O devices may connect to these addresses (usually called "ports", not to be confused with TCP ports) and make their registers accessible this way.

Continuing with the example of the VGA CRTC registers above, with how I explained "I/O ports" above you are now armed with the knowledge to understand this and understand that by issuing specific OUT instructions the CPU then modifies the value in the VGA's I/O register, which is retained and used by the VGA chipset.

Not all I/O devices have registers. Some are really simple and just need some sort of signal to do their thing, and also "reading" the device just reports a current state. The old PC "game port" is an example. There's really no storage of data going on so it might not be technically correct to call it a register. Most technical documentation won't make this distinction, though.