-
-
Notifications
You must be signed in to change notification settings - Fork 53
Register
Register class is a representation of all the various CPU registers. Most of the known CPU registers have already been created as objects using this class.
So generally you use those, instead of creating new instances of this class.
The following instances are available as of now. Each category has 8 registers and a placeholder register.
The placeholders are utilized in hex code where you only know the register's bitwidth.
For e.g. R16
can represent any of the 8 general purpose 16 bit registers.
These are the most commonly used registers in every code you see.
The first 4 are called Data Registers, the middle 2 are Pointer registers and the last 2 are Index registers.
EAX
ECX
EDX
EBX
ESP
EBP
ESI
EDI
Placeholder:
R32
These are the lower halves of the General purpose 32 bit registers listed above.
The last two are often used for index addressing (Source Index & Destination Index for string operations).
AX
CX
DX
BX
SP
BP
SI
DI
Placeholder:
R16
These are the upper and lower halves of the first 4 General purpose 16 bit registers listed above (i.e. lower parts of the Data registers).
AL
CL
DL
BL
AH
CH
DH
BH
Placeholder:
R8
All the FPU stack registers have the ST prefix with their respective indices as suffix.
ST0
ST1
ST2
ST3
ST4
ST5
ST6
ST7
Placeholder:
ST$
There is also an ST function available if you want to access them with their indices indirectly.
For e.g. ST(idx)
where idx = 2 will give you ST2
MMX is a supplemental instruction set introduced in 1996. Most of these are Single Instruction, Multiple Data. To support these there are eight 64-bit registers available.
MM0
MM1
MM2
MM3
MM4
MM5
MM6
MM7
Placeholder:
MM$
Since these overlap with the SSE registers mentioned below, we cannot use both simultaneously.
SSE stands for Streaming SIMD Extensions. Essentially the floating point equivalent of MMX with 128 bit registers.
XMM0
XMM1
XMM2
XMM3
XMM4
XMM5
XMM6
XMM7
Placeholder:
XMM$
All the objects/instances listed above contain the following properties.
Property name | Description |
---|---|
Name |
Name of the Register. For e.g. EAX has the name "EAX"
|
Index |
Index of the Register. |
Width |
Bit Width of the Register |
All the registers have these functions as well.
Checks whether the current register is the same as the one specified.
Syntax:
<reg>.is(reg2)
Argument | Description |
---|---|
reg2 |
The register object to compare against. |
Returns:
true
if reg2 is aRegister
and the Index & Width match elsefalse
Checks whether the current register is one of the placeholders.
Syntax:
<reg>.isPlaceHolder()
Returns:
true
orfalse
Checks whether the current register is a primary one i.e. Index == 0. For General purpose register set this means the Accumulator (hence the name).
Syntax:
<reg>.isAcc()
Returns:
true
orfalse
Override of toString
function for retrieving the details of the register as a string. Useful for debugging.
Syntax:
<reg>.toString()
This function is automatically invoked when the object is used in a string context. For e.g. with the Debug function.
In order to test whether a value is a Register object, you can use this function.
Syntax:
IsReg(value)
Returns:
true
orfalse