OLD | NEW |
| (Empty) |
1 /* | |
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 | |
4 * found in the LICENSE file. | |
5 */ | |
6 | |
7 #include "native_client/src/trusted/validator/x86/x86_insts.h" | |
8 | |
9 #include "native_client/src/trusted/validator/x86/x86_insts_inl.c" | |
10 | |
11 /* Defines the range of possible (initial) opcodes for x87 instructions. */ | |
12 const uint8_t kFirstX87Opcode = 0xd8; | |
13 const uint8_t kLastX87Opcode = 0xdf; | |
14 | |
15 /* Defines the opcode for the WAIT instruction. | |
16 * Note: WAIT is an x87 instruction but not in the coproc opcode space. | |
17 */ | |
18 const uint8_t kWAITOp = 0x9b; | |
19 | |
20 const uint8_t kTwoByteOpcodeByte1 = 0x0f; | |
21 const uint8_t k3DNowOpcodeByte2 = 0x0f; | |
22 const int kMaxPrefixBytes = 4; | |
23 | |
24 /* Accessors for the ModRm byte. */ | |
25 uint8_t modrm_mod(uint8_t modrm) { | |
26 return modrm_modInline(modrm); | |
27 } | |
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 } | |
40 | |
41 /* Accessors for the Sib byte. */ | |
42 uint8_t sib_ss(uint8_t sib) { return ((sib >> 6) & 0x03); } | |
43 uint8_t sib_index(uint8_t sib) { return ((sib >> 3) & 0x07); } | |
44 uint8_t sib_base(uint8_t sib) { return (sib & 0x07); } | |
45 | |
46 /* Defines the corresponding mask for the bits of the the Rex prefix. */ | |
47 #define NaClRexWMask 0x8 | |
48 #define NaClRexRMask 0x4 | |
49 #define NaClRexXMask 0x2 | |
50 #define NaClRexBMask 0x1 | |
51 | |
52 /* Defines the range of rex prefix values. */ | |
53 const uint8_t NaClRexMin = 0x40; | |
54 const uint8_t NaClRexMax = 0x4F; | |
55 | |
56 uint8_t NaClRexW(uint8_t prefix) { | |
57 return NaClHasBit(prefix, NaClRexWMask); | |
58 } | |
59 | |
60 uint8_t NaClRexR(uint8_t prefix) { | |
61 return NaClHasBit(prefix, NaClRexRMask); | |
62 } | |
63 | |
64 uint8_t NaClRexX(uint8_t prefix) { | |
65 return NaClHasBit(prefix, NaClRexXMask); | |
66 } | |
67 | |
68 uint8_t NaClRexB(uint8_t prefix) { | |
69 return NaClHasBit(prefix, NaClRexBMask); | |
70 } | |
OLD | NEW |