Hi u was just studying about register in the cpu and surfed the net to see their defenition and try to understand their purpose. However it turned out that some of the results were a little bit complicated and with difficult english.

Related registers : Segment

thanks for your help

8 Years
Discussion Span
Last Post by Duoas

There are numerous types of memory.

There is external memory (stuff stored elsewhere like on disk or over a network or the like). Everything else I'll say here relates to internal memory: memory your computer has direct access to.

There is RAM -- Random Access Memory, which is accessed via an address. RAM is typically designed to be pretty quick to access so that programs will run quickly. However, there is still a significant performance hit to accessing it, because it is accessed through the computers data bus (the memory is stored on one or more chips that attach to your motherboard).

To help speed things along, there is a special kind of memory called the Register File, which is basically a certain number of memory locations that are directly accessible by the CPU (they are part of the same chip as the CPU). Accessing them is lightning fast and suggests their use for certain operations, like additions and comparisons.

Individual "registers" often have special functionalities attached to them. For example, on MIPS systems register 0 ($0) always has the value 0 (zero). You can assign to it but its value never changes. This is very handy because zero is such a useful number when computing.

Another example is on Intel 80x86 processors. The [E]CX register is hardwired for counting through loops. Its special integration into the hardware for such tasks make it very efficient and fast for looping/repetitive operations.

Because these special memory locations are so attached to the CPU, there cannot be too many of them (for very good reasons you'll have to trust me on). So there must be some way to copy the contents of one memory type to the other: RAM to Register and Register to RAM.

In order to do this, the RAM must be indexed by number. Older x86 processors had a limitation in the size of the CPU indexing registers: they were only 16-bits wide, meaning that any one register could only access 65536 bytes at a time. However, a typical PC could have up to 20-bits worth of addressable RAM (16 times the amount a single register could hold, or 1048576 bytes).

The way Intel decided to handle this is to implement a "segment" register, one which had a granularity of 16 bytes -- it could access memory in 16 byte increments. Given a segment register and an index register, often written as DS:SI or the like, they could be combined to address the full range of memory. (The way it was actually done is weird, but don't worry too much about that.)

Modern computer architectures use the same concept. A "segment" register is one that indexes the beginning of a certain segment of memory, to which the address in another (index) register is relative.

A stack is a specific way of organizing memory. Google it to read more. Processors typically expect the software to initialize a stack that the processor can use to manage the software running on it. For example, if you write a subroutine and call it, how does the computer know where to continue when the subroutine returns? That information is pushed onto the stack before transferring to the routine, and popped off before returning.

In order to keep order, certain registers have the special capabilities of referencing the beginning, top, and indices into the stack.

Instruction pointer registers likewise have the special purpose of indexing where in RAM the next opcode (or instruction) to execute is found.

Hope this helps.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.