org.ow2.asmdex.instruction
Class InstructionFormat23X

java.lang.Object
  extended by org.ow2.asmdex.instruction.Instruction
      extended by org.ow2.asmdex.instruction.InstructionFormat23X
All Implemented Interfaces:
IThreeRegistersInstruction

public class InstructionFormat23X
extends Instruction
implements IThreeRegistersInstruction

Encodes and decodes an instruction built with the Dalvik format 23X.

Author:
Julien Névo

Field Summary
 
Fields inherited from class org.ow2.asmdex.instruction.Instruction
lineNumber, opcodeByte, opcodeHighOrderByte
 
Constructor Summary
InstructionFormat23X(int opcode, int registerA, int registerB, int registerC)
          Constructor of the Instruction by providing all the elements it's composed of.
 
Method Summary
static int getEncodedRegisterBAndC(IDalvikValueReader reader)
          Returns the RegisterB and C encoded as an int, from where the Reader points.
 int getRegisterA()
          Gets the index of first register
static int getRegisterA(int opcode)
          Returns the RegisterA encoded in the given 16-bit opcode.
 int getRegisterB()
          Gets the index of second register
static int getRegisterBFromEncodedRegisterBAndC(int encodedRegisterBAndC)
          Returns the RegisterB encoded inside the given value, that should contained both RegisterB and C from the getEncodedRegisterBAndC method.
 int getRegisterC()
          Gets the index of third register
static int getRegisterCFromEncodedRegisterBAndC(int encodedRegisterBAndC)
          Returns the RegisterC encoded inside the given value, that should contained both RegisterB and C from the getEncodedRegisterBAndC method.
 int getSize()
          Returns the size of the instruction in bytes.
static void skip(IDalvikValueReader reader)
          Skips the data of this Instruction.
 void write(ByteVector out, ConstantPool constantPool)
          Encodes the instruction, in the Dalvik format, to an output buffer.
 
Methods inherited from class org.ow2.asmdex.instruction.Instruction
getInstructionSizeInByte, getLineNumber, getOpcodeByte, getOpcodeHighOrderByte, setLineNumber, test4BitsLimit, test4BitsLimit
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstructionFormat23X

public InstructionFormat23X(int opcode,
                            int registerA,
                            int registerB,
                            int registerC)
Constructor of the Instruction by providing all the elements it's composed of.

Parameters:
opcode - 8 or 16 bits opcode.
registerA - the first register to store.
registerB - the second register to store.
registerC - the third register to store.
Method Detail

getRegisterA

public int getRegisterA()
Description copied from interface: IThreeRegistersInstruction
Gets the index of first register

Specified by:
getRegisterA in interface IThreeRegistersInstruction
Returns:
index

getRegisterB

public int getRegisterB()
Description copied from interface: IThreeRegistersInstruction
Gets the index of second register

Specified by:
getRegisterB in interface IThreeRegistersInstruction
Returns:
index

getRegisterC

public int getRegisterC()
Description copied from interface: IThreeRegistersInstruction
Gets the index of third register

Specified by:
getRegisterC in interface IThreeRegistersInstruction
Returns:
index

getRegisterA

public static int getRegisterA(int opcode)
Returns the RegisterA encoded in the given 16-bit opcode.

Returns:
the RegisterA.

getEncodedRegisterBAndC

public static int getEncodedRegisterBAndC(IDalvikValueReader reader)
Returns the RegisterB and C encoded as an int, from where the Reader points. It must be performed only once after having read the opcode.. To decode the returned int, use getRegisterBFromEncodedRegisterBAndC and getRegisterCFromEncodedRegisterBAndC.

Parameters:
reader - reader pointing after the 16-bit opcode.
Returns:
the RegisterB and C, encoded as one single int.

getRegisterBFromEncodedRegisterBAndC

public static int getRegisterBFromEncodedRegisterBAndC(int encodedRegisterBAndC)
Returns the RegisterB encoded inside the given value, that should contained both RegisterB and C from the getEncodedRegisterBAndC method.

Parameters:
encodedRegisterBAndC - the RegisterB and C encoded as an int.
Returns:
the RegisterB.

getRegisterCFromEncodedRegisterBAndC

public static int getRegisterCFromEncodedRegisterBAndC(int encodedRegisterBAndC)
Returns the RegisterC encoded inside the given value, that should contained both RegisterB and C from the getEncodedRegisterBAndC method.

Parameters:
encodedRegisterBAndC - the RegisterB and C encoded as an int.
Returns:
the RegisterC.

skip

public static void skip(IDalvikValueReader reader)
Skips the data of this Instruction.

Parameters:
reader - reader on the Instruction to parse, pointing after the 16-bit opcode.

getSize

public int getSize()
Description copied from class: Instruction
Returns the size of the instruction in bytes.

Specified by:
getSize in class Instruction
Returns:
the size of the instruction in bytes.

write

public void write(ByteVector out,
                  ConstantPool constantPool)
Description copied from class: Instruction
Encodes the instruction, in the Dalvik format, to an output buffer.

Specified by:
write in class Instruction
Parameters:
out - output buffer.
constantPool - the constantPool.