1 // Copyright (c) 2009 The Regents of The University of Michigan
2 // All rights reserved.
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are
6 // met: redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer;
8 // redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution;
11 // neither the name of the copyright holders nor the names of its
12 // contributors may be used to endorse or promote products derived from
13 // this software without specific prior written permission.
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 // Authors: Gabe Black
29 ////////////////////////////////////////////////////////////////////
31 // Decode opcodes with the lock prefix. Opcodes which shouldn't have that
32 // prefix should effectively decode to UD2.
35 // All the memory references in these instructions happen through modrm bytes.
36 // We therefore only need to make sure the modrm byte encodes a memory
37 // reference to make sure these are the memory forms of these instructions.
38 0x1: decode MODRM_MOD {
41 default: decode OPCODE_NUM {
42 0x1: decode OPCODE_OP_TOP5 {
43 0x00: decode OPCODE_OP_BOTTOM3 {
44 default: MultiInst::ADD_LOCKED(OPCODE_OP_BOTTOM3,
47 0x01: decode OPCODE_OP_BOTTOM3 {
48 default: MultiInst::OR_LOCKED(OPCODE_OP_BOTTOM3,
51 0x02: decode OPCODE_OP_BOTTOM3 {
52 default: MultiInst::ADC_LOCKED(OPCODE_OP_BOTTOM3,
55 0x03: decode OPCODE_OP_BOTTOM3 {
56 default: MultiInst::SBB_LOCKED(OPCODE_OP_BOTTOM3,
59 0x04: decode OPCODE_OP_BOTTOM3 {
60 default: MultiInst::AND_LOCKED(OPCODE_OP_BOTTOM3,
63 0x05: decode OPCODE_OP_BOTTOM3 {
64 default: MultiInst::SUB_LOCKED(OPCODE_OP_BOTTOM3,
67 0x06: decode OPCODE_OP_BOTTOM3 {
68 default: MultiInst::XOR_LOCKED(OPCODE_OP_BOTTOM3,
71 0x10: decode OPCODE_OP_BOTTOM3 {
72 0x0: decode MODRM_REG {
73 0x0: ADD_LOCKED(Mb,Ib);
74 0x1: OR_LOCKED(Mb,Ib);
75 0x2: ADC_LOCKED(Mb,Ib);
76 0x3: SBB_LOCKED(Mb,Ib);
77 0x4: AND_LOCKED(Mb,Ib);
78 0x5: SUB_LOCKED(Mb,Ib);
79 0x6: XOR_LOCKED(Mb,Ib);
81 0x1: decode MODRM_REG {
82 0x0: ADD_LOCKED(Mv,Iz);
83 0x1: OR_LOCKED(Mv,Iz);
84 0x2: ADC_LOCKED(Mv,Iz);
85 0x3: SBB_LOCKED(Mv,Iz);
86 0x4: AND_LOCKED(Mv,Iz);
87 0x5: SUB_LOCKED(Mv,Iz);
88 0x6: XOR_LOCKED(Mv,Iz);
90 0x2: decode MODE_SUBMODE {
92 default: decode MODRM_REG {
93 0x0: ADD_LOCKED(Mb,Ib);
94 0x1: OR_LOCKED(Mb,Ib);
95 0x2: ADC_LOCKED(Mb,Ib);
96 0x3: SBB_LOCKED(Mb,Ib);
97 0x4: AND_LOCKED(Mb,Ib);
98 0x5: SUB_LOCKED(Mb,Ib);
99 0x6: XOR_LOCKED(Mb,Ib);
102 //0x3: group1_Ev_Ib();
103 0x3: decode MODRM_REG {
104 0x0: ADD_LOCKED(Mv,Ib);
105 0x1: OR_LOCKED(Mv,Ib);
106 0x2: ADC_LOCKED(Mv,Ib);
107 0x3: SBB_LOCKED(Mv,Ib);
108 0x4: AND_LOCKED(Mv,Ib);
109 0x5: SUB_LOCKED(Mv,Ib);
110 0x6: XOR_LOCKED(Mv,Ib);
112 0x6: XCHG_LOCKED(Mb,Gb);
113 0x7: XCHG_LOCKED(Mv,Gv);
115 0x1E: decode OPCODE_OP_BOTTOM3 {
117 0x6: decode MODRM_REG {
122 0x7: decode MODRM_REG {
127 0x1F: decode OPCODE_OP_BOTTOM3 {
128 0x6: decode MODRM_REG {
134 0x7: decode MODRM_REG {
140 0x2: decode OPCODE_PREFIXA {
141 0x0F: decode OPCODE_OP_TOP5 {
142 0x15: decode OPCODE_OP_BOTTOM3 {
143 0x3: BTS_LOCKED(Mv,Gv);
145 0x16: decode OPCODE_OP_BOTTOM3 {
146 0x0: CMPXCHG_LOCKED(Mb,Gb);
147 0x1: CMPXCHG_LOCKED(Mv,Gv);
148 0x3: BTR_LOCKED(Mv,Gv);
150 0x17: decode OPCODE_OP_BOTTOM3 {
151 0x2: decode MODRM_REG {
152 0x5: BTS_LOCKED(Mv,Ib);
153 0x6: BTR_LOCKED(Mv,Ib);
154 0x7: BTC_LOCKED(Mv,Ib);
156 0x3: BTC_LOCKED(Mv,Gv);
158 0x18: decode OPCODE_OP_BOTTOM3 {
159 0x0: XADD_LOCKED(Mb,Gb);
160 0x1: XADD_LOCKED(Mv,Gv);
162 0x7: decode MODRM_REG {
163 0x1: WarnUnimpl::cmpxchg_Mq_LOCKED();
167 default: M5InternalError::error(
168 {{"Unexpected first opcode byte in two byte opcode!"}});