two_byte_opcodes.isa revision 4864:a78c58ce5499
1// Copyright (c) 2007 The Hewlett-Packard Development Company
2// All rights reserved.
3//
4// Redistribution and use of this software in source and binary forms,
5// with or without modification, are permitted provided that the
6// following conditions are met:
7//
8// The software must be used only for Non-Commercial Use which means any
9// use which is NOT directed to receiving any direct monetary
10// compensation for, or commercial advantage from such use.  Illustrative
11// examples of non-commercial use are academic research, personal study,
12// teaching, education and corporate research & development.
13// Illustrative examples of commercial use are distributing products for
14// commercial advantage and providing services using the software for
15// commercial advantage.
16//
17// If you wish to use this software or functionality therein that may be
18// covered by patents for commercial use, please contact:
19//     Director of Intellectual Property Licensing
20//     Office of Strategy and Technology
21//     Hewlett-Packard Company
22//     1501 Page Mill Road
23//     Palo Alto, California  94304
24//
25// Redistributions of source code must retain the above copyright notice,
26// this list of conditions and the following disclaimer.  Redistributions
27// in binary form must reproduce the above copyright notice, this list of
28// conditions and the following disclaimer in the documentation and/or
29// other materials provided with the distribution.  Neither the name of
30// the COPYRIGHT HOLDER(s), HEWLETT-PACKARD COMPANY, nor the names of its
31// contributors may be used to endorse or promote products derived from
32// this software without specific prior written permission.  No right of
33// sublicense is granted herewith.  Derivatives of the software and
34// output created using the software may be prepared, but only for
35// Non-Commercial Uses.  Derivatives of the software may be shared with
36// others provided: (i) the others agree to abide by the list of
37// conditions herein which includes the Non-Commercial Use restrictions;
38// and (ii) such Derivatives of the software include the above copyright
39// notice to acknowledge the contribution from this software where
40// applicable, this list of conditions and the disclaimer below.
41//
42// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
43// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
44// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
45// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
46// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
47// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
48// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
49// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
50// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
51// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
52// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53//
54// Authors: Gabe Black
55
56////////////////////////////////////////////////////////////////////
57//
58// Decode the two byte opcodes
59//
600x2: decode OPCODE_PREFIXA {
61    0x0F: decode OPCODE_OP_TOP5 {
62        format WarnUnimpl {
63            0x00: decode OPCODE_OP_BOTTOM3 {
64                0x00: group6();
65                0x01: group7();
66                0x02: lar_Gv_Ew();
67                0x03: lsl_Gv_Ew();
68                //sandpile.org doesn't seem to know what this is... ?
69                0x04: loadall_or_reset_or_hang();
70#if FULL_SYSTEM
71                0x05: syscall();
72#else
73                0x05: SyscallInst::syscall('xc->syscall(rax)', IsSyscall);
74#endif
75                0x06: clts();
76                //sandpile.org says (AMD) after sysret, so I might want to check
77                //if that means amd64 or AMD machines
78                0x07: loadall_or_sysret();
79            }
80            0x01: decode OPCODE_OP_BOTTOM3 {
81                0x0: invd();
82                0x1: wbinvd();
83                0x2: Inst::UD2();
84                0x3: Inst::UD2();
85                0x4: Inst::UD2();
86                0x5: threednow();
87                0x6: threednow();
88                0x7: threednow();
89            }
90            0x02: decode LEGACY_DECODEVAL {
91                // no prefix
92                0x0: decode OPCODE_OP_BOTTOM3 {
93                    0x0: holder();
94                    0x1: holder();
95                    0x2: holder();
96                    0x3: holder();
97                    0x4: holder();
98                    0x5: holder();
99                    0x6: holder();
100                    0x7: holder();
101                }
102                // repe (0xF3)
103                0x4: decode OPCODE_OP_BOTTOM3 {
104                    0x0: holder();
105                    0x1: holder();
106                    0x2: holder();
107                    0x3: holder();
108                    0x4: holder();
109                    0x5: holder();
110                    0x6: holder();
111                    0x7: holder();
112                }
113                // operand size (0x66)
114                0x1: decode OPCODE_OP_BOTTOM3 {
115                    0x0: holder();
116                    0x1: holder();
117                    0x2: holder();
118                    0x3: holder();
119                    0x4: holder();
120                    0x5: holder();
121                    0x6: holder();
122                    0x7: holder();
123                }
124                // repne (0xF2)
125                0x8: decode OPCODE_OP_BOTTOM3 {
126                    0x0: holder();
127                    0x1: holder();
128                    0x2: holder();
129                    0x3: holder();
130                    0x4: holder();
131                    0x5: holder();
132                    0x6: holder();
133                    0x7: holder();
134                }
135                default: Inst::UD2();
136            }
137            0x03: decode OPCODE_OP_BOTTOM3 {
138                0x0: group17();
139                0x1: group17();
140                0x2: group17();
141                0x3: group17();
142                0x4: group17();
143                0x5: group17();
144                0x6: group17();
145                0x7: group17();
146            }
147            0x04: decode OPCODE_OP_BOTTOM3 {
148                0x0: holder();
149                0x1: holder();
150                0x2: holder();
151                0x3: holder();
152                0x4: holder();
153                0x5: holder();
154                0x6: holder();
155                0x7: holder();
156            }
157            0x05: decode OPCODE_OP_BOTTOM3 {
158                0x0: holder();
159                0x1: holder();
160                0x2: holder();
161                0x3: holder();
162                0x4: holder();
163                0x5: holder();
164                0x6: holder();
165                0x7: holder();
166            }
167            0x06: decode OPCODE_OP_BOTTOM3 {
168                0x0: wrmsr();
169                0x1: rdtsc();
170                0x2: rdmsr();
171                0x3: rdpmc();
172                0x4: sysenter();
173                0x5: sysexit();
174                0x6: Inst::UD2();
175                0x7: getsec();
176            }
177            0x07: decode OPCODE_OP_BOTTOM3 {
178                0x0: three_byte_opcode();
179                0x1: three_byte_opcode();
180                0x2: three_byte_opcode();
181                0x3: three_byte_opcode();
182                0x4: three_byte_opcode();
183                0x5: three_byte_opcode();
184                0x6: three_byte_opcode();
185                0x7: three_byte_opcode();
186            }
187            format Inst {
188                0x08: decode OPCODE_OP_BOTTOM3 {
189                    0x0: CMOVO(Gv,Ev);
190                    0x1: CMOVNO(Gv,Ev);
191                    0x2: CMOVB(Gv,Ev);
192                    0x3: CMOVNB(Gv,Ev);
193                    0x4: CMOVZ(Gv,Ev);
194                    0x5: CMOVNZ(Gv,Ev);
195                    0x6: CMOVBE(Gv,Ev);
196                    0x7: CMOVNBE(Gv,Ev);
197                }
198                0x09: decode OPCODE_OP_BOTTOM3 {
199                    0x0: CMOVS(Gv,Ev);
200                    0x1: CMOVNS(Gv,Ev);
201                    0x2: CMOVP(Gv,Ev);
202                    0x3: CMOVNP(Gv,Ev);
203                    0x4: CMOVL(Gv,Ev);
204                    0x5: CMOVNL(Gv,Ev);
205                    0x6: CMOVLE(Gv,Ev);
206                    0x7: CMOVNLE(Gv,Ev);
207                }
208            }
209            0x0A: decode OPCODE_OP_BOTTOM3 {
210                0x0: holder();
211                0x1: holder();
212                0x2: holder();
213                0x3: holder();
214                0x4: holder();
215                0x5: holder();
216                0x6: holder();
217                0x7: holder();
218            }
219            0x0B: decode OPCODE_OP_BOTTOM3 {
220                0x0: holder();
221                0x1: holder();
222                0x2: holder();
223                0x3: holder();
224                0x4: holder();
225                0x5: holder();
226                0x6: holder();
227                0x7: holder();
228            }
229            0x0C: decode OPCODE_OP_BOTTOM3 {
230                0x0: holder();
231                0x1: holder();
232                0x2: holder();
233                0x3: holder();
234                0x4: holder();
235                0x5: holder();
236                0x6: holder();
237                0x7: holder();
238            }
239            0x0D: decode OPCODE_OP_BOTTOM3 {
240                0x0: holder();
241                0x1: holder();
242                0x2: holder();
243                0x3: holder();
244                0x4: holder();
245                0x5: holder();
246                0x6: holder();
247                0x7: holder();
248            }
249            0x0E: decode OPCODE_OP_BOTTOM3 {
250                0x0: holder();
251                0x1: holder();
252                0x2: holder();
253                0x3: holder();
254                0x4: holder();
255                0x5: holder();
256                0x6: holder();
257                0x7: holder();
258            }
259            0x0F: decode OPCODE_OP_BOTTOM3 {
260                0x0: holder();
261                0x1: holder();
262                0x2: holder();
263                0x3: holder();
264                0x4: holder();
265                0x5: holder();
266                0x6: holder();
267                0x7: holder();
268            }
269            format Inst {
270                0x10: decode OPCODE_OP_BOTTOM3 {
271                    0x0: JO(Jz);
272                    0x1: JNO(Jz);
273                    0x2: JB(Jz);
274                    0x3: JNB(Jz);
275                    0x4: JZ(Jz);
276                    0x5: JNZ(Jz);
277                    0x6: JBE(Jz);
278                    0x7: JNBE(Jz);
279                }
280                0x11: decode OPCODE_OP_BOTTOM3 {
281                    0x0: JS(Jz);
282                    0x1: JNS(Jz);
283                    0x2: JP(Jz);
284                    0x3: JNP(Jz);
285                    0x4: JL(Jz);
286                    0x5: JNL(Jz);
287                    0x6: JLE(Jz);
288                    0x7: JNLE(Jz);
289                }
290                0x12: decode OPCODE_OP_BOTTOM3 {
291                    0x0: SETO(Eb);
292                    0x1: SETNO(Eb);
293                    0x2: SETB(Eb);
294                    0x3: SETNB(Eb);
295                    0x4: SETZ(Eb);
296                    0x5: SETNZ(Eb);
297                    0x6: SETBE(Eb);
298                    0x7: SETNBE(Eb);
299                }
300                0x13: decode OPCODE_OP_BOTTOM3 {
301                    0x0: SETS(Eb);
302                    0x1: SETNS(Eb);
303                    0x2: SETP(Eb);
304                    0x3: SETNP(Eb);
305                    0x4: SETL(Eb);
306                    0x5: SETNL(Eb);
307                    0x6: SETLE(Eb);
308                    0x7: SETNLE(Eb);
309                }
310            }
311            0x14: decode OPCODE_OP_BOTTOM3 {
312                0x0: push_fs();
313                0x1: pop_fs();
314                0x2: Inst::CPUID(rAd);
315                0x3: bt_Ev_Gv();
316                0x4: shld_Ev_Gv_Ib();
317                0x5: shld_Ev_Gv_rCl();
318                0x6: xbts_and_cmpxchg();
319                0x7: ibts_and_cmpxchg();
320            }
321            0x15: decode OPCODE_OP_BOTTOM3 {
322                0x0: push_gs();
323                0x1: pop_gs();
324                0x2: rsm_smm();
325                0x3: bts_Ev_Gv();
326                0x4: shrd_Ev_Gv_Ib();
327                0x5: shrd_Ev_Gv_rCl();
328                0x6: group16();
329                0x7: Inst::IMUL(Gv,Ev);
330            }
331            0x16: decode OPCODE_OP_BOTTOM3 {
332                0x0: Inst::CMPXCHG(Eb,Gb);
333                0x1: Inst::CMPXCHG(Ev,Gv);
334                0x2: lss_Gz_Mp();
335                0x3: btr_Ev_Gv();
336                0x4: lfs_Gz_Mp();
337                0x5: lgs_Gz_Mp();
338                //The size of the second operand in these instructions should
339                //really be "b" or "w", but it's set to v in order to have a
340                //consistent register size. This shouldn't affect behavior.
341                0x6: Inst::MOVZX_B(Gv,Ev);
342                0x7: Inst::MOVZX_W(Gv,Ev);
343            }
344            0x17: decode OPCODE_OP_BOTTOM3 {
345                0x0: jmpe_Jz(); // IA-64?
346                0x1: group11_UD2();
347                0x2: group8_Ev_Ib();
348                0x3: btc_Ev_Gv();
349                0x4: bsf_Gv_Ev();
350                0x5: bsr_Gv_Ev();
351                //The size of the second operand in these instructions should
352                //really be "b" or "w", but it's set to v in order to have a
353                //consistent register size. This shouldn't affect behavior.
354                0x6: Inst::MOVSX_B(Gv,Ev);
355                0x7: Inst::MOVSX_W(Gv,Ev);
356            }
357            0x18: decode OPCODE_OP_BOTTOM3 {
358                0x0: holder();
359                0x1: holder();
360                0x2: holder();
361                0x3: holder();
362                0x4: holder();
363                0x5: holder();
364                0x6: holder();
365                0x7: holder();
366            }
367            0x19: bswap_B();
368            0x1A: decode OPCODE_OP_BOTTOM3 {
369                0x0: holder();
370                0x1: holder();
371                0x2: holder();
372                0x3: holder();
373                0x4: holder();
374                0x5: holder();
375                0x6: holder();
376                0x7: holder();
377            }
378            0x1B: decode OPCODE_OP_BOTTOM3 {
379                0x0: holder();
380                0x1: holder();
381                0x2: holder();
382                0x3: holder();
383                0x4: holder();
384                0x5: holder();
385                0x6: holder();
386                0x7: holder();
387            }
388            0x1C: decode OPCODE_OP_BOTTOM3 {
389                0x0: holder();
390                0x1: holder();
391                0x2: holder();
392                0x3: holder();
393                0x4: holder();
394                0x5: holder();
395                0x6: holder();
396                0x7: holder();
397            }
398            0x1D: decode OPCODE_OP_BOTTOM3 {
399                0x0: holder();
400                0x1: holder();
401                0x2: holder();
402                0x3: holder();
403                0x4: holder();
404                0x5: holder();
405                0x6: holder();
406                0x7: holder();
407            }
408            0x1E: decode OPCODE_OP_BOTTOM3 {
409                0x0: holder();
410                0x1: holder();
411                0x2: holder();
412                0x3: holder();
413                0x4: holder();
414                0x5: holder();
415                0x6: holder();
416                0x7: holder();
417            }
418            0x1F: decode OPCODE_OP_BOTTOM3 {
419                0x0: holder();
420                0x1: holder();
421                0x2: holder();
422                0x3: holder();
423                0x4: holder();
424                0x5: holder();
425                0x6: holder();
426                0x7: holder();
427            }
428            default: FailUnimpl::twoByteOps();
429        }
430    }
431    default: M5InternalError::error(
432        {{"Unexpected first opcode byte in two byte opcode!"}});
433}
434