@Test public void testPushEsp() throws InternalTranslationException, InterpreterException { interpreter.setRegister( "esp", BigInteger.valueOf(0x12345678), OperandSize.DWORD, ReilRegisterStatus.DEFINED); final MockOperandTree operandTree = new MockOperandTree(); operandTree.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword"); operandTree.root.m_children.add(new MockOperandTreeNode(ExpressionType.REGISTER, "esp")); final List<MockOperandTree> operands = Lists.newArrayList(operandTree); final IInstruction instruction = new MockInstruction("push", operands); translator.translate(environment, instruction, instructions); interpreter.interpret(TestHelpers.createMapping(instructions), BigInteger.valueOf(0x100)); assertEquals(BigInteger.valueOf(4L), BigInteger.valueOf(interpreter.getMemorySize())); assertEquals(0x12345678, interpreter.readMemoryDword(0x12345674)); assertEquals(2, TestHelpers.filterNativeRegisters(interpreter.getDefinedRegisters()).size()); }
@Test public void testPushL32() throws InternalTranslationException, InterpreterException { final MockOperandTree operandTree = new MockOperandTree(); operandTree.root = new MockOperandTreeNode(ExpressionType.SIZE_PREFIX, "dword"); operandTree.root.m_children.add( new MockOperandTreeNode(ExpressionType.IMMEDIATE_INTEGER, "12345678")); final List<MockOperandTree> operands = Lists.newArrayList(operandTree); final IInstruction instruction = new MockInstruction("push", operands); translator.translate(environment, instruction, instructions); interpreter.interpret(TestHelpers.createMapping(instructions), BigInteger.valueOf(0x100)); assertEquals(BigInteger.valueOf(0x1FFC), interpreter.getVariableValue("esp")); assertEquals(BigInteger.valueOf(4L), BigInteger.valueOf(interpreter.getMemorySize())); assertEquals(12345678, interpreter.readMemoryDword(0x1FFC)); assertEquals(2, TestHelpers.filterNativeRegisters(interpreter.getDefinedRegisters()).size()); }