Register - Neo-Mind/WARP GitHub Wiki
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.
EAXECXEDXEBXESPEBPESIEDI
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).
AXCXDXBXSPBPSIDI
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).
ALCLDLBLAHCHDHBH
Placeholder:
R8
All the FPU stack registers have the ST prefix with their respective indices as suffix.
ST0ST1ST2ST3ST4ST5ST6ST7
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.
MM0MM1MM2MM3MM4MM5MM6MM7
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.
XMM0XMM1XMM2XMM3XMM4XMM5XMM6XMM7
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:
trueif reg2 is aRegisterand the Index & Width match elsefalse
Checks whether the current register is one of the placeholders.
Syntax:
<reg>.isPlaceHolder()Returns:
trueorfalse
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:
trueorfalse
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:
trueorfalse