From: <mic...@us...> - 2007-05-08 16:35:57
|
Revision: 105 http://svn.sourceforge.net/pearcolator/?rev=105&view=rev Author: michael_baer Date: 2007-05-08 09:35:56 -0700 (Tue, 08 May 2007) Log Message: ----------- Fixed bugs in IntMultiply, LongMultiply and Rotate-Right-Extend (RRX) uncovered by sanity tests. Modified Paths: -------------- src/org/binarytranslator/arch/arm/decoder/ARM_Instructions.java src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Instructions.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Instructions.java 2007-05-02 18:27:00 UTC (rev 104) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Instructions.java 2007-05-08 16:35:56 UTC (rev 105) @@ -92,8 +92,7 @@ } /** Base class for multiply operations. */ - protected abstract static class MultiplyTemplate - extends ThreeRegistersTemplate { + protected abstract static class MultiplyTemplate extends Instruction { /** @see #updateConditionCodes() */ protected final boolean updateConditionCodes; @@ -103,13 +102,25 @@ /** @see #getRs() */ protected final byte Rs; + + /** @see #getRn() */ + protected final byte Rn; + + /** @see #getRm() */ + protected final byte Rm; + + /** @see #getRd() */ + protected final byte Rd; protected MultiplyTemplate(int instr) { super(instr); updateConditionCodes = Utils.getBit(instr, 20); accumulate = Utils.getBit(instr, 21); + Rd = (byte) Utils.getBits(instr, 16, 19); + Rn = (byte) Utils.getBits(instr, 12, 15); Rs = (byte) Utils.getBits(instr, 8, 11); + Rm = (byte) Utils.getBits(instr, 0, 3); } /** Returns true, if the condition codes shall be updated by the result of this operation. */ @@ -126,6 +137,21 @@ public final byte getRs() { return Rs; } + + /** Returns the register number of the Rm operand register. */ + public final byte getRm() { + return Rm; + } + + /** Returns the register number of the Rn operand register. */ + public final byte getRn() { + return Rn; + } + + /** Returns the register number of the Rd destination register. */ + public final byte getRd() { + return Rd; + } } /** Base class for coprocessor instructions. */ @@ -172,7 +198,7 @@ LSR, ASR, ROR, - RRE + RRX } /** Creates an operand wrapper around a 12 bit immediate value. */ @@ -229,7 +255,7 @@ if (shift == ShiftType.ROR) { //However, if the shift type was RotateRight, then ARM meant do a RotateRightExtend by 1 - return new RegisterShiftImmediateOperand(shiftedRegister, shift, (byte)1); + return new RegisterShiftImmediateOperand(shiftedRegister, ShiftType.RRX, (byte)1); } //in all other cases, an immediate of zero denotes a shift by 32 @@ -591,7 +617,7 @@ } //this instruction variant yields an undefined result - if (DBT.VerifyAssertions) DBT._assert(Rd != 15 || !writeBack); + if (DBT.VerifyAssertions) DBT._assert(Rd != Rn || !writeBack); } /** Returns true, if this memory access shall be treated as if it had been done in user mode. */ @@ -650,7 +676,6 @@ if (DBT.VerifyAssertions) DBT._assert((accumulate || Rn == 0) && Rd != 15); } - @Override public void visit(ARM_InstructionVisitor visitor) { visitor.visit(this); } @@ -668,7 +693,7 @@ unsigned = Utils.getBit(instr, 22); //check for instruction combinations that show undefined behaviour on ARM - if (DBT.VerifyAssertions) DBT._assert((accumulate || Rn == 0) && Rd != 15); + if (DBT.VerifyAssertions) DBT._assert(Rd != 15); } /** Long multiplication stores its result in two registers. This function gets the register which receives the high int. */ @@ -686,7 +711,6 @@ return unsigned; } - @Override public void visit(ARM_InstructionVisitor visitor) { visitor.visit(this); } Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java 2007-05-02 18:27:00 UTC (rev 104) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Interpreter.java 2007-05-08 16:35:56 UTC (rev 105) @@ -162,7 +162,7 @@ case ROR: return Integer.rotateRight(value, shiftAmount); - case RRE: + case RRX: if (regs.isCarrySet()) return (value >> 1) | 0x80000000; else @@ -315,7 +315,7 @@ return Integer.rotateRight(value, shiftAmount); } - case RRE: + case RRX: shifterCarryOut = (value & 0x1) != 0; if (regs.isCarrySet()) Modified: src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java =================================================================== --- src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java 2007-05-02 18:27:00 UTC (rev 104) +++ src/org/binarytranslator/arch/arm/decoder/ARM_Translator.java 2007-05-08 16:35:56 UTC (rev 105) @@ -265,7 +265,7 @@ translator.arm2ir.appendRotateRight(resultRegister, shiftedOperand, shiftAmount); return resultRegister; - case RRE: + case RRX: /* * if (regs.isCarrySet()) return (resultRegister >> 1) | 0x80000000; * else return resultRegister >>> 1; @@ -504,7 +504,7 @@ shiftAmount); return resultRegister; - case RRE: + case RRX: /* * if (regs.isCarrySet()) return (resultRegister >> 1) | 0x80000000; * else return resultRegister >>> 1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |