示例#1
0
  /**
   * Translates a PUSHFW instruction to REIL code.
   *
   * @param environment A valid translation environment.
   * @param instruction The PUSHFW instruction to translate.
   * @param instructions The generated REIL code will be added to this list
   * @throws InternalTranslationException if any of the arguments are null the passed instruction is
   *     not an PUSHFW instruction
   */
  @Override
  public void translate(
      final ITranslationEnvironment environment,
      final IInstruction instruction,
      final List<ReilInstruction> instructions)
      throws InternalTranslationException {
    TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "pushfw");

    if (instruction.getOperands().size() != 0) {
      throw new InternalTranslationException(
          "Error: Argument instruction is not a pushfw instruction (invalid number of operands)");
    }

    final long baseOffset = instruction.getAddress().toLong() * 0x100;
    long offset = baseOffset;

    final String result =
        Helpers.shiftFlagsIntoValue(environment, offset, OperandSize.WORD, instructions);

    offset = baseOffset + instructions.size();

    Helpers.generatePush(environment, offset, result, OperandSize.WORD, instructions);
  }