use of com.google.security.zynamics.reil.OperandSize in project binnavi by google.
the class THUMBCmnTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
final String sourceRegister2 = (registerOperand2.getValue());
final OperandSize bt = OperandSize.BYTE;
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();
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1));
// N Flag
instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-31L), bt, tmpVar2));
instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar2, bt, String.valueOf(1L), bt, "N"));
// Z Flag
instructions.add(ReilHelpers.createBisz(baseOffset++, qw, tmpVar1, bt, "Z"));
// C Flag
instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-32L), bt, tmpVar3));
instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar3, bt, String.valueOf(1L), bt, "C"));
Helpers.addOverflow(baseOffset, environment, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1, "V", 32);
}
use of com.google.security.zynamics.reil.OperandSize in project binnavi by google.
the class THUMBCmpTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
final String sourceRegister2 = (registerOperand2.getValue());
final OperandSize bt = OperandSize.BYTE;
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();
instructions.add(ReilHelpers.createSub(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1));
// N Flag
instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-31L), bt, tmpVar2));
instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar2, bt, String.valueOf(1L), bt, "N"));
// Z Flag
instructions.add(ReilHelpers.createBisz(baseOffset++, qw, tmpVar1, bt, "Z"));
// C Flag
instructions.add(ReilHelpers.createBsh(baseOffset++, qw, tmpVar1, dw, String.valueOf(-32L), bt, tmpVar3));
instructions.add(ReilHelpers.createAnd(baseOffset++, bt, tmpVar3, bt, String.valueOf(1L), bt, tmpVar4));
instructions.add(ReilHelpers.createBisz(baseOffset++, bt, tmpVar4, bt, "C"));
// V Flag
Helpers.subOverflow(baseOffset, environment, instruction, instructions, dw, sourceRegister1, dw, sourceRegister2, qw, tmpVar1, "V", 32);
}
use of com.google.security.zynamics.reil.OperandSize in project binnavi by google.
the class THUMBCpyTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
final String sourceRegister2 = (registerOperand2.getValue());
final OperandSize dw = OperandSize.DWORD;
long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
instructions.add(ReilHelpers.createStr(baseOffset++, dw, sourceRegister2, dw, sourceRegister1));
}
use of com.google.security.zynamics.reil.OperandSize in project binnavi by google.
the class THUMBEorTranslator 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 String sourceRegister1 = (registerOperand1.getValue());
final String sourceRegister2 = (registerOperand2.getValue());
final OperandSize bt = OperandSize.BYTE;
final OperandSize wd = OperandSize.WORD;
final OperandSize dw = OperandSize.DWORD;
long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
instructions.add(ReilHelpers.createXor(baseOffset++, dw, sourceRegister1, dw, sourceRegister2, dw, sourceRegister1));
// N flag
instructions.add(ReilHelpers.createBsh(baseOffset++, dw, sourceRegister1, wd, String.valueOf(-31), bt, "N"));
// Z flag
instructions.add(ReilHelpers.createBisz(baseOffset++, dw, sourceRegister1, bt, "Z"));
}
use of com.google.security.zynamics.reil.OperandSize in project binnavi by google.
the class THUMBLdmiaTranslator 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).getChildren().size() == 1 ? instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().get(0) : instruction.getOperands().get(0).getRootNode().getChildren().get(0);
final Boolean wback = instruction.getOperands().get(0).getRootNode().getChildren().get(0).getChildren().size() == 1 ? true : false;
/*
* get size to see how many registers we have to load
*/
final int registerListLength = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().size();
final String sourceRegister1 = (registerOperand1.getValue());
final OperandSize bt = OperandSize.BYTE;
final OperandSize dw = OperandSize.DWORD;
long baseOffset = (instruction.getAddress().toLong() * 0x100) + instructions.size();
final String tmpAddress = environment.getNextVariableString();
instructions.add(ReilHelpers.createStr(baseOffset++, dw, sourceRegister1, dw, tmpAddress));
for (int i = 0; i < registerListLength; i++) {
final String currentRegisterValue = instruction.getOperands().get(1).getRootNode().getChildren().get(0).getChildren().get(i).getValue();
instructions.add(ReilHelpers.createLdm(baseOffset++, dw, tmpAddress, dw, currentRegisterValue));
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, tmpAddress, bt, String.valueOf(4L), dw, tmpAddress));
}
if (wback) {
instructions.add(ReilHelpers.createAdd(baseOffset++, dw, sourceRegister1, dw, String.valueOf(registerListLength * 4), dw, sourceRegister1));
}
}
Aggregations