Skip to content

Register

Neo edited this page Jul 23, 2021 · 3 revisions

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.

Table of Contents


Available registers

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.

General 32 bit

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.

  1. EAX
  2. ECX
  3. EDX
  4. EBX
  5. ESP
  6. EBP
  7. ESI
  8. EDI

Placeholder: R32


General 16 bit

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).

  1. AX
  2. CX
  3. DX
  4. BX
  5. SP
  6. BP
  7. SI
  8. DI

Placeholder: R16


General 8 bit

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).

  1. AL
  2. CL
  3. DL
  4. BL
  5. AH
  6. CH
  7. DH
  8. BH

Placeholder: R8


FPU Stack

All the FPU stack registers have the ST prefix with their respective indices as suffix.

  1. ST0
  2. ST1
  3. ST2
  4. ST3
  5. ST4
  6. ST5
  7. ST6
  8. 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

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.

  1. MM0
  2. MM1
  3. MM2
  4. MM3
  5. MM4
  6. MM5
  7. MM6
  8. MM7

Placeholder: MM$

Since these overlap with the SSE registers mentioned below, we cannot use both simultaneously.


SSE

SSE stands for Streaming SIMD Extensions. Essentially the floating point equivalent of MMX with 128 bit registers.

  1. XMM0
  2. XMM1
  3. XMM2
  4. XMM3
  5. XMM4
  6. XMM5
  7. XMM6
  8. XMM7

Placeholder: XMM$


Properties

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

Functions

All the registers have these functions as well.

is

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 a Register and the Index & Width match else false


isPlaceHolder

Checks whether the current register is one of the placeholders.

Syntax:

<reg>.isPlaceHolder()

Returns: true or false


isAcc

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 or false


toString

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.


IsReg

In order to test whether a value is a Register object, you can use this function.

Syntax:

IsReg(value)

Returns: true or false


Return to top


Further reading