Definition of registers
Required Knowledge
None.
Registers
Registers, from an engineer's point of view, are small pieces of memory (hence the name 'register memory') which are much faster, in terms of access time, than the bulk of memory on your mainboard. The register memory is located on the CPU. The size and amount of these pieces of register memory is dependant on the architecture of the processor. Taking the x86 architecture as an example, each piece of register memory is 32 bits (4 bytes) wide and is aranged as shown below.

In the above diagram we can see that a register is 32 bits and is split up in to 4 overlapping areas.
Each
? can be replaced with A/B/C or D to represent the various basic registers.
Taking EAX as an example, EAX represents the entire scope of the register, the full DWORD value. However, the 'first' (least significant) WORD value can be accessed by using the operand AX. Similarly, the first and second BYTES can be accessed using AL and AH respectively. The above diagram explains the 'structure' of the four ABCD registers (EAX, EBX, ECX and EDX). They have 32/16 and 8-bit addressing modes (EAX/AX and AH/AL, etc.) however the other registers do not have any way of being addressed as 8-bit registers, ie. they have only 32 and 16-bit components.
Thus, the registers ESI, EDI, EBP and ESP can simply be addressed as SI/DI/BP and SP, when 16-bit operations are required. EIP can be considered for all purposes as a pure 32-bit register, but you can't really move anything out or in to it, so can be ignored.
Access of the individual registers is restricted to assembly level programming (at least in all the programming languages I've seen) and the above sections of each register can be accessed individually through various
opcodes.
The following are the basic x86 CPU registers (General purpose registers):
- EAX, the accumulator register. It is here which the results of various opcodes return their values and it is this register in which most functions should place their 'return value'.
- EBX, the base register. This register was very useful in 16-bit mode, however it can be seen as a true general purpose register in 32-bit mode and thus used for whatever the Hell you want. :o
- ECX, the count register. This register is used in many loop sequences to store the current loop or the number of remaining loops etc. The loop/repeat related opcodes also use this register to define how many loops must be completed.
- EDX, the data register. The data register does not have a predefined purpose in many cases, however it is sometimes used to store data pertinent to the contents of the accumulator register (EAX).
- ESI, the Source Index register. The source index is used in many of the string opcodes which iterate over a certain area of memory. The source memory location is usually stored in this register.
- EDI, the Destination Index register. Similar to ESI but holds the address of the destination memory of the function.
- EBP, the 'base pointer' (For more information on this register see the stack.)
- ESP, the 'stack pointer' (For more information on this register see the stack.)
- EIP, the Instruction Pointer register. This is a register which points to the next instruction to be read by the CPU and should/can not be altered directly, in the sense that only specific opcodes can change it (ie. you cannot use the instruction 'mov EIP, 004010C4' however you can use 'jmp 004010C4').
As well as these general purpose registers there many other registers available to the assembly programmer / reverser. These registers are more specific in their purpose. For instance the FPU registers are used in floating point operations and are optimized for this function.
Links to other register sets can be followed in the "Related links" section below.
Related links
Todo: Put links to other register sets here.
|
|
Attachment
|
Size
|
Date Added
|
|
|
Registers.PNG
|
1.57 KB
|
7/18/2005 11:22 am
|
| |
Categories
CategoryDefinitions
There are no comments on this page. [Add comment]