SeanMc wrote:
I'm still trying to wrap my head around registers. I know they are supposed to be on-CPU memory stores, but what exactly is the difference between all of them? The concept for them being copied to other registers sounds weird and confusing too.
To have some information we need it to be perceptible. Until we can feel it the information doesn't exist. That's why machines have means of recording an information. Electrical machines (computers in particular) often use the electric potential level as a sign of "something is there" (an information about something). That's how computer's memory works. It sets one voltage level for the bit 0 (zero) and another level for the bit 1. But there's much more information in the world than one bit can hold. So, people invented bytes (8 bits), kilobytes, megabytes and so on. And every bit in those megabytes is one of the voltage levels - one level for 0 and another for 1.
Next goes memory structure. If we have enough memory it doesn't mean the memory fulfills all our needs. One particular need is the speed with which the computer does it's job. When there is a lot of memory the time required to access it increases significantly. That's why people decided to create another piece of memory, but with another name - the registers. The registers are small pieces of memory and because of the size it is possible to place them somewhere near the computer's processor. If something is near the access speed is increased. So, the registers can be viewed as a "fast" memory. And all that they are needed for is the speed. Would there be no need for speed there would be no registers.
Next goes computer's job. The job is about calculations and sending results to a device, where people can see it. So, there's a need for sending information. To send an information we need a piece of hardware with the same voltage levels as the another piece has. It is just a copy of the voltage levels. When there's no copy - the information wasn't sent. But when the copy is there - we just have sent the information from one device to another. It applies to every piece of the computer electronics. Also it applies to the registers. If we ordered the processor to execute a move instruction (register to register) it means the processor just connected it's internal lines between two registers. If the move instruction involves memory then the process is more complicated and involves additional chips and somewhat tricky algorithms. That's why processor to memory communication is slow (if to keep it simple).
Next goes the need for register to register information movement. It's partially the hardware issue. Internal processor's lines connect registers with processor's calculation unit (arithmetic logic unit or ALU). But in the process of processor evolution there was time when not all registers were connected to the ALU and some operations were possible only for a particular register. It means if we have our information in the register it doesn't mean we actually can use it and just have to copy it to another register. But sometime we need the copy because of the algorithm involved. For example - to calculate a square of a number we need to multiply the number with itself, so, we have a need for another copy of the number.
Well, now it should be simple enough - there's just some voltage levels and they just represent our information. When we want to use our information we often have to copy it because of the need for speed or hardware issues or just because of the algorithm involved. And the best way for a processor to access the information is to read it from processor's registers. That's why we need to copy our bits (voltage levels) from one register to another.