Exemplo n.º 1
0
  public Instruction decode(
      byte[] bytesArray,
      int index,
      int instrStartIndex,
      int segmentOverride,
      int prefixes,
      X86InstructionFactory factory) {
    this.byteIndex = index;
    this.instrStartIndex = instrStartIndex;
    this.prefixes = prefixes;

    int ModRM = readByte(bytesArray, byteIndex);
    int rm = ModRM & 7;

    FPInstructionDecoder instrDecoder = null;
    instrDecoder = floatGRPMap[number][rm];

    Instruction instr = null;
    if (instrDecoder != null) {
      instr =
          instrDecoder.decode(
              bytesArray, byteIndex, instrStartIndex, segmentOverride, prefixes, factory);
      byteIndex = instrDecoder.getCurrentIndex();
    } else {
      instr = factory.newIllegalInstruction();
    }
    return instr;
  }
Exemplo n.º 2
0
  public Instruction decode(
      BinaryInputBuffer bytesArray,
      int index,
      int instrStartIndex,
      int segmentOverride,
      int prefixes,
      X86InstructionFactory factory) {
    this.byteIndex = index;
    this.instrStartIndex = instrStartIndex;
    this.prefixes = prefixes;

    int ModRM = readByte(bytesArray, byteIndex);
    int reg = (ModRM >> 3) & 7;
    // int regOrOpcode = (ModRM >> 3) & 7;
    // int rm = ModRM & 7;

    int startIndexWithoutPrefix;

    // JK: FWAIT was broken
    if ((prefixes & PREFIX_FWAIT) != 0) startIndexWithoutPrefix = instrStartIndex + 1;
    else startIndexWithoutPrefix = instrStartIndex;

    int floatOpcode = InstructionDecoder.readByte(bytesArray, startIndexWithoutPrefix);

    FPInstructionDecoder instrDecoder = null;

    if (ModRM < 0xbf) {
      instrDecoder = floatMapOne[floatOpcode - 0xd8][reg];
    } else {
      instrDecoder = floatMapTwo[floatOpcode - 0xd8][reg];
    }

    Instruction instr = null;
    if (instrDecoder != null) {
      instr =
          instrDecoder.decode(
              bytesArray, byteIndex, instrStartIndex, segmentOverride, prefixes, factory);
      byteIndex = instrDecoder.getCurrentIndex();
    }

    return instr;
  }