Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
    
i'd add a bit to the question.. where are they? processor? device? or just mapped ram locations? –  barlop Jul 9 '11 at 21:58
    
I don't have a time to write a real answer now, but registers are pieces of memory inside the CPU in which are stored data which are being processed at the moment. One type of registers are I/O registers. –  AndrejaKo Jul 9 '11 at 22:12
    
@AndrejaKo Many are talking of IO Registers in the device rather than the processor. So maybe they -are- in the device, (they probably have to be), but are they sometimes or always in the processor? would the processor just use the same register when it has something for a device, that it'd use when it has something for RAM. I might guess so, and then there's no IO Register in the CPU. It's just the data register MBR/MDR(memory buffer/data register). The one that the Data Bus reads from. –  barlop Jul 10 '11 at 10:00
2  
@barlop You are correct, the CPU does use the same registers when it has something for a device as when it has something for the RAM. Why is this? Because it accesses them in the same way! Sometimes they map hardware to the actual memory map, or use a different "hardware map" with different instructions. BUT, as you said, they use the same registers in the CPU, so there are no "specific" I/O registers. –  Breakthrough Jul 10 '11 at 14:11
add comment

3 Answers 3

up vote 2 down vote accepted

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.

share|improve this answer
add comment

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 (IN and 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.

share|improve this answer
add comment

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.

share|improve this answer
    
i'd add, memory locations (main memory / RAM locations) are also data storage units for processing operations, but are not called registers are they? –  barlop Jul 10 '11 at 17:42
    
Well, if you want to get strict about it, memory cells are registers. –  A Dwarf Jul 10 '11 at 20:51
    
@A Dwarf maybe in a descriptive sense, but as far as terminology is concerned, I don't think they are called Registers. –  barlop Jul 10 '11 at 21:45
1  
Precisely. They aren't. :) –  A Dwarf Jul 10 '11 at 21:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.