Chromium Code Reviews| Index: src/mips/simulator-mips.cc |
| diff --git a/src/mips/simulator-mips.cc b/src/mips/simulator-mips.cc |
| index 07cfcff5b4813e7d16276009b2ca7c3ca182b8f8..1f69ac91982fdd8d54d0f5a1ef0c12433c956493 100644 |
| --- a/src/mips/simulator-mips.cc |
| +++ b/src/mips/simulator-mips.cc |
| @@ -3833,12 +3833,45 @@ void Simulator::DecodeTypeRegisterSPECIAL3() { |
| alu_out = static_cast<int32_t>(output); |
| break; |
| } |
| - case SEB: |
| - case SEH: |
| - case WSBH: |
| - alu_out = 0x12345678; |
| - UNREACHABLE(); |
| + case SEB: { |
| + int8_t input = static_cast<int8_t>(rt()); |
| + int32_t output = 0x000000FF & input; |
|
balazs.kilvady
2016/06/21 10:24:58
In the above line if input is an int8_t then why d
|
| + int32_t mask = 0x00000080; |
| + |
| + if (mask & input) output += 0xFFFFFF00; |
| + |
| + alu_out = static_cast<int32_t>(output); |
| + break; |
| + } |
| + case SEH: { |
| + int16_t input = static_cast<int16_t>(rt()); |
| + int32_t output = 0x0000FFFF & input; |
| + int32_t mask = 0x00008000; |
| + |
| + if (mask & input) output += 0xFFFF0000; |
| + |
| + alu_out = static_cast<int32_t>(output); |
| break; |
| + } |
| + case WSBH: { |
| + int32_t input = static_cast<uint32_t>(rt()); |
| + int32_t output = 0; |
| + |
| + uint32_t mask = 0xFF000000; |
| + for (int i = 0; i < 4; i++) { |
| + uint32_t tmp = mask & input; |
| + if (i % 2 == 0) { |
| + tmp = tmp >> 8; |
| + } else { |
| + tmp = tmp << 8; |
| + } |
| + output = output | tmp; |
| + mask = mask >> 8; |
| + } |
| + |
| + alu_out = static_cast<int32_t>(output); |
| + break; |
| + } |
| default: { |
| const uint8_t bp = get_instr()->Bp2Value(); |
| sa >>= kBp2Bits; |