use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMSmmlsTranslator 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 IOperandTreeNode registerOperand4 = instruction.getOperands().get(3).getRootNode().getChildren().get(0);
final String targetRegister = (registerOperand1.getValue());
final String sourceRegister1 = (registerOperand2.getValue());
final String sourceRegister2 = (registerOperand3.getValue());
final String sourceRegister3 = (registerOperand4.getValue());
final OperandSize wd = OperandSize.WORD;
final OperandSize dw = OperandSize.DWORD;
final OperandSize qw = OperandSize.QWORD;
long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
final String tmpVar1 = environment.getNextVariableString();
final String tmpVar2 = environment.getNextVariableString();
final String tmpVar3 = environment.getNextVariableString();
final String tmpVar4 = environment.getNextVariableString();
final String value = environment.getNextVariableString();
Helpers.signedMul(baseOffset, environment, instruction, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, value);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister3, dw, String.valueOf(32L), qw, tmpVar1));
if (instruction.getMnemonic().contains("R")) {
instructions.add(ReilHelpers.createSub(baseOffset++, qw, tmpVar1, qw, value, qw, tmpVar2));
instructions.add(ReilHelpers.createAdd(baseOffset++, qw, tmpVar2, dw, String.valueOf(0x80000000L), qw, tmpVar3));
} else {
instructions.add(ReilHelpers.createSub(baseOffset++, qw, tmpVar1, qw, value, qw, tmpVar3));
}
instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar3, wd, String.valueOf(-32L), dw, tmpVar4));
instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpVar4, dw, String.valueOf(0xFFFFFFFFL), dw, targetRegister));
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMSmmulTranslator 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 wd = OperandSize.WORD;
final OperandSize dw = OperandSize.DWORD;
final OperandSize qw = OperandSize.QWORD;
long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
final String tmpVar1 = environment.getNextVariableString();
final String value = environment.getNextVariableString();
Helpers.signedMul(baseOffset, environment, instruction, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, value);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
if (instruction.getMnemonic().contains("R")) {
instructions.add(ReilHelpers.createAdd(baseOffset++, qw, value, dw, String.valueOf(0x80000000L), dw, value));
}
instructions.add(ReilHelpers.createBsh(baseOffset++, qw, value, wd, String.valueOf(-32L), dw, tmpVar1));
instructions.add(ReilHelpers.createAnd(baseOffset++, dw, tmpVar1, dw, String.valueOf(0xFFFFFFFFL), dw, targetRegister));
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMShadd16Translator 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 long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
new Processor() {
@Override
protected int getResultShiftDelta() {
return -1;
}
@Override
protected String[] process(final long offset, final String[] firstTwo, final String[] secondTwo) {
final String sum1 = environment.getNextVariableString();
final String sum2 = environment.getNextVariableString();
long baseOffset = offset - instructions.size();
// sign extend the operands to reflect the signed addition
Helpers.signExtend(baseOffset + instructions.size(), environment, instruction, instructions, dw, firstTwo[0], dw, firstTwo[0], 16);
Helpers.signExtend(baseOffset + instructions.size(), environment, instruction, instructions, dw, firstTwo[1], dw, firstTwo[1], 16);
Helpers.signExtend(baseOffset + instructions.size(), environment, instruction, instructions, dw, secondTwo[0], dw, secondTwo[0], 16);
Helpers.signExtend(baseOffset + instructions.size(), environment, instruction, instructions, dw, secondTwo[1], dw, secondTwo[1], 16);
// do the adds
instructions.add(ReilHelpers.createAdd(baseOffset + instructions.size(), dw, firstTwo[0], dw, secondTwo[0], dw, sum1));
instructions.add(ReilHelpers.createAdd(baseOffset + instructions.size(), dw, firstTwo[1], dw, secondTwo[1], dw, sum2));
return new String[] { sum1, sum2 };
}
}.generate(environment, baseOffset, 16, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMShadd8Translator 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 long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
new Processor() {
@Override
protected int getResultShiftDelta() {
return -1;
}
@Override
protected String[] process(final long offset, final String[] firstFour, final String[] secondFour) {
final String sum1 = environment.getNextVariableString();
final String sum2 = environment.getNextVariableString();
final String sum3 = environment.getNextVariableString();
final String sum4 = environment.getNextVariableString();
long baseOffset = offset;
// sign extend the operands to reflect signed addition
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[0], dw, firstFour[0], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[1], dw, firstFour[1], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[2], dw, firstFour[2], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[3], dw, firstFour[3], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[0], dw, secondFour[0], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[1], dw, secondFour[1], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[2], dw, secondFour[2], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[3], dw, secondFour[3], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
// do the adds
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[0], dw, secondFour[0], dw, sum1));
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[1], dw, secondFour[1], dw, sum2));
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[2], dw, secondFour[2], dw, sum3));
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, firstFour[3], dw, secondFour[3], dw, sum4));
return new String[] { sum1, sum2, sum3, sum4 };
}
}.generate(environment, baseOffset, 8, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
use of com.google.security.zynamics.zylib.disassembly.IOperandTreeNode in project binnavi by google.
the class ARMShsub8Translator 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 long baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
new Processor() {
@Override
protected int getResultShiftDelta() {
return -1;
}
@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;
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[0], dw, firstFour[0], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[1], dw, firstFour[1], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[2], dw, firstFour[2], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, firstFour[3], dw, firstFour[3], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[0], dw, secondFour[0], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[1], dw, secondFour[1], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[2], dw, secondFour[2], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signExtend(baseOffset, environment, instruction, instructions, dw, secondFour[3], dw, secondFour[3], 8);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSub(baseOffset, environment, instruction, instructions, secondFour[0], firstFour[0], diff1, trueDiff1);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSub(baseOffset, environment, instruction, instructions, secondFour[1], firstFour[1], diff2, trueDiff2);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSub(baseOffset, environment, instruction, instructions, secondFour[2], firstFour[2], diff3, trueDiff3);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
Helpers.signedSub(baseOffset, environment, instruction, instructions, secondFour[3], firstFour[3], diff4, trueDiff4);
baseOffset = ReilHelpers.nextReilAddress(instruction, instructions);
return new String[] { diff1, diff2, diff3, diff4 };
}
}.generate(environment, baseOffset, 8, sourceRegister1, sourceRegister2, targetRegister, instructions);
}
Aggregations