use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMQsub8Translator method translateCore.
@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
final IOperandTreeNode registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
final IOperandTreeNode registerOperand3 = instruction.getOperands().get(2).getRootNode().getChildren().get(0);
final String targetRegister = (registerOperand1.getValue());
final String sourceRegister1 = (registerOperand2.getValue());
final String sourceRegister2 = (registerOperand3.getValue());
final String subOperation = "SUB";
final long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
new Processor() {
@Override
protected String[] process(final long offset, final String[] firstFour, final String[] secondFour) {
final String diff1 = environment.getNextVariableString();
final String diff2 = environment.getNextVariableString();
final String diff3 = environment.getNextVariableString();
final String diff4 = environment.getNextVariableString();
final String trueDiff1 = environment.getNextVariableString();
final String trueDiff2 = environment.getNextVariableString();
final String trueDiff3 = environment.getNextVariableString();
final String trueDiff4 = environment.getNextVariableString();
long baseOffset = offset;
// do the subs
instructions.add(ReilHelpers.createSub(baseOffset++, dw, firstFour[0], dw, secondFour[0], dw, trueDiff1));
instructions.add(ReilHelpers.createSub(baseOffset++, dw, firstFour[1], dw, secondFour[1], dw, trueDiff2));
instructions.add(ReilHelpers.createSub(baseOffset++, dw, firstFour[2], dw, secondFour[2], dw, trueDiff3));
instructions.add(ReilHelpers.createSub(baseOffset++, dw, firstFour[3], dw, secondFour[3], dw, trueDiff4));
// do the sats
Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[0], dw, secondFour[0], dw, trueDiff1, subOperation, diff1, 8, "");
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[1], dw, secondFour[1], dw, trueDiff2, subOperation, diff2, 8, "");
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[2], dw, secondFour[2], dw, trueDiff3, subOperation, diff3, 8, "");
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, firstFour[3], dw, secondFour[3], dw, trueDiff4, subOperation, diff4, 8, "");
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
return new String[] { diff1, diff2, diff3, diff4 };
}
}.generate(environment, baseOffset, 8, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMQsubTranslator method translateCore.
@Override
protected void translateCore(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) {
final IOperandTreeNode registerOperand1 = instruction.getOperands().get(0).getRootNode().getChildren().get(0);
final IOperandTreeNode registerOperand2 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
final IOperandTreeNode registerOperand3 = instruction.getOperands().get(2).getRootNode().getChildren().get(0);
final String targetRegister = (registerOperand1.getValue());
final String sourceRegister1 = (registerOperand2.getValue());
final String sourceRegister2 = (registerOperand3.getValue());
final OperandSize dw = OperandSize.DWORD;
final OperandSize qw = OperandSize.QWORD;
long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
final String tmpResult = environment.getNextVariableString();
instructions.add(ReilHelpers.createSub(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, qw, tmpResult));
Helpers.signedSat(baseOffset, environment, instruction, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, tmpResult, "SUB", targetRegister, 32L, "Q");
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class Helpers method translateChildrenOfNode.
/**
* Iterates over the children of a node in the operand tree and generates
* translations for them.
* @param environment A valid translation environment.
* @param expression The expression to translate.
* @param size The size of the expression.
* @param loadOperand A flag that indicates whether a LDM instruction should be added for memory
* access operands.
* @param baseOffset The offset of the first instruction. This has to be a
* Long (and not a long) so that we have reference semantics; so that
* this function can update the baseOffset of calling functions.
*
* @return A list of translations for the individual children.
* @throws InternalTranslationException
*/
private static List<TranslationResult> translateChildrenOfNode(final ITranslationEnvironment environment, final IOperandTreeNode expression, OperandSize size, final boolean loadOperand, Long baseOffset) throws InternalTranslationException {
// The list in which we will gather the partial translations. This will be
// returned to the caller.
final List<TranslationResult> partialResults = new ArrayList<>();
// Get all child nodes of the current node and sort them. The sorting is
// important for precedence in arithmetic expressions.
final List<? extends IOperandTreeNode> children = expression.getChildren();
Collections.sort(children, comparator);
// ... and process them
for (final IOperandTreeNode child : children) {
// Get the code for the child expression.
final TranslationResult nextResult = loadOperand(environment, baseOffset, child, isSegmentExpression(expression.getValue()) ? expression : null, size, loadOperand);
partialResults.add(nextResult);
baseOffset += nextResult.getInstructions().size();
}
return partialResults;
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class SubfzeTranslator method translate.
@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "subfze");
final IOperandTreeNode registerOperand1 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
SubGenerator.generate(instruction.getAddress().toLong() * 0x100, environment, instruction, instructions, "subfze", registerOperand1.getValue(), String.valueOf(0x0L), false, false, true, true);
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class SubfzeoTranslator method translate.
@Override
public void translate(final ITranslationEnvironment environment, final IInstruction instruction, final List<ReilInstruction> instructions) throws InternalTranslationException {
TranslationHelpers.checkTranslationArguments(environment, instruction, instructions, "subfzeo");
final IOperandTreeNode registerOperand1 = instruction.getOperands().get(1).getRootNode().getChildren().get(0);
SubGenerator.generate(instruction.getAddress().toLong() * 0x100, environment, instruction, instructions, "subfzeo", registerOperand1.getValue(), String.valueOf(0x0L), false, true, true, true);
}
Aggregations