UML Internal Register Opcodes

From MAMEDEV Wiki

Below is a detailed description of all the UML internal register opcodes. For general information about the UML, please see UML Architecture.

GETEXP

Usage:

GETEXP  dest

Codegen Shorthand:

UML_GETEXP(block, PTYPE(dest));

Parameters:

  • dest — a 32-bit integer register or memory location

Flags: undefined

Description: The GETEXP opcode fetches the current value of the internal EXP (exception parameter) register. The EXP is set equal to the parameter value that was specified by the most recently executed EXH opcode, or is set equal to the pc parameter from a HASHJMP opcode that failed to find any associated code.

Example:

void generate_get_exception_parameter_in_i7(drcuml_block *block)
{
    UML_GETEXP(block, IREG(7));
}

GETFLGS

Usage:

GETFLGS dest,mask

Codegen Shorthand:

UML_GETFLGS(block, PTYPE(dest), mask);

Parameters:

  • dest — a 32-bit integer register or memory location
  • mask — an immediate mask of the flags to be retrieved

Flags: undefined

Description: The GETFLGS opcode retrieves the current value of the UML flags and stores them in the target destination. Although all of the flags are available, it is rare that all flags are required, and often more efficient if the back-end only needs to fetch a subset of the flags. The mask parameter makes it possible to specify exactly which flags are needed. Bits in dest representing unrequested flags will be set to zero.

Example:

void generate_get_sign_and_zero_flags_in_i0(drcuml_block *block)
{
    UML_GETFLGS(block, IREG(0), DRCUML_FLAG_S | DRCUML_FLAG_Z);
}

GETFMOD

Usage:

GETFMOD dest

Codegen Shorthand:

UML_GETFMOD(block, PTYPE(mode));

Parameters:

  • dest — a 32-bit integer register or memory location

Flags: undefined

Description: The GETFMOD opcode retrieves the current floating point rounding mode. It will produce one of the following values:

  • DRCUML_FMOD_TRUNC (0) means truncate, or round toward zero
  • DRCUML_FMOD_ROUND (1) means round to nearest
  • DRCUML_FMOD_CEIL (2) means round toward positive infinity
  • DRCUML_FMOD_FLOOR (3) means round toward negative infinity

Example:

UINT32 saved_mode;

void generate_save_rounding_mode(drcuml_block *block)
{
    UML_GETFMOD(block, MEM(&saved_mode));
}

RESTORE

Usage:

RESTORE source

Codegen Shorthand:

UML_RESTORE(block, source);

Parameters:

  • source — a memory pointer to a drcuml_machine_state structure

Flags:

  • C — set to the value provided in source
  • V — set to the value provided in source
  • Z — set to the value provided in source
  • S — set to the value provided in source
  • U — set to the value provided in source

Description: The RESTORE opcode copies the provided drcuml_machine_state structure into the live UML machine state.

Example:

void generate_restore_machine_state(drcuml_block *block, drcuml_machine_state *state)
{
    UML_RESTORE(block, state);
}

SAVE

Usage:

SAVE    dest

Codegen Shorthand:

UML_SAVE(block, dest);

Parameters:

  • dest — a memory pointer to a drcuml_machine_state structure

Flags: undefined

Description: The SAVE opcode dumps the current UML machine state to the provided drcuml_machine_state structure. This state may be used for debugging or compliance analysis.

Example:

static drcuml_machine_state state;

void generate_save_machine_state(drcuml_block *block)
{
    UML_SAVE(block, &state);
}

SETFMOD

Usage:

SETFMOD mode

Codegen Shorthand:

UML_SETFMOD(block, PTYPE(mode));

Parameters:

  • mode — a 32-bit integer register, memory location, map variable, or immediate

Flags: undefined

Description: The SETFMOD opcode sets the currently active floating point rounding mode, which is implicitly used when performing most floating point operations (apart from those which explicitly specify a mode). The mode can be one of four values:

  • DRCUML_FMOD_TRUNC (0) means truncate, or round toward zero
  • DRCUML_FMOD_ROUND (1) means round to nearest
  • DRCUML_FMOD_CEIL (2) means round toward positive infinity
  • DRCUML_FMOD_FLOOR (3) means round toward negative infinity

Only the two least significant bits of the mode parameter are considered; all other bits are ignored. Note that the floating point mode is forgotten once an EXIT opcode is executed. A dynamic recompiler that relies on the rounding mode must reset it in its entry point via this opcode.

Example:

void generate_set_fixed_rounding_mode(drcuml_block *block, int mode)
{
    UML_SETFMOD(block, IMM(mode));
}