| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. | 2 * Copyright (c) 2011 The Native Client Authors. All rights reserved. |
| 3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
| 4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
| 5 */ | 5 */ |
| 6 | 6 |
| 7 #include "native_client/src/trusted/validator/x86/x86_insts.h" | 7 #include "native_client/src/trusted/validator/x86/x86_insts.h" |
| 8 | 8 |
| 9 #include "native_client/src/trusted/validator/x86/x86_insts_inl.c" |
| 10 |
| 9 /* Defines the range of possible (initial) opcodes for x87 instructions. */ | 11 /* Defines the range of possible (initial) opcodes for x87 instructions. */ |
| 10 const uint8_t kFirstX87Opcode = 0xd8; | 12 const uint8_t kFirstX87Opcode = 0xd8; |
| 11 const uint8_t kLastX87Opcode = 0xdf; | 13 const uint8_t kLastX87Opcode = 0xdf; |
| 12 | 14 |
| 13 /* Defines the opcode for the WAIT instruction. | 15 /* Defines the opcode for the WAIT instruction. |
| 14 * Note: WAIT is an x87 instruction but not in the coproc opcode space. | 16 * Note: WAIT is an x87 instruction but not in the coproc opcode space. |
| 15 */ | 17 */ |
| 16 const uint8_t kWAITOp = 0x9b; | 18 const uint8_t kWAITOp = 0x9b; |
| 17 | 19 |
| 18 const uint8_t kTwoByteOpcodeByte1 = 0x0f; | 20 const uint8_t kTwoByteOpcodeByte1 = 0x0f; |
| 19 const uint8_t k3DNowOpcodeByte2 = 0x0f; | 21 const uint8_t k3DNowOpcodeByte2 = 0x0f; |
| 20 const int kMaxPrefixBytes = 4; | 22 const int kMaxPrefixBytes = 4; |
| 21 | 23 |
| 22 /* Accessors for the ModRm byte. */ | 24 /* Accessors for the ModRm byte. */ |
| 23 uint8_t modrm_mod(uint8_t modrm) { return ((modrm >> 6) & 0x03);} | 25 uint8_t modrm_mod(uint8_t modrm) { |
| 24 uint8_t modrm_rm(uint8_t modrm) { return (modrm & 0x07); } | 26 return modrm_modInline(modrm); |
| 25 uint8_t modrm_reg(uint8_t modrm) { return ((modrm >> 3) & 0x07); } | 27 } |
| 26 uint8_t modrm_opcode(uint8_t modrm) { return modrm_reg(modrm); } | 28 |
| 29 uint8_t modrm_rm(uint8_t modrm) { |
| 30 return modrm_rmInline(modrm); |
| 31 } |
| 32 |
| 33 uint8_t modrm_reg(uint8_t modrm) { |
| 34 return modrm_regInline(modrm); |
| 35 } |
| 36 |
| 37 uint8_t modrm_opcode(uint8_t modrm) { |
| 38 return modrm_opcodeInline(modrm); |
| 39 } |
| 27 | 40 |
| 28 /* Accessors for the Sib byte. */ | 41 /* Accessors for the Sib byte. */ |
| 29 uint8_t sib_ss(uint8_t sib) { return ((sib >> 6) & 0x03); } | 42 uint8_t sib_ss(uint8_t sib) { return ((sib >> 6) & 0x03); } |
| 30 uint8_t sib_index(uint8_t sib) { return ((sib >> 3) & 0x07); } | 43 uint8_t sib_index(uint8_t sib) { return ((sib >> 3) & 0x07); } |
| 31 uint8_t sib_base(uint8_t sib) { return (sib & 0x07); } | 44 uint8_t sib_base(uint8_t sib) { return (sib & 0x07); } |
| 32 | 45 |
| 33 /* Defines the corresponding mask for the bits of the the Rex prefix. */ | 46 /* Defines the corresponding mask for the bits of the the Rex prefix. */ |
| 34 #define NaClRexWMask 0x8 | 47 #define NaClRexWMask 0x8 |
| 35 #define NaClRexRMask 0x4 | 48 #define NaClRexRMask 0x4 |
| 36 #define NaClRexXMask 0x2 | 49 #define NaClRexXMask 0x2 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 48 return NaClHasBit(prefix, NaClRexRMask); | 61 return NaClHasBit(prefix, NaClRexRMask); |
| 49 } | 62 } |
| 50 | 63 |
| 51 uint8_t NaClRexX(uint8_t prefix) { | 64 uint8_t NaClRexX(uint8_t prefix) { |
| 52 return NaClHasBit(prefix, NaClRexXMask); | 65 return NaClHasBit(prefix, NaClRexXMask); |
| 53 } | 66 } |
| 54 | 67 |
| 55 uint8_t NaClRexB(uint8_t prefix) { | 68 uint8_t NaClRexB(uint8_t prefix) { |
| 56 return NaClHasBit(prefix, NaClRexBMask); | 69 return NaClHasBit(prefix, NaClRexBMask); |
| 57 } | 70 } |
| OLD | NEW |