Chromium Code Reviews| Index: src/arm/simulator-arm.cc |
| diff --git a/src/arm/simulator-arm.cc b/src/arm/simulator-arm.cc |
| index 7687bbbe7c91f123db176c08f5a78f26df477142..490d9617ada877641eae503803ad5a8bc8d1d1a9 100644 |
| --- a/src/arm/simulator-arm.cc |
| +++ b/src/arm/simulator-arm.cc |
| @@ -1333,11 +1333,12 @@ bool Simulator::CarryFrom(int32_t left, int32_t right, int32_t carry) { |
| // Calculate C flag value for subtractions. |
| -bool Simulator::BorrowFrom(int32_t left, int32_t right) { |
| +bool Simulator::BorrowFrom(int32_t left, int32_t right, int32_t carry) { |
| uint32_t uleft = static_cast<uint32_t>(left); |
| uint32_t uright = static_cast<uint32_t>(right); |
| - return (uright > uleft); |
| + return (uright > uleft) || |
| + (carry && (((uright + 1) > uleft) || (uright > (uleft - 1)))); |
| } |
| @@ -2493,8 +2494,15 @@ void Simulator::DecodeType01(Instruction* instr) { |
| } |
| case SBC: { |
| - Format(instr, "sbc'cond's 'rd, 'rn, 'shift_rm"); |
| - Format(instr, "sbc'cond's 'rd, 'rn, 'imm"); |
| + // Format(instr, "sbc'cond's 'rd, 'rn, 'shift_rm"); |
| + // Format(instr, "sbc'cond's 'rd, 'rn, 'imm"); |
| + alu_out = (rn_val - shifter_operand) - (GetCarry() ? 0 : 1); |
|
titzer
2016/03/14 09:36:06
Why is carry inverted here?
ahaas
2016/03/15 11:01:43
Because the arm instruction manual says so.
|
| + set_register(rd, alu_out); |
| + if (instr->HasS()) { |
| + SetNZFlags(alu_out); |
| + SetCFlag(!BorrowFrom(rn_val, shifter_operand, GetCarry())); |
| + SetVFlag(OverflowFrom(alu_out, rn_val, shifter_operand, false)); |
| + } |
| break; |
| } |