Skip to content

IPrefix

Neo edited this page Jul 23, 2021 · 2 revisions

IPrefix

IPrefix class is a representation of the various Instruction prefixes. All the known prefixes 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 prefixes

Name Description
CS Segment override to Code Segment.
DS Segment override to Data Segment.
ES Segment override to Extra Segment.
FS Segment override to General Segment 1.
GS Segment override to General Segment 2.
SS Segment override to Stack Segment.
OPCH OPerand size CHange - 32 bit to 16, 64 bit to 128 etc.
AD16 ADdress override to 16 bit.
Also used in float instructions for converting to lower size.
ILOCK Repeat/LOCK to grant exclusive use of all shared memory.
IREPE String manipulation - Repeat string operation.
IREPN String manipulation - Repeat string operation.

Properties

All the objects listed above contain the following properties.

Property name Description
Value The underlying value as hex.

In addition the IPrefix class itself has a List member containing all the Values.


Functions

is

Checks whether the current prefix is the same as the one specified.

Syntax:

<obj>.is(pre)
Argument Description
pre The prefix to compare against.

Returns: true if pre is an IPrefix and the Value matches else false


toString

Override of toString to return the underlying Value as a hex.

Primarily used by the [Instr] class, while generating the instruction's hex equivalent.

Syntax;

<obj>.toString()

Wrappers

You may have noticed that the last 3 prefixes begin with an I. This is done intentionally to avoid conflict with the wrapper functions.

For the last 3 prefixes, they are usually written before the instructions themselves (in the truest sense of the word prefix).

To mimic this behavior in code as well, there are 4 wrapping functions available for them :

  • LOCK
  • REPE
  • REPN
  • REP (Just an alias for REPE needed for some of the string instructions)

For e.g.

REP(LODS(AX)) //this will add the REP prefix to loop the LODS instruction.

Further reading

Clone this wiki locally