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.
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
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
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
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:
OUTinstructions 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.
You can compare the concept of an I/O register to a generic hardware register, since a register is an arbitrary term used to refer to a digital storage area. A register can act as an accumulator, hold execution information, provide an input-output buffer between devices, etc. This also means that a processor register is just a type of hardware register.
An I/O register, then, is also an abstraction of a register - it holds intermediate data moving between components. Processors do not have specific I/O registers but rather, various generic registers which can accomplish the same task (which are used, for example, when the system uses memory mapped I/O). These are used to provide a common interface bus between the CPU and the memory of the system, but in the case of MMIO, allow access to external devices' memory off of the actual address bus.
How would a programmer actually do this? They would need to determine how the external device is mapped onto the address bus of the system, and then use one of the various x86 registers to store the address (in an index/pointer register). This register could then be used (with machine instructions) to transfer data to/from another register in the processor to a register on the device.
If the CPU does not support MMIO (or the programmer decides not to use it), then in the case of x86 there can also exist special instructions for I/O from a port (which is essentially another bus). These instructions (
OUT) work similar to the
MOV instruction - they even use the same processor registers. The only difference is what the address in the index/pointer registers means (since those registers use a different I/O address map).
This is why I say that I/O registers are an abstraction of any other CPU register - they are one in the same thing. The data still moves in and out of the processor into the same registers, whether or not they are used for intermediate results, data transfer to/from the RAM, or accessing external hardware.
Depending on the motherboard layout, a CPU may access an external devices' memory through the actual address bus itself, or another bus connected to a port on the CPU. However, all of this is usually governed by the motherboard's northbridge for memory access, and southbridge for peripheral access (e.g. video cards, mouse/keyboard).
Finally, if you're familiar with the concept of DMA, external peripherals themselves can have registers designated specifically for I/O purposes from the computer's RAM. Do note that DMA basically circumvents any CPU intervention, so the concept of a processor register would not be applicable here.
Final word: Every device in your computer has a register of some kind, since no device is connected directly to the CPU - and if it was, then you would be wasting CPU clock cycles keeping the data on the bus until the device had enough time to use it (the CPU usually has the fastest clock in any system). This is just one reason why devices need a place to store data before they can work with it - and that is essentially all a register is.
Conceptually I/O registers and Processor registers are the same thing. They both are data holding units of storage for processing operations.
The difference is one of locality. I/O registers and CPU registers are all part of the same family; Hardware Registers. CPU registers live in the CPU, I/O registers live outside the CPU on your I/O devices own digital processors.
For detailed information: Hardware Registers, explains hardware registers in general, making mention of their different kinds.
In normal usage, an "I/O register" is a register which is part of a microprocessor, and is physically attached to the I/O pins of the microprocessor.
Microprocessor CPU's can only communicate with the outside world through I/O pins. There are several ways that the internal logic of the Microprocessor can do this: there may be an internal bus, there may be memory access commands which implicitly use pins connected to an external address and data bus, there may be explicit commands for setting the values of specific pins. One common way is to have logic representing registers, the values of which control the meaning, state, and value of the I/O pins. These "registers" (which commonly are actual physical registers) are I/O registers.
For example, see the data sheet for the ATtiny261A http://ww1.microchip.com/downloads/en/DeviceDoc/doc8197.pdf
"PortB" is the logical representation of 8 I/O pins. It is the name of a Register in the Register List, and in the text is called an I/O register. "GPIOR1" is another register in the registers list. It is a "General Purpose" I/O register, not tied to physical pins, used to send data to an I/O register like "Port B"