Allow bts and btr instructions: gcc will generate them
[nativeclient.git] / ncv / ncdecode_table.c
blobdc7768441bab0d556fe24a9c81e578be393dd4c9
1 /*
2 * Copyright 2008, Google Inc.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
14 * distribution.
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * ncdecode_intable.h - table driven decoder for Native Client.
35 * This program generates C source for the ncdecode.c decoder tables.
36 * It writes two C .h file to standard out, one for decoding and one
37 * for disassembly, that contain six decoder tables.
40 #include "native_client/include/portability.h"
41 #include <stdlib.h>
42 #include <stdio.h>
43 #include <time.h>
44 #include <string.h>
45 #include <assert.h>
46 #define NEEDSNACLINSTTYPESTRING
47 #include "ncdecode.h"
49 typedef uint8_t bool; /* zero or non-zero */
51 #define TODO
53 /* For handling prefixes we consume the prefix byte and then
54 * record the state in this record.
56 typedef struct OpMetaInfo {
57 const char *disfmt; /* as a short string, for printing */
58 NaClInstType insttype;
59 bool mrmbyte; /* 0 or 1 */
60 uint8_t immtype; /* IMM_UNKNOWN .. IMM_DEFAULT_4 */
61 uint8_t opinmrm; /* 0 .. 8 */
62 } OpMetaInfo;
64 /* The decoder input table is an array of instruction definitions, */
65 /* defined using OpMetaInfo as defined in ncdecode.h */
66 OpMetaInfo *g_Op1ByteTable[NCDTABLESIZE];
67 /* two byte opcode tables */
68 OpMetaInfo *g_Op0FXXMetaTable[NCDTABLESIZE];
69 OpMetaInfo *g_OpF20FXXTable[NCDTABLESIZE];
70 OpMetaInfo *g_OpF30FXXTable[NCDTABLESIZE];
71 OpMetaInfo *g_Op660FXXTable[NCDTABLESIZE];
72 /* three byte opcode tables */
73 OpMetaInfo *g_Op0F0FTable[NCDTABLESIZE];
74 OpMetaInfo *g_Op0F38Table[NCDTABLESIZE];
75 OpMetaInfo *g_Op0F3ATable[NCDTABLESIZE];
76 /* tables for opcodes in ModRM */
77 OpMetaInfo *g_ModRMOpTable[kNaClMRMGroupsRange][kModRMOpcodeGroupSize];
78 /* x87 opcode tables */
79 OpMetaInfo *g_Op87D8[NCDTABLESIZE];
80 OpMetaInfo *g_Op87D9[NCDTABLESIZE];
81 OpMetaInfo *g_Op87DA[NCDTABLESIZE];
82 OpMetaInfo *g_Op87DB[NCDTABLESIZE];
83 OpMetaInfo *g_Op87DC[NCDTABLESIZE];
84 OpMetaInfo *g_Op87DD[NCDTABLESIZE];
85 OpMetaInfo *g_Op87DE[NCDTABLESIZE];
86 OpMetaInfo *g_Op87DF[NCDTABLESIZE];
87 static OpMetaInfo DecodeUndefinedInstInfo = {
88 "undefined", NACLi_UNDEFINED, 0, IMM_NONE, 0
91 /* Note: in general all errors in this module will be fatal.
92 * To debug: use gdb or your favorite debugger.
94 static void fatal(const char *s) {
95 fprintf(stderr, "%s\n", s);
96 fprintf(stderr, "fatal error, cannot recover\n");
97 exit(-1);
100 /* operandsize == 0 implies operand size determined by operand size attributes
101 * opbytes: length of opcode, one or two bytes
102 * mrmbyte: 0 or 1, 1 if mrmbyte is present
103 * immbytes: bytes of immediate: 1, 2, 4
104 * itype: decoder treatment, an NaClInstType as in ncdecode.h
105 * disfmt: format string for disassembly
107 static OpMetaInfo *NewMetaDefn(const bool mrmbyte, const uint8_t immtype,
108 const NaClInstType itype, const char *disfmt) {
109 OpMetaInfo *imd = (OpMetaInfo *)malloc(sizeof(*imd));
110 if (imd == NULL) {
111 fatal("NewMetaDefn: malloc failed");
113 imd->insttype = itype;
114 imd->disfmt = disfmt;
115 imd->mrmbyte = mrmbyte;
116 imd->immtype = immtype;
117 imd->opinmrm = 0;
118 return imd;
121 static void EncodeOpByte1(const uint8_t byte1, const bool mrmbyte,
122 const uint8_t immtype,
123 const NaClInstType itype, const char *disfmt) {
124 g_Op1ByteTable[byte1] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
127 static void EncodeOp0F(const uint8_t byte2, const bool mrmbyte,
128 const uint8_t immtype,
129 const NaClInstType itype, const char *disfmt) {
130 g_Op0FXXMetaTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
133 static void EncodeOp66(const uint8_t byte2, const bool mrmbyte,
134 const uint8_t immtype,
135 const NaClInstType itype, const char *disfmt) {
136 g_Op660FXXTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
139 static void EncodeOpF2(const uint8_t byte2, const bool mrmbyte,
140 const uint8_t immtype,
141 const NaClInstType itype, const char *disfmt) {
142 g_OpF20FXXTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
145 static void EncodeOpF3(const uint8_t byte2, const bool mrmbyte,
146 const uint8_t immtype,
147 const NaClInstType itype, const char *disfmt) {
148 g_OpF30FXXTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
151 static void EncodeOp0F0F(const uint8_t byte2, const bool mrmbyte,
152 const uint8_t immtype,
153 const NaClInstType itype, const char *disfmt) {
154 g_Op0F0FTable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
157 static void EncodeOp0F38(const uint8_t byte2, const bool mrmbyte,
158 const uint8_t immtype,
159 const NaClInstType itype, const char *disfmt) {
160 g_Op0F38Table[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
163 static void EncodeOp0F3A(const uint8_t byte2, const bool mrmbyte,
164 const uint8_t immtype,
165 const NaClInstType itype, const char *disfmt) {
166 g_Op0F3ATable[byte2] = NewMetaDefn(mrmbyte, immtype, itype, disfmt);
169 static void EncodeModRMOp(const uint8_t group, const uint8_t nnn,
170 const NaClInstType itype, const char *disfmt) {
171 OpMetaInfo *idefn = NewMetaDefn(1, IMM_NONE, itype, disfmt);
172 g_ModRMOpTable[group][nnn] = idefn;
175 static void SetOpByte1OpInMRM(const uint8_t byte1, const uint8_t group) {
176 assert(g_Op1ByteTable[byte1] != &DecodeUndefinedInstInfo);
177 g_Op1ByteTable[byte1]->opinmrm = group;
180 /* TODO - this function generates an error since it is not used */
181 #if 0
182 static void SetModRMOpImmType(const uint8_t group, const uint8_t nnn,
183 const uint8_t it) {
184 g_ModRMOpTable[group][nnn]->immtype = it;
186 #endif
187 static void SetOp0FOpInMRM(const uint8_t byte2, const uint8_t group) {
188 assert(g_Op0FXXMetaTable[byte2] != &DecodeUndefinedInstInfo);
189 g_Op0FXXMetaTable[byte2]->opinmrm = group;
192 static void SetOp66OpInMRM(const uint8_t byte2, const uint8_t group) {
193 assert(g_Op660FXXTable[byte2] != &DecodeUndefinedInstInfo);
194 g_Op660FXXTable[byte2]->opinmrm = group;
197 /* TODO - this function generates an error since it is not used */
198 #if 0
199 static void SetOpF2OpInMRM(const uint8_t byte2, const uint8_t group) {
200 assert(g_OpF20FXXTable[byte2] != &DecodeUndefinedInstInfo);
201 g_OpF20FXXTable[byte2]->opinmrm = group;
204 static void SetOpF3OpInMRM(const uint8_t byte2, const uint8_t group) {
205 assert(g_OpF30FXXTable[byte2] != &DecodeUndefinedInstInfo);
206 g_OpF30FXXTable[byte2]->opinmrm = group;
208 #endif
210 extern int asprintf(char **s, const char *fmt, ...);
211 /* note that this function accepts only one string in s */
212 static char *aprintf(const char *fmt, const char *s) {
213 char *rstring = NULL;
214 /* there will be one spare byte, because %s is replaced, but it's ok */
215 int length = strlen(fmt) + strlen(s);
216 rstring = malloc(length);
217 if (rstring != NULL) {
218 sprintf(rstring,fmt,s);
219 } else {
220 fprintf(stderr, "malloc failed in aprintf (%s, %s) \n", fmt, s);
222 return rstring;
225 static void ALUOperandVariants00_05(const uint8_t base,
226 const NaClInstType itype,
227 const char *ocstr) {
228 EncodeOpByte1(base, 1, IMM_NONE, itype, aprintf("%s $E, $G", ocstr));
229 EncodeOpByte1(base+1, 1, IMM_NONE, itype, aprintf("%s $E, $G", ocstr));
230 EncodeOpByte1(base+2, 1, IMM_NONE, itype, aprintf("%s $G, $E", ocstr));
231 EncodeOpByte1(base+3, 1, IMM_NONE, itype, aprintf("%s $G, $E", ocstr));
232 EncodeOpByte1(base+4, 0, IMM_FIXED1, itype, aprintf("%s %%al, $I", ocstr));
233 EncodeOpByte1(base+5, 0, IMM_DATAV, itype, aprintf("%s %%eAX, $I", ocstr));
236 static void OneRegVariants00_07(const uint8_t base,
237 const NaClInstType itype,
238 const char *ocstr) {
239 EncodeOpByte1(base, 0, IMM_NONE, itype, aprintf("%s %%eax", ocstr));
240 EncodeOpByte1(base+1, 0, IMM_NONE, itype, aprintf("%s %%ecx", ocstr));
241 EncodeOpByte1(base+2, 0, IMM_NONE, itype, aprintf("%s %%edx", ocstr));
242 EncodeOpByte1(base+3, 0, IMM_NONE, itype, aprintf("%s %%ebx", ocstr));
243 EncodeOpByte1(base+4, 0, IMM_NONE, itype, aprintf("%s %%esp", ocstr));
244 EncodeOpByte1(base+5, 0, IMM_NONE, itype, aprintf("%s %%ebp", ocstr));
245 EncodeOpByte1(base+6, 0, IMM_NONE, itype, aprintf("%s %%esi", ocstr));
246 EncodeOpByte1(base+7, 0, IMM_NONE, itype, aprintf("%s %%edi", ocstr));
249 /* TODO - this function generates an error since it is not used */
250 #if 0
251 static char *asmprint(char **asmstr, const char *opcode,
252 const char *reg, const char *dest) {
253 if (asprintf(asmstr, "%s %s, %s", opcode, reg, dest) < 0) {
254 fatal("asprintf failed");
256 return *asmstr;
258 #endif
260 static void InitializeGlobalTables() {
261 int i, j;
262 /* pre-initialize g_Op1ByteTable */
263 for (i = 0; i < NCDTABLESIZE; i++) {
264 g_Op1ByteTable[i] = &DecodeUndefinedInstInfo;
265 g_Op0FXXMetaTable[i] = &DecodeUndefinedInstInfo;
266 g_Op660FXXTable[i] = &DecodeUndefinedInstInfo;
267 g_OpF20FXXTable[i] = &DecodeUndefinedInstInfo;
268 g_OpF30FXXTable[i] = &DecodeUndefinedInstInfo;
269 g_Op0F0FTable[i] = &DecodeUndefinedInstInfo;
270 g_Op0F38Table[i] = &DecodeUndefinedInstInfo;
271 g_Op0F3ATable[i] = &DecodeUndefinedInstInfo;
272 g_Op87D8[i] = &DecodeUndefinedInstInfo;
273 g_Op87D9[i] = &DecodeUndefinedInstInfo;
274 g_Op87DA[i] = &DecodeUndefinedInstInfo;
275 g_Op87DB[i] = &DecodeUndefinedInstInfo;
276 g_Op87DC[i] = &DecodeUndefinedInstInfo;
277 g_Op87DD[i] = &DecodeUndefinedInstInfo;
278 g_Op87DE[i] = &DecodeUndefinedInstInfo;
279 g_Op87DF[i] = &DecodeUndefinedInstInfo;
281 for (i = 0; i < kNaClMRMGroupsRange; i++) {
282 for (j = 0; j < 8; j++) {
283 g_ModRMOpTable[i][j] = &DecodeUndefinedInstInfo;
289 static void Encode87Op(OpMetaInfo *g87tab[],
290 const char *set1[8],
291 const char *set2[64]) {
292 int j, reg;
293 uint8_t i;
295 for (i = 0; i < 0xc0; i++) {
296 reg = modrm_reg(i);
297 if (set1[reg] == NULL) {
298 g87tab[i] = NewMetaDefn(1, IMM_NONE, NACLi_INVALID, "invalid");
299 } else {
300 g87tab[i] = NewMetaDefn(1, IMM_NONE, NACLi_X87, set1[reg]);
303 for (j = 0xc0; j < 0x100; j++) {
304 if (set2[j - 0xc0] == NULL) {
305 g87tab[j] = NewMetaDefn(1, IMM_NONE, NACLi_INVALID, "invalid");
306 } else {
307 g87tab[j] = NewMetaDefn(1, IMM_NONE, NACLi_X87, set2[j - 0xc0]);
312 static void Buildx87Tables() {
313 int i;
314 /* since these are so repetative I'm using a little bit of a hack */
315 /* to make this more concise. */
316 static const char *k87D8Table1[8] =
317 {"fadd", "fmul", "fcom", "fcomp", "fsub", "fsubr", "fdiv", "fdivr"};
318 static const char *k87D8Table2[64] = {
319 "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd",
320 "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul",
321 "fcom", "fcom", "fcom", "fcom", "fcom", "fcom", "fcom", "fcom",
322 "fcomp", "fcomp", "fcomp", "fcomp", "fcomp", "fcomp", "fcomp", "fcomp",
323 "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub",
324 "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr",
325 "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv",
326 "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr"};
328 static const char *k87D9Table1[8] =
329 {"fld", NULL, "fst", "fstp", "fldenv", "fldcw", "fnstenv", "fnstcw"};
330 static const char *k87D9Table2[64] = {
331 "fld", "fld", "fld", "fld", "fld", "fld", "fld", "fld",
332 "fxch", "fxch", "fxch", "fxch", "fxch", "fxch", "fxch", "fxch",
333 "fnop", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
334 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
335 "fchs", "fabs", NULL, NULL, "ftst", "fxam", NULL, NULL,
336 "fld1", "fldl2t", "fldl2e", "fldpi", "fldlg2", "fldln2", "fldz", NULL,
337 "f2xm1", "fyl2x", "fptan", "fpatan",
338 "fxtract", "fprem1", "fdecstp", "fincstp",
339 "fprem", "fyl2xp1", "fsqrt", "fsincos",
340 "frndint", "fscale", "fsin", "fcos" };
342 static const char *k87DATable1[8] =
343 {"fiadd", "fimul", "ficom", "ficomp", "fisub", "fisubr", "fidiv", "fidivr"};
344 static const char *k87DATable2[64] = {
345 "fcmovb", "fcmovb", "fcmovb", "fcmovb",
346 "fcmovb", "fcmovb", "fcmovb", "fcmovb",
347 "fcmove", "fcmove", "fcmove", "fcmove",
348 "fcmove", "fcmove", "fcmove", "fcmove",
349 "fcmovbe", "fcmovbe", "fcmovbe", "fcmovbe",
350 "fcmovbe", "fcmovbe", "fcmovbe", "fcmovbe",
351 "fcmovu", "fcmovu", "fcmovu", "fcmovu",
352 "fcmovu", "fcmovu", "fcmovu", "fcmovu",
353 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
354 NULL, "fucompp", NULL, NULL, NULL, NULL, NULL, NULL,
355 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
356 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
358 static const char *k87DBTable1[8] =
359 {"fild", "fisttp", "fist", "fistp", NULL, "fld", NULL, "fstp"};
360 static const char *k87DBTable2[64] = {
361 "fcmovnb", "fcmovnb", "fcmovnb", "fcmovnb",
362 "fcmovnb", "fcmovnb", "fcmovnb", "fcmovnb",
363 "fcmovne", "fcmovne", "fcmovne", "fcmovne",
364 "fcmovne", "fcmovne", "fcmovne", "fcmovne",
365 "fcmovnbe", "fcmovnbe", "fcmovnbe", "fcmovnbe",
366 "fcmovnbe", "fcmovnbe", "fcmovnbe", "fcmovnbe",
367 "fcmovnu", "fcmovnu", "fcmovnu", "fcmovnu",
368 "fcmovnu", "fcmovnu", "fcmovnu", "fcmovnu",
369 NULL, NULL, "fnclex", "fninit", NULL, NULL, NULL, NULL,
370 "fucomi", "fucomi", "fucomi", "fucomi",
371 "fucomi", "fucomi", "fucomi", "fucomi",
372 "fcomi", "fcomi", "fcomi", "fcomi",
373 "fcomi", "fcomi", "fcomi", "fcomi",
374 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
376 static const char *k87DCTable1[8] =
377 {"fadd", "fmul", "fcom", "fcomp", "fsub", "fsubr", "fdiv", "fdivr"};
378 static const char *k87DCTable2[64] = {
379 "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd", "fadd",
380 "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul", "fmul",
381 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
382 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
383 "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr", "fsubr",
384 "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub", "fsub",
385 "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr", "fdivr",
386 "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv", "fdiv" };
388 static const char *k87DDTable1[8] =
389 {"fld", "fisttp", "fst", "fstp", "frstor", NULL, "fnsave", "fnstsw"};
390 static const char *k87DDTable2[64] = {
391 "ffree", "ffree", "ffree", "ffree", "ffree", "ffree", "ffree", "ffree",
392 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
393 "fst", "fst", "fst", "fst", "fst", "fst", "fst", "fst",
394 "fstp", "fstp", "fstp", "fstp", "fstp", "fstp", "fstp", "fstp",
395 "fucom", "fucom", "fucom", "fucom", "fucom", "fucom", "fucom", "fucom",
396 "fucomp", "fucomp", "fucomp", "fucomp",
397 "fucomp", "fucomp", "fucomp", "fucomp",
398 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
399 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
401 static const char *k87DETable1[8] =
402 {"fiadd", "fimul", "ficom", "ficomp", "fisub", "fisubr", "fidiv", "fidivr"};
403 static const char *k87DETable2[64] = {
404 "faddp", "faddp", "faddp", "faddp", "faddp", "faddp", "faddp", "faddp",
405 "fmulp", "fmulp", "fmulp", "fmulp", "fmulp", "fmulp", "fmulp", "fmulp",
406 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
407 NULL, "fcompp", NULL, NULL, NULL, NULL, NULL, NULL,
408 "fsubrp", "fsubrp", "fsubrp", "fsubrp",
409 "fsubrp", "fsubrp", "fsubrp", "fsubrp",
410 "fsubp", "fsubp", "fsubp", "fsubp",
411 "fsubp", "fsubp", "fsubp", "fsubp",
412 "fdivrp", "fdivrp", "fdivrp", "fdivrp",
413 "fdivrp", "fdivrp", "fdivrp", "fdivrp",
414 "fdivp", "fdivp", "fdivp", "fdivp",
415 "fdivp", "fdivp", "fdivp", "fdivp"};
417 static const char *k87DFTable1[8] =
418 {"fild", "fisttp", "fist", "fistp", "fbld", "fild", "fbstp", "fistp"};
419 static const char *k87DFTable2[64] = {
420 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
421 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
422 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
423 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
424 "fnstsw", NULL, NULL, NULL, NULL, NULL, NULL, NULL,
425 "fucomip", "fucomip", "fucomip", "fucomip",
426 "fucomip", "fucomip", "fucomip", "fucomip",
427 "fcomip", "fcomip", "fcomip", "fcomip",
428 "fcomip", "fcomip", "fcomip", "fcomip",
429 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
431 Encode87Op(g_Op87D8, k87D8Table1, k87D8Table2);
432 Encode87Op(g_Op87D9, k87D9Table1, k87D9Table2);
433 Encode87Op(g_Op87DA, k87DATable1, k87DATable2);
434 Encode87Op(g_Op87DB, k87DBTable1, k87DBTable2);
435 Encode87Op(g_Op87DC, k87DCTable1, k87DCTable2);
436 Encode87Op(g_Op87DD, k87DDTable1, k87DDTable2);
437 Encode87Op(g_Op87DE, k87DETable1, k87DETable2);
438 Encode87Op(g_Op87DF, k87DFTable1, k87DFTable2);
439 /* fix instruction type for x87 conditional moves */
440 for (i = 0; i < 8; i++) {
441 g_Op87DA[0xc0 + i]->insttype = NACLi_FCMOV;
442 g_Op87DA[0xc8 + i]->insttype = NACLi_FCMOV;
443 g_Op87DA[0xd0 + i]->insttype = NACLi_FCMOV;
444 g_Op87DA[0xd8 + i]->insttype = NACLi_FCMOV;
445 g_Op87DB[0xc0 + i]->insttype = NACLi_FCMOV;
446 g_Op87DB[0xc8 + i]->insttype = NACLi_FCMOV;
447 g_Op87DB[0xd0 + i]->insttype = NACLi_FCMOV;
448 g_Op87DB[0xd8 + i]->insttype = NACLi_FCMOV;
452 static void BuildMetaTables() {
453 InitializeGlobalTables();
454 /* now add the real contents */
455 /* Eight opcode groups with a regular pattern... */
456 ALUOperandVariants00_05(0x00, NACLi_386L, "add");
457 ALUOperandVariants00_05(0x08, NACLi_386L, "or");
458 ALUOperandVariants00_05(0x10, NACLi_386L, "adc");
459 ALUOperandVariants00_05(0x18, NACLi_386L, "sbb");
460 ALUOperandVariants00_05(0x20, NACLi_386L, "and");
461 ALUOperandVariants00_05(0x28, NACLi_386L, "sub");
462 ALUOperandVariants00_05(0x30, NACLi_386L, "xor");
463 ALUOperandVariants00_05(0x38, NACLi_386, "cmp");
464 /* Fill in gaps between 00 and 0x40 */
465 EncodeOpByte1(0x06, 0, IMM_NONE, NACLi_ILLEGAL, "push %ES");
466 EncodeOpByte1(0x16, 0, IMM_NONE, NACLi_ILLEGAL, "push %SS");
467 EncodeOpByte1(0x26, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %ES]");
468 EncodeOpByte1(0x36, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %SS]");
469 EncodeOpByte1(0x07, 0, IMM_NONE, NACLi_ILLEGAL, "pop %ES");
470 EncodeOpByte1(0x17, 0, IMM_NONE, NACLi_ILLEGAL, "pop %SS");
471 EncodeOpByte1(0x27, 0, IMM_NONE, NACLi_ILLEGAL, "daa");
472 EncodeOpByte1(0x37, 0, IMM_NONE, NACLi_ILLEGAL, "aaa"); /* deprecated */
473 EncodeOpByte1(0x0e, 0, IMM_NONE, NACLi_ILLEGAL, "push %CS");
474 EncodeOpByte1(0x1e, 0, IMM_NONE, NACLi_ILLEGAL, "push %DS");
475 EncodeOpByte1(0x2e, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %CS]");
476 EncodeOpByte1(0x3e, 0, IMM_NONE, NACLi_ILLEGAL, "[seg %DS]");
477 /* 0x0f is an escape to two-byte instructions, below... */
478 EncodeOpByte1(0x0f, 0, IMM_NONE, NACLi_UNDEFINED, "[two-byte opcode]");
479 EncodeOpByte1(0x1f, 0, IMM_NONE, NACLi_ILLEGAL, "pop %DS");
480 EncodeOpByte1(0x2f, 0, IMM_NONE, NACLi_ILLEGAL, "das");
481 EncodeOpByte1(0x3f, 0, IMM_NONE, NACLi_ILLEGAL, "aas"); /* deprecated */
482 /* another easy pattern, 0x40-0x5f */
483 /* inc and dec are deprecated in x86-64; NaCl discourages their use. */
484 OneRegVariants00_07(0x40, NACLi_386L, "inc");
485 OneRegVariants00_07(0x48, NACLi_386L, "dec");
486 OneRegVariants00_07(0x50, NACLi_386, "push");
487 OneRegVariants00_07(0x58, NACLi_386, "pop");
488 /* 0x60-0x6f */
489 EncodeOpByte1(0x60, 0, IMM_NONE, NACLi_ILLEGAL, "pusha");
490 EncodeOpByte1(0x61, 0, IMM_NONE, NACLi_ILLEGAL, "popa"); /* also POPAD */
491 EncodeOpByte1(0x62, 1, IMM_NONE, NACLi_ILLEGAL, "bound $G, $M"); /* deprecated */
492 EncodeOpByte1(0x63, 1, IMM_NONE, NACLi_SYSTEM, "arpl $E, $R"); /* system */
493 EncodeOpByte1(0x64, 0, IMM_NONE, NACLi_ILLEGAL, "[seg fs]");
494 EncodeOpByte1(0x65, 0, IMM_NONE, NACLi_ILLEGAL, "[seg gs]");
495 EncodeOpByte1(0x66, 0, IMM_NONE, NACLi_ILLEGAL, "[data16]");
496 EncodeOpByte1(0x67, 0, IMM_NONE, NACLi_ILLEGAL, "[addr size]");
497 EncodeOpByte1(0x68, 0, IMM_DATAV, NACLi_386, "push $I");
498 EncodeOpByte1(0x69, 1, IMM_DATAV, NACLi_386, "imul $G,$E,$I");
499 EncodeOpByte1(0x6a, 0, IMM_FIXED1, NACLi_386, "push $I");
500 EncodeOpByte1(0x6b, 1, IMM_FIXED1, NACLi_386, "imul $G,$E,$I");
501 EncodeOpByte1(0x6c, 0, IMM_NONE, NACLi_ILLEGAL, "insb $Y, $D");
502 EncodeOpByte1(0x6d, 0, IMM_NONE, NACLi_ILLEGAL, "insw/d $Y, $D");
503 EncodeOpByte1(0x6e, 0, IMM_NONE, NACLi_ILLEGAL, "outsb $D, $X");
504 EncodeOpByte1(0x6f, 0, IMM_NONE, NACLi_ILLEGAL, "outsw/d $D, $X");
505 /* 0x70-0x77: jumps */
506 EncodeOpByte1(0x70, 0, IMM_FIXED1, NACLi_JMP8, "jo $I");
507 EncodeOpByte1(0x71, 0, IMM_FIXED1, NACLi_JMP8, "jno $I");
508 EncodeOpByte1(0x72, 0, IMM_FIXED1, NACLi_JMP8, "jb $I");
509 EncodeOpByte1(0x73, 0, IMM_FIXED1, NACLi_JMP8, "jnb $I");
510 EncodeOpByte1(0x74, 0, IMM_FIXED1, NACLi_JMP8, "jz $I");
511 EncodeOpByte1(0x75, 0, IMM_FIXED1, NACLi_JMP8, "jnz $I");
512 EncodeOpByte1(0x76, 0, IMM_FIXED1, NACLi_JMP8, "jbe $I");
513 EncodeOpByte1(0x77, 0, IMM_FIXED1, NACLi_JMP8, "jnbe $I");
514 EncodeOpByte1(0x78, 0, IMM_FIXED1, NACLi_JMP8, "js $I");
515 EncodeOpByte1(0x79, 0, IMM_FIXED1, NACLi_JMP8, "jns $I");
516 EncodeOpByte1(0x7a, 0, IMM_FIXED1, NACLi_JMP8, "jp $I");
517 EncodeOpByte1(0x7b, 0, IMM_FIXED1, NACLi_JMP8, "jnp $I");
518 EncodeOpByte1(0x7c, 0, IMM_FIXED1, NACLi_JMP8, "jl $I");
519 EncodeOpByte1(0x7d, 0, IMM_FIXED1, NACLi_JMP8, "jge $I");
520 EncodeOpByte1(0x7e, 0, IMM_FIXED1, NACLi_JMP8, "jle $I");
521 EncodeOpByte1(0x7f, 0, IMM_FIXED1, NACLi_JMP8, "jg $I");
522 /* 0x80-0x8f: Gpr1, test, xchg, mov, lea, mov, pop */
523 EncodeOpByte1(0x80, 1, IMM_FIXED1, NACLi_OPINMRM, "$group1 $Eb,$Ib");
524 SetOpByte1OpInMRM(0x80, GROUP1);
525 EncodeOpByte1(0x81, 1, IMM_DATAV, NACLi_OPINMRM, "$group1 $Ev,$Iv");
526 SetOpByte1OpInMRM(0x81, GROUP1);
527 /* The AMD manual shows 0x82 as a synonym for 0x80, however these are */
528 /* all illegal in 64-bit mode so we omit them here too. */
529 EncodeOpByte1(0x82, 1, IMM_FIXED1, NACLi_ILLEGAL, "undef");
530 /* table disagrees with objdump on 0x83? */
531 EncodeOpByte1(0x83, 1, IMM_FIXED1, NACLi_OPINMRM, "$group1 $Eb, $Ib");
532 SetOpByte1OpInMRM(0x83, GROUP1);
533 EncodeOpByte1(0x84, 1, IMM_NONE, NACLi_386, "test $E, $G");
534 EncodeOpByte1(0x85, 1, IMM_NONE, NACLi_386, "test $E, $G");
535 EncodeOpByte1(0x86, 1, IMM_NONE, NACLi_386L, "xchg $E, $G");
536 EncodeOpByte1(0x87, 1, IMM_NONE, NACLi_386L, "xchg $E, $G");
537 EncodeOpByte1(0x88, 1, IMM_NONE, NACLi_386, "mov $Eb, $Gb");
538 EncodeOpByte1(0x89, 1, IMM_NONE, NACLi_386, "mov $Ev, $Gv");
539 EncodeOpByte1(0x8a, 1, IMM_NONE, NACLi_386, "mov $Gb, $Eb");
540 EncodeOpByte1(0x8b, 1, IMM_NONE, NACLi_386, "mov $Gv, $Ev");
541 EncodeOpByte1(0x8c, 1, IMM_NONE, NACLi_ILLEGAL, "mov $E, $S");
542 EncodeOpByte1(0x8d, 1, IMM_NONE, NACLi_386, "lea $G, $M");
543 EncodeOpByte1(0x8e, 1, IMM_NONE, NACLi_ILLEGAL, "mov $S, $E");
544 EncodeOpByte1(0x8f, 1, IMM_NONE, NACLi_OPINMRM, "$group1a");
545 SetOpByte1OpInMRM(0x8f, GROUP1A);
546 /* 0x90-0x9f */
547 EncodeOpByte1(0x90, 0, IMM_NONE, NACLi_386R, "nop");
548 EncodeOpByte1(0x91, 0, IMM_NONE, NACLi_386L, "xchg %eax, %ecx");
549 EncodeOpByte1(0x92, 0, IMM_NONE, NACLi_386L, "xchg %eax, %edx");
550 EncodeOpByte1(0x93, 0, IMM_NONE, NACLi_386L, "xchg %eax, %ebx");
551 EncodeOpByte1(0x94, 0, IMM_NONE, NACLi_386L, "xchg %eax, %esp");
552 EncodeOpByte1(0x95, 0, IMM_NONE, NACLi_386L, "xchg %eax, %ebp");
553 EncodeOpByte1(0x96, 0, IMM_NONE, NACLi_386L, "xchg %eax, %esi");
554 EncodeOpByte1(0x97, 0, IMM_NONE, NACLi_386L, "xchg %eax, %edi");
555 EncodeOpByte1(0x98, 0, IMM_NONE, NACLi_386, "cbw"); /* cwde cdqe */
556 EncodeOpByte1(0x99, 0, IMM_NONE, NACLi_386, "cwd"); /* cdq cqo */
557 EncodeOpByte1(0x9a, 0, IMM_FARPTR, NACLi_ILLEGAL, "lcall $A");
558 EncodeOpByte1(0x9b, 0, IMM_NONE, NACLi_X87, "wait");
559 EncodeOpByte1(0x9c, 0, IMM_NONE, NACLi_ILLEGAL, "pushf $F");
560 EncodeOpByte1(0x9d, 0, IMM_NONE, NACLi_ILLEGAL, "popf $F");
561 EncodeOpByte1(0x9e, 0, IMM_NONE, NACLi_386, "sahf");
562 EncodeOpByte1(0x9f, 0, IMM_NONE, NACLi_386, "lahf");
563 /* 0xa0-0xaf */
564 EncodeOpByte1(0xa0, 0, IMM_ADDRV, NACLi_386, "mov %al, $O");
565 EncodeOpByte1(0xa1, 0, IMM_ADDRV, NACLi_386, "mov %eax, $O");
566 EncodeOpByte1(0xa2, 0, IMM_ADDRV, NACLi_386, "mov $O, %al");
567 EncodeOpByte1(0xa3, 0, IMM_ADDRV, NACLi_386, "mov $O, %eax");
568 EncodeOpByte1(0xa4, 0, IMM_NONE, NACLi_386R, "movsb $X, $Y");
569 EncodeOpByte1(0xa5, 0, IMM_NONE, NACLi_386R, "movsw $X, $Y");
570 EncodeOpByte1(0xa6, 0, IMM_NONE, NACLi_386RE, "cmpsb $X, $Y");
571 EncodeOpByte1(0xa7, 0, IMM_NONE, NACLi_386RE, "cmpsw $X, $Y");
572 EncodeOpByte1(0xa8, 0, IMM_FIXED1, NACLi_386, "test %al, $I");
573 EncodeOpByte1(0xa9, 0, IMM_DATAV, NACLi_386, "test %eax, $I");
574 EncodeOpByte1(0xaa, 0, IMM_NONE, NACLi_386R, "stosb $Y, %al");
575 EncodeOpByte1(0xab, 0, IMM_NONE, NACLi_386R, "stosw $Y, $eax");
576 /* ISE reviewers suggested omiting lods and scas */
577 EncodeOpByte1(0xac, 0, IMM_NONE, NACLi_ILLEGAL, "lodsb %al, $X");
578 EncodeOpByte1(0xad, 0, IMM_NONE, NACLi_ILLEGAL, "lodsw %eax, $X");
579 EncodeOpByte1(0xae, 0, IMM_NONE, NACLi_386RE, "scasb %al, $X");
580 EncodeOpByte1(0xaf, 0, IMM_NONE, NACLi_386RE, "scasw %eax, $X");
581 /* 0xb0-0xbf */
582 EncodeOpByte1(0xb0, 0, IMM_FIXED1, NACLi_386, "mov %al, $I");
583 EncodeOpByte1(0xb1, 0, IMM_FIXED1, NACLi_386, "mov %cl, $I");
584 EncodeOpByte1(0xb2, 0, IMM_FIXED1, NACLi_386, "mov %dl, $I");
585 EncodeOpByte1(0xb3, 0, IMM_FIXED1, NACLi_386, "mov %bl, $I");
586 EncodeOpByte1(0xb4, 0, IMM_FIXED1, NACLi_386, "mov %ah, $I");
587 EncodeOpByte1(0xb5, 0, IMM_FIXED1, NACLi_386, "mov %ch, $I");
588 EncodeOpByte1(0xb6, 0, IMM_FIXED1, NACLi_386, "mov %dh, $I");
589 EncodeOpByte1(0xb7, 0, IMM_FIXED1, NACLi_386, "mov %bh, $I");
590 EncodeOpByte1(0xb8, 0, IMM_DATAV, NACLi_386, "mov %eax, $I");
591 EncodeOpByte1(0xb9, 0, IMM_DATAV, NACLi_386, "mov %ecx, $I");
592 EncodeOpByte1(0xba, 0, IMM_DATAV, NACLi_386, "mov %edx, $I");
593 EncodeOpByte1(0xbb, 0, IMM_DATAV, NACLi_386, "mov %ebx, $I");
594 EncodeOpByte1(0xbc, 0, IMM_DATAV, NACLi_386, "mov %esp, $I");
595 EncodeOpByte1(0xbd, 0, IMM_DATAV, NACLi_386, "mov %ebp, $I");
596 EncodeOpByte1(0xbe, 0, IMM_DATAV, NACLi_386, "mov %esi, $I");
597 EncodeOpByte1(0xbf, 0, IMM_DATAV, NACLi_386, "mov %edi, $I");
598 /* 0xc0-0xcf */
599 EncodeOpByte1(0xc0, 1, IMM_FIXED1, NACLi_OPINMRM, "$group2 $Eb, $Ib");
600 SetOpByte1OpInMRM(0xc0, GROUP2);
601 EncodeOpByte1(0xc1, 1, IMM_FIXED1, NACLi_OPINMRM, "$group2 $Ev, $Ib");
602 SetOpByte1OpInMRM(0xc1, GROUP2);
603 EncodeOpByte1(0xc2, 0, IMM_FIXED2, NACLi_RETURN, "ret");
604 EncodeOpByte1(0xc3, 0, IMM_NONE, NACLi_RETURN, "ret $I");
605 EncodeOpByte1(0xc4, 1, IMM_NONE, NACLi_ILLEGAL, "les $G, $M");
606 EncodeOpByte1(0xc5, 1, IMM_NONE, NACLi_ILLEGAL, "lds $G, $M");
607 EncodeOpByte1(0xc6, 1, IMM_FIXED1, NACLi_OPINMRM, "$group11");
608 SetOpByte1OpInMRM(0xc6, GROUP11);
609 EncodeOpByte1(0xc7, 1, IMM_DATAV, NACLi_OPINMRM, "$group11");
610 SetOpByte1OpInMRM(0xc7, GROUP11);
611 EncodeOpByte1(0xc8, 0, IMM_FIXED3, NACLi_ILLEGAL, "enter $I, $I");
612 EncodeOpByte1(0xc9, 0, IMM_NONE, NACLi_386, "leave");
613 EncodeOpByte1(0xca, 0, IMM_FIXED2, NACLi_RETURN, "ret (far)");
614 EncodeOpByte1(0xcb, 0, IMM_NONE, NACLi_RETURN, "ret (far)");
615 EncodeOpByte1(0xcc, 0, IMM_NONE, NACLi_ILLEGAL, "int3");
616 EncodeOpByte1(0xcd, 0, IMM_FIXED1, NACLi_ILLEGAL, "int $Iv");
617 EncodeOpByte1(0xce, 0, IMM_NONE, NACLi_ILLEGAL, "into");
618 EncodeOpByte1(0xcf, 0, IMM_NONE, NACLi_SYSTEM, "iret");
619 /* 0xd0-0xdf */
620 EncodeOpByte1(0xd0, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Eb, 1");
621 SetOpByte1OpInMRM(0xd0, GROUP2);
622 EncodeOpByte1(0xd1, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Ev, 1");
623 SetOpByte1OpInMRM(0xd1, GROUP2);
624 EncodeOpByte1(0xd2, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Eb, %cl");
625 SetOpByte1OpInMRM(0xd2, GROUP2);
626 EncodeOpByte1(0xd3, 1, IMM_NONE, NACLi_OPINMRM, "$group2 $Ev, %cl");
627 SetOpByte1OpInMRM(0xd3, GROUP2);
628 /* ISE reviewers suggested omision of AAM, AAD */
629 EncodeOpByte1(0xd4, 0, IMM_FIXED1, NACLi_ILLEGAL, "aam"); /* deprecated */
630 EncodeOpByte1(0xd5, 0, IMM_FIXED1, NACLi_ILLEGAL, "aad"); /* deprecated */
631 EncodeOpByte1(0xd6, 0, IMM_NONE, NACLi_ILLEGAL, "salc");
632 /* ISE reviewers suggested this omision */
633 EncodeOpByte1(0xd7, 0, IMM_NONE, NACLi_ILLEGAL, "xlat");
634 EncodeOpByte1(0xd8, 1, IMM_NONE, NACLi_X87, "x87");
635 EncodeOpByte1(0xd9, 1, IMM_NONE, NACLi_X87, "x87");
636 EncodeOpByte1(0xda, 1, IMM_NONE, NACLi_X87, "x87");
637 EncodeOpByte1(0xdb, 1, IMM_NONE, NACLi_X87, "x87");
638 EncodeOpByte1(0xdc, 1, IMM_NONE, NACLi_X87, "x87");
639 EncodeOpByte1(0xdd, 1, IMM_NONE, NACLi_X87, "x87");
640 EncodeOpByte1(0xde, 1, IMM_NONE, NACLi_X87, "x87");
641 EncodeOpByte1(0xdf, 1, IMM_NONE, NACLi_X87, "x87");
642 /* 0xe0-0xef */
643 /* ISE reviewers suggested making loopne, loope, loop, jcxz illegal */
644 /* There are faster alternatives on modern x86 implementations. */
645 EncodeOpByte1(0xe0, 0, IMM_FIXED1, NACLi_ILLEGAL, "loopne $J");
646 EncodeOpByte1(0xe1, 0, IMM_FIXED1, NACLi_ILLEGAL, "loope $J");
647 EncodeOpByte1(0xe2, 0, IMM_FIXED1, NACLi_ILLEGAL, "loop $J");
648 EncodeOpByte1(0xe3, 0, IMM_FIXED1, NACLi_ILLEGAL, "jcxz $J");
649 /* I/O instructions */
650 EncodeOpByte1(0xe4, 0, IMM_FIXED1, NACLi_ILLEGAL, "in %al, $I");
651 EncodeOpByte1(0xe5, 0, IMM_FIXED1, NACLi_ILLEGAL, "in %eax, $I");
652 EncodeOpByte1(0xe6, 0, IMM_FIXED1, NACLi_ILLEGAL, "out %al, $I");
653 EncodeOpByte1(0xe7, 0, IMM_FIXED1, NACLi_ILLEGAL, "out %eax, $I");
654 EncodeOpByte1(0xe8, 0, IMM_DATAV, NACLi_JMPZ, "call $A");
655 EncodeOpByte1(0xe9, 0, IMM_DATAV, NACLi_JMPZ, "jmp $J");
656 EncodeOpByte1(0xea, 0, IMM_FARPTR, NACLi_ILLEGAL, "ljmp $A");
657 EncodeOpByte1(0xeb, 0, IMM_FIXED1, NACLi_JMP8, "jmp $J");
658 EncodeOpByte1(0xec, 0, IMM_NONE, NACLi_ILLEGAL, "in %al, $DX");
659 EncodeOpByte1(0xed, 0, IMM_NONE, NACLi_ILLEGAL, "in %eax, $DX");
660 EncodeOpByte1(0xee, 0, IMM_NONE, NACLi_ILLEGAL, "out $DX, %al");
661 EncodeOpByte1(0xef, 0, IMM_NONE, NACLi_ILLEGAL, "out $DX, %eax");
662 /* 0xf0-0xff */
663 EncodeOpByte1(0xf0, 0, IMM_NONE, NACLi_ILLEGAL, "[lock]");
664 EncodeOpByte1(0xf1, 0, IMM_NONE, NACLi_ILLEGAL, "int1");
665 EncodeOpByte1(0xf2, 0, IMM_NONE, NACLi_ILLEGAL, "[repne]");
666 EncodeOpByte1(0xf3, 0, IMM_NONE, NACLi_ILLEGAL, "[rep]");
667 /* NaCl uses the hlt instruction for bytes that should never be */
668 /* executed. hlt causes immediate termination of the module. */
669 EncodeOpByte1(0xf4, 0, IMM_NONE, NACLi_386, "hlt");
670 EncodeOpByte1(0xf5, 0, IMM_NONE, NACLi_386, "cmc");
671 EncodeOpByte1(0xf6, 1, IMM_GROUP3_F6, NACLi_OPINMRM, "$group3 $E");
672 SetOpByte1OpInMRM(0xf6, GROUP3);
673 EncodeOpByte1(0xf7, 1, IMM_GROUP3_F7, NACLi_OPINMRM, "$group3 $E");
674 SetOpByte1OpInMRM(0xf7, GROUP3);
675 EncodeOpByte1(0xf8, 0, IMM_NONE, NACLi_386, "clc");
676 EncodeOpByte1(0xf9, 0, IMM_NONE, NACLi_386, "stc");
677 EncodeOpByte1(0xfa, 0, IMM_NONE, NACLi_SYSTEM, "cli");
678 EncodeOpByte1(0xfb, 0, IMM_NONE, NACLi_SYSTEM, "sti");
679 /* cld and std are generated by gcc, used for mem move operations */
680 EncodeOpByte1(0xfc, 0, IMM_NONE, NACLi_386, "cld");
681 EncodeOpByte1(0xfd, 0, IMM_NONE, NACLi_386, "std");
682 EncodeOpByte1(0xfe, 1, IMM_NONE, NACLi_OPINMRM, "$group4 $E");
683 SetOpByte1OpInMRM(0xfe, GROUP4);
684 EncodeOpByte1(0xff, 1, IMM_NONE, NACLi_OPINMRM, "$group5 $Ev");
685 SetOpByte1OpInMRM(0xff, GROUP5);
687 /* Opcodes encoded in the modrm field */
688 /* Anything not done explicitly is marked illegal */
689 /* group1 */
690 EncodeModRMOp(GROUP1, 0, NACLi_386L, "add");
691 EncodeModRMOp(GROUP1, 1, NACLi_386L, "or");
692 EncodeModRMOp(GROUP1, 2, NACLi_386L, "adc");
693 EncodeModRMOp(GROUP1, 3, NACLi_386L, "sbb");
694 EncodeModRMOp(GROUP1, 4, NACLi_386L, "and");
695 EncodeModRMOp(GROUP1, 5, NACLi_386L, "sub");
696 EncodeModRMOp(GROUP1, 6, NACLi_386L, "xor");
697 EncodeModRMOp(GROUP1, 7, NACLi_386, "cmp");
698 /* group1a */
699 EncodeModRMOp(GROUP1A, 0, NACLi_386, "pop $Ev");
700 /* all other group1a opcodes are illegal */
701 /* group2 */
702 EncodeModRMOp(GROUP2, 0, NACLi_386, "rol");
703 EncodeModRMOp(GROUP2, 1, NACLi_386, "ror");
704 EncodeModRMOp(GROUP2, 2, NACLi_386, "rcl");
705 EncodeModRMOp(GROUP2, 3, NACLi_386, "rcr");
706 EncodeModRMOp(GROUP2, 4, NACLi_386, "shl"); /* sal */
707 EncodeModRMOp(GROUP2, 5, NACLi_386, "shr"); /* sar */
708 /* note 2, 6 is illegal according to Intel, shl according to AMD */
709 EncodeModRMOp(GROUP2, 7, NACLi_386, "sar");
710 /* group3 */
711 EncodeModRMOp(GROUP3, 0, NACLi_386, "test $I");
712 /* this is such a weird case ... just put a special case in ncdecode.c */
713 /* note 3, 1 is handled by a special case in the decoder */
714 /* SetModRMOpImmType(3, 0, IMM_FIXED1); */
715 EncodeModRMOp(GROUP3, 2, NACLi_386L, "not");
716 EncodeModRMOp(GROUP3, 3, NACLi_386L, "neg");
717 EncodeModRMOp(GROUP3, 4, NACLi_386, "mul %eax");
718 EncodeModRMOp(GROUP3, 5, NACLi_386, "imul %eax");
719 EncodeModRMOp(GROUP3, 6, NACLi_386, "div %eax");
720 EncodeModRMOp(GROUP3, 7, NACLi_386, "idiv %eax");
721 /* group4 */
722 EncodeModRMOp(GROUP4, 0, NACLi_386L, "inc");
723 EncodeModRMOp(GROUP4, 1, NACLi_386L, "dec");
724 /* group5 */
725 EncodeModRMOp(GROUP5, 0, NACLi_386L, "inc $E");
726 EncodeModRMOp(GROUP5, 1, NACLi_386L, "dec $E");
727 EncodeModRMOp(GROUP5, 2, NACLi_INDIRECT, "call $E"); /* call indirect */
728 EncodeModRMOp(GROUP5, 3, NACLi_ILLEGAL, "lcall $E"); /* far call */
729 EncodeModRMOp(GROUP5, 4, NACLi_INDIRECT, "jmp $E"); /* jump indirect */
730 EncodeModRMOp(GROUP5, 5, NACLi_ILLEGAL, "ljmp $E"); /* far jmp */
731 EncodeModRMOp(GROUP5, 6, NACLi_386, "push $E");
732 /* group6 */
733 EncodeModRMOp(GROUP6, 0, NACLi_SYSTEM, "sldt");
734 EncodeModRMOp(GROUP6, 1, NACLi_SYSTEM, "str");
735 EncodeModRMOp(GROUP6, 2, NACLi_SYSTEM, "lldt");
736 EncodeModRMOp(GROUP6, 3, NACLi_SYSTEM, "ltr");
737 EncodeModRMOp(GROUP6, 4, NACLi_SYSTEM, "verr");
738 EncodeModRMOp(GROUP6, 5, NACLi_SYSTEM, "verw");
739 /* group7 */
740 EncodeModRMOp(GROUP7, 0, NACLi_SYSTEM, "sgdt");
741 EncodeModRMOp(GROUP7, 1, NACLi_SYSTEM, "sidt"); /* monitor mwait */
742 EncodeModRMOp(GROUP7, 2, NACLi_SYSTEM, "lgdt");
743 EncodeModRMOp(GROUP7, 3, NACLi_SYSTEM, "lidt");
744 EncodeModRMOp(GROUP7, 4, NACLi_SYSTEM, "smsw");
745 EncodeModRMOp(GROUP7, 6, NACLi_SYSTEM, "lmsw");
746 EncodeModRMOp(GROUP7, 7, NACLi_SYSTEM, "invlpg"); /* swapgs rdtscp */
747 /* group8 */
748 /* ISE reviewers suggested omitting bt* */
749 EncodeModRMOp(GROUP8, 4, NACLi_ILLEGAL, "bt"); /* deprecated */
750 EncodeModRMOp(GROUP8, 5, NACLi_ILLEGAL, "bts"); /* deprecated */
751 EncodeModRMOp(GROUP8, 6, NACLi_ILLEGAL, "btr"); /* deprecated */
752 EncodeModRMOp(GROUP8, 7, NACLi_ILLEGAL, "btc"); /* deprecated */
753 /* group9 */
754 /* If the effective operand size is 16 or 32 bits, cmpxchg8b is used. */
755 /* If the size is 64 bits, cmpxchg16b is used, (64-bit mode only) */
756 /* These instructions do support the LOCK prefix */
757 EncodeModRMOp(GROUP9, 1, NACLi_CMPXCHG8B, "cmpxchg8b");
758 /* group10 - all illegal */
759 /* group11 */
760 EncodeModRMOp(GROUP11, 0, NACLi_386, "mov");
761 /* group12 */
762 EncodeModRMOp(GROUP12, 2, NACLi_MMXSSE2, "psrlw");
763 EncodeModRMOp(GROUP12, 4, NACLi_MMXSSE2, "psraw");
764 EncodeModRMOp(GROUP12, 6, NACLi_MMXSSE2, "psllw");
765 /* group13 */
766 EncodeModRMOp(GROUP13, 2, NACLi_MMXSSE2, "psrld");
767 EncodeModRMOp(GROUP13, 4, NACLi_MMXSSE2, "psrad");
768 EncodeModRMOp(GROUP13, 6, NACLi_MMXSSE2, "pslld");
769 /* group14 */
770 EncodeModRMOp(GROUP14, 2, NACLi_MMXSSE2, "psrlq");
771 EncodeModRMOp(GROUP14, 3, NACLi_SSE2x, "psrldq");
772 EncodeModRMOp(GROUP14, 6, NACLi_MMXSSE2, "psllq");
773 EncodeModRMOp(GROUP14, 7, NACLi_SSE2x, "pslldq");
774 /* group15 */
775 EncodeModRMOp(GROUP15, 0, NACLi_ILLEGAL, "fxsave");
776 EncodeModRMOp(GROUP15, 1, NACLi_ILLEGAL, "fxrstor");
777 EncodeModRMOp(GROUP15, 2, NACLi_ILLEGAL, "ldmxcsr"); /* SSE */
778 EncodeModRMOp(GROUP15, 3, NACLi_ILLEGAL, "stmxcsr");
779 EncodeModRMOp(GROUP15, 4, NACLi_ILLEGAL, "invalid");
780 TODO;
781 EncodeModRMOp(GROUP15, 5, NACLi_ILLEGAL, "lfence");
782 EncodeModRMOp(GROUP15, 6, NACLi_SSE2, "mfence");
783 EncodeModRMOp(GROUP15, 7, NACLi_ILLEGAL, "sfence/clflush");
784 /* group16 - SSE prefetch instructions */
785 EncodeModRMOp(GROUP16, 0, NACLi_SSE, "prefetch NTA");
786 EncodeModRMOp(GROUP16, 1, NACLi_SSE, "prefetch T0");
787 EncodeModRMOp(GROUP16, 2, NACLi_SSE, "prefetch T1");
788 EncodeModRMOp(GROUP16, 3, NACLi_SSE, "prefetch T1");
789 EncodeModRMOp(GROUP16, 4, NACLi_ILLEGAL, "NOP (prefetch)");
790 EncodeModRMOp(GROUP16, 5, NACLi_ILLEGAL, "NOP (prefetch)");
791 EncodeModRMOp(GROUP16, 6, NACLi_ILLEGAL, "NOP (prefetch)");
792 EncodeModRMOp(GROUP16, 7, NACLi_ILLEGAL, "NOP (prefetch)");
793 /* groupp: prefetch - requires longmode or 3DNow! */
794 /* It may be the case that these can also be enabled by CPUID_ECX_PRE; */
795 /* This enabling is not supported by the validator at this time. */
796 EncodeModRMOp(GROUPP, 0, NACLi_3DNOW, "prefetch exclusive");
797 EncodeModRMOp(GROUPP, 1, NACLi_3DNOW, "prefetch modified");
798 EncodeModRMOp(GROUPP, 2, NACLi_ILLEGAL, "[prefetch reserved]");
799 EncodeModRMOp(GROUPP, 3, NACLi_ILLEGAL, "prefetch modified");
800 EncodeModRMOp(GROUPP, 4, NACLi_ILLEGAL, "[prefetch reserved]");
801 EncodeModRMOp(GROUPP, 5, NACLi_ILLEGAL, "[prefetch reserved]");
802 EncodeModRMOp(GROUPP, 6, NACLi_ILLEGAL, "[prefetch reserved]");
803 EncodeModRMOp(GROUPP, 7, NACLi_ILLEGAL, "[prefetch reserved]");
805 /* encode opbyte 2; first byte is 0x0f */
806 /* holes are undefined instructions */
807 /* prefix can be: none 66 F2 F3 */
808 EncodeOp0F(0x00, 1, IMM_NONE, NACLi_OPINMRM, "$group6 $E");
809 SetOp0FOpInMRM(0x0, GROUP6);
810 /* Group7 is all privileged/system instructions */
811 EncodeOp0F(0x01, 1, IMM_NONE, NACLi_OPINMRM, "$group7");
812 SetOp0FOpInMRM(0x01, GROUP7);
813 EncodeOp0F(0x02, 1, IMM_NONE, NACLi_SYSTEM, "lar $G, $E");
814 EncodeOp0F(0x03, 1, IMM_NONE, NACLi_ILLEGAL, "lsl, $Gv, $Ew");
815 EncodeOp0F(0x05, 0, IMM_NONE, NACLi_SYSCALL, "syscall");
816 EncodeOp0F(0x06, 0, IMM_NONE, NACLi_SYSTEM, "clts");
817 EncodeOp0F(0x07, 0, IMM_NONE, NACLi_ILLEGAL, "sysret");
818 EncodeOp0F(0x08, 0, IMM_NONE, NACLi_SYSTEM, "invd");
819 EncodeOp0F(0x09, 0, IMM_NONE, NACLi_SYSTEM, "wbinvd");
820 EncodeOp0F(0x0b, 0, IMM_NONE, NACLi_ILLEGAL, "ud2");
821 EncodeOp0F(0x0d, 1, IMM_NONE, NACLi_OPINMRM, "$groupP (prefetch)");
822 SetOp0FOpInMRM(0x0d, GROUPP);
823 EncodeOp0F(0x0e, 0, IMM_NONE, NACLi_3DNOW, "femms");
824 /* 3DNow instruction encodings use a MODRM byte and a 1-byte */
825 /* immediate which defines the opcode. */
826 EncodeOp0F(0x0f, 1, IMM_FIXED1, NACLi_3DNOW, "3DNow");
827 /* 0x10-17 appear below with the other newer opcodes ... */
828 EncodeOp0F(0x18, 1, IMM_NONE, NACLi_OPINMRM, "$group16");
829 SetOp0FOpInMRM(0x18, GROUP16);
830 /* this nop takes an MRM byte */
831 EncodeOp0F(0x1f, 1, IMM_NONE, NACLi_386, "nop");
832 EncodeOp0F(0x20, 1, IMM_NONE, NACLi_SYSTEM, "mov $C, $R");
833 EncodeOp0F(0x21, 1, IMM_NONE, NACLi_SYSTEM, "mov $D, $R");
834 EncodeOp0F(0x22, 1, IMM_NONE, NACLi_SYSTEM, "mov $R, $C");
835 EncodeOp0F(0x23, 1, IMM_NONE, NACLi_SYSTEM, "mov $R, $D");
836 /* These two seem to be a mistake */
837 /* EncodeOp0F(0x24, 0, IMM_NONE, NACLi_SYSTEM, "mov $T, $R"); */
838 /* EncodeOp0F(0x26, 0, IMM_NONE, NACLi_SYSTEM, "mov $R, %T"); */
839 /* 0x30-0x38 */
840 EncodeOp0F(0x30, 0, IMM_NONE, NACLi_RDMSR, "wrmsr");
841 EncodeOp0F(0x31, 0, IMM_NONE, NACLi_RDTSC, "rdtsc");
842 EncodeOp0F(0x32, 0, IMM_NONE, NACLi_RDMSR, "rdmsr");
843 EncodeOp0F(0x33, 0, IMM_NONE, NACLi_SYSTEM, "rdpmc");
844 EncodeOp0F(0x34, 0, IMM_NONE, NACLi_SYSENTER, "sysenter");
845 EncodeOp0F(0x35, 0, IMM_NONE, NACLi_SYSENTER, "sysexit");
846 EncodeOp0F(0x38, 1, IMM_NONE, NACLi_3BYTE, "SSSE3");
847 EncodeOp0F(0x3a, 1, IMM_FIXED1, NACLi_3BYTE, "SSSE3");
848 /* 0x40-0x48 */
849 EncodeOp0F(0x40, 1, IMM_NONE, NACLi_CMOV, "cmovo");
850 EncodeOp0F(0x41, 1, IMM_NONE, NACLi_CMOV, "cmovno");
851 EncodeOp0F(0x42, 1, IMM_NONE, NACLi_CMOV, "cmovb");
852 EncodeOp0F(0x43, 1, IMM_NONE, NACLi_CMOV, "cmovnb");
853 EncodeOp0F(0x44, 1, IMM_NONE, NACLi_CMOV, "cmovz");
854 EncodeOp0F(0x45, 1, IMM_NONE, NACLi_CMOV, "cmovnz");
855 EncodeOp0F(0x46, 1, IMM_NONE, NACLi_CMOV, "cmovbe");
856 EncodeOp0F(0x47, 1, IMM_NONE, NACLi_CMOV, "cmovnbe");
857 EncodeOp0F(0x48, 1, IMM_NONE, NACLi_CMOV, "cmovs");
858 EncodeOp0F(0x49, 1, IMM_NONE, NACLi_CMOV, "cmovns");
859 EncodeOp0F(0x4a, 1, IMM_NONE, NACLi_CMOV, "cmovp");
860 EncodeOp0F(0x4b, 1, IMM_NONE, NACLi_CMOV, "cmovnp");
861 EncodeOp0F(0x4c, 1, IMM_NONE, NACLi_CMOV, "cmovl");
862 EncodeOp0F(0x4d, 1, IMM_NONE, NACLi_CMOV, "cmovnl");
863 EncodeOp0F(0x4e, 1, IMM_NONE, NACLi_CMOV, "cmovle");
864 EncodeOp0F(0x4f, 1, IMM_NONE, NACLi_CMOV, "cmovnle");
865 /* 0x80-0x8f */
866 EncodeOp0F(0x80, 0, IMM_DATAV, NACLi_JMPZ, "jo $I");
867 EncodeOp0F(0x81, 0, IMM_DATAV, NACLi_JMPZ, "jno $I");
868 EncodeOp0F(0x82, 0, IMM_DATAV, NACLi_JMPZ, "jb $I");
869 EncodeOp0F(0x83, 0, IMM_DATAV, NACLi_JMPZ, "jnb $I");
870 EncodeOp0F(0x84, 0, IMM_DATAV, NACLi_JMPZ, "jz $I");
871 EncodeOp0F(0x85, 0, IMM_DATAV, NACLi_JMPZ, "jnz $I");
872 EncodeOp0F(0x86, 0, IMM_DATAV, NACLi_JMPZ, "jbe $I");
873 EncodeOp0F(0x87, 0, IMM_DATAV, NACLi_JMPZ, "jnbe $I");
874 EncodeOp0F(0x88, 0, IMM_DATAV, NACLi_JMPZ, "js $I");
875 EncodeOp0F(0x89, 0, IMM_DATAV, NACLi_JMPZ, "jns $I");
876 EncodeOp0F(0x8a, 0, IMM_DATAV, NACLi_JMPZ, "jp $I");
877 EncodeOp0F(0x8b, 0, IMM_DATAV, NACLi_JMPZ, "jnp $I");
878 EncodeOp0F(0x8c, 0, IMM_DATAV, NACLi_JMPZ, "jl $I");
879 EncodeOp0F(0x8d, 0, IMM_DATAV, NACLi_JMPZ, "jge $I");
880 EncodeOp0F(0x8e, 0, IMM_DATAV, NACLi_JMPZ, "jle $I");
881 EncodeOp0F(0x8f, 0, IMM_DATAV, NACLi_JMPZ, "jg $I");
882 /* 0x90-0x9f */
883 EncodeOp0F(0x90, 1, IMM_NONE, NACLi_386, "seto");
884 EncodeOp0F(0x91, 1, IMM_NONE, NACLi_386, "setno");
885 EncodeOp0F(0x92, 1, IMM_NONE, NACLi_386, "setb");
886 EncodeOp0F(0x93, 1, IMM_NONE, NACLi_386, "setnb");
887 EncodeOp0F(0x94, 1, IMM_NONE, NACLi_386, "setz");
888 EncodeOp0F(0x95, 1, IMM_NONE, NACLi_386, "setnz");
889 EncodeOp0F(0x96, 1, IMM_NONE, NACLi_386, "setbe");
890 EncodeOp0F(0x97, 1, IMM_NONE, NACLi_386, "setnbe");
891 EncodeOp0F(0x98, 1, IMM_NONE, NACLi_386, "sets");
892 EncodeOp0F(0x99, 1, IMM_NONE, NACLi_386, "setns");
893 EncodeOp0F(0x9a, 1, IMM_NONE, NACLi_386, "setp");
894 EncodeOp0F(0x9b, 1, IMM_NONE, NACLi_386, "setnp");
895 EncodeOp0F(0x9c, 1, IMM_NONE, NACLi_386, "setl");
896 EncodeOp0F(0x9d, 1, IMM_NONE, NACLi_386, "setge");
897 EncodeOp0F(0x9e, 1, IMM_NONE, NACLi_386, "setle");
898 EncodeOp0F(0x9f, 1, IMM_NONE, NACLi_386, "setg");
899 /* 0xa0-0xaf */
900 EncodeOp0F(0xa0, 0, IMM_NONE, NACLi_ILLEGAL, "push fs");
901 EncodeOp0F(0xa1, 0, IMM_NONE, NACLi_ILLEGAL, "pop fs");
902 EncodeOp0F(0xa2, 0, IMM_NONE, NACLi_386, "cpuid");
903 EncodeOp0F(0xa3, 1, IMM_NONE, NACLi_ILLEGAL, "bt $Ev, $Gv");
904 /* ISE reviewers suggested omitting shld */
905 EncodeOp0F(0xa4, 1, IMM_FIXED1, NACLi_386, "shld $Ev, $Gv, $Ib");
906 EncodeOp0F(0xa5, 1, IMM_NONE, NACLi_386, "shld $Ev, $Gv, $CL");
907 EncodeOp0F(0xa6, 0, IMM_NONE, NACLi_INVALID, "invalid");
908 EncodeOp0F(0xa7, 0, IMM_NONE, NACLi_INVALID, "invalid");
909 EncodeOp0F(0xa8, 0, IMM_NONE, NACLi_ILLEGAL, "push gs");
910 EncodeOp0F(0xa9, 0, IMM_NONE, NACLi_ILLEGAL, "pop gs");
911 EncodeOp0F(0xaa, 0, IMM_NONE, NACLi_SYSTEM, "rsm");
912 EncodeOp0F(0xab, 1, IMM_NONE, NACLi_386, "bts $Ev, $Gv");
913 /* ISE reviewers suggested omitting shrd */
914 EncodeOp0F(0xac, 1, IMM_FIXED1, NACLi_386, "shrd $Ev, $Gv, $Ib");
915 EncodeOp0F(0xad, 1, IMM_NONE, NACLi_386, "shrd $Ev, $Gv, $CL");
916 /* fxsave fxrstor ldmxcsr stmxcsr clflush */
917 /* lfence mfence sfence */
918 EncodeOp0F(0xae, 1, IMM_NONE, NACLi_OPINMRM, "$group15");
919 SetOp0FOpInMRM(0xae, GROUP15);
920 EncodeOp0F(0xaf, 1, IMM_NONE, NACLi_386, "imul $Gv, $Ev");
921 /* 0xb0-0xbf */
922 /* Note NaCl doesn't allow 16-bit cmpxchg */
923 EncodeOp0F(0xb0, 1, IMM_NONE, NACLi_386L, "cmpxchg $E, $G");
924 EncodeOp0F(0xb1, 1, IMM_NONE, NACLi_386L, "cmpxchg $E, $G");
925 EncodeOp0F(0xb2, 1, IMM_NONE, NACLi_ILLEGAL, "lss $Mp");
926 EncodeOp0F(0xb3, 1, IMM_NONE, NACLi_386, "btr $Ev, $Gv");
927 EncodeOp0F(0xb4, 1, IMM_NONE, NACLi_ILLEGAL, "lfs $Mp");
928 EncodeOp0F(0xb5, 1, IMM_NONE, NACLi_ILLEGAL, "lgs $Mp");
929 EncodeOp0F(0xb6, 1, IMM_NONE, NACLi_386, "movzx $Gv, $Eb");
930 EncodeOp0F(0xb7, 1, IMM_NONE, NACLi_386, "movzx $Gv, $Ew");
932 EncodeOp0F(0xc8, 0, IMM_NONE, NACLi_386, "bswap eax");
933 EncodeOp0F(0xc9, 0, IMM_NONE, NACLi_386, "bswap ecx");
934 EncodeOp0F(0xca, 0, IMM_NONE, NACLi_386, "bswap edx");
935 EncodeOp0F(0xcb, 0, IMM_NONE, NACLi_386, "bswap ebx");
936 EncodeOp0F(0xcc, 0, IMM_NONE, NACLi_386, "bswap esp");
937 EncodeOp0F(0xcd, 0, IMM_NONE, NACLi_386, "bswap ebp");
938 EncodeOp0F(0xce, 0, IMM_NONE, NACLi_386, "bswap esi");
939 EncodeOp0F(0xcf, 0, IMM_NONE, NACLi_386, "bswap edi");
941 /* Instructions from ?? 0F 10 to ?? 0F 1F */
942 EncodeOp0F(0x10, 1, IMM_NONE, NACLi_SSE, "movups");
943 EncodeOpF3(0x10, 1, IMM_NONE, NACLi_SSE, "movss");
944 EncodeOp66(0x10, 1, IMM_NONE, NACLi_SSE2, "movupd");
945 EncodeOpF2(0x10, 1, IMM_NONE, NACLi_SSE2, "movsd");
947 EncodeOp0F(0x11, 1, IMM_NONE, NACLi_SSE, "movups");
948 EncodeOpF3(0x11, 1, IMM_NONE, NACLi_SSE, "movss");
949 EncodeOp66(0x11, 1, IMM_NONE, NACLi_SSE2, "movupd");
950 EncodeOpF2(0x11, 1, IMM_NONE, NACLi_SSE2, "movsd");
952 EncodeOp0F(0x12, 1, IMM_NONE, NACLi_SSE, "movlps"); /* or movhlps */
953 EncodeOpF3(0x12, 1, IMM_NONE, NACLi_SSE3, "movsldup");
954 EncodeOp66(0x12, 1, IMM_NONE, NACLi_SSE2, "movlpd");
955 EncodeOpF2(0x12, 1, IMM_NONE, NACLi_SSE3, "movddup");
957 EncodeOp0F(0x13, 1, IMM_NONE, NACLi_SSE, "movlps");
958 EncodeOpF3(0x13, 0, IMM_NONE, NACLi_INVALID, "invalid");
959 EncodeOp66(0x13, 1, IMM_NONE, NACLi_SSE2, "movlpd");
960 EncodeOpF2(0x13, 0, IMM_NONE, NACLi_INVALID, "invalid");
962 EncodeOp0F(0x14, 1, IMM_NONE, NACLi_SSE, "unpcklps");
963 EncodeOpF3(0x14, 0, IMM_NONE, NACLi_INVALID, "invalid");
964 EncodeOp66(0x14, 1, IMM_NONE, NACLi_SSE2, "unpcklpd");
965 EncodeOpF2(0x14, 0, IMM_NONE, NACLi_INVALID, "invalid");
967 EncodeOp0F(0x15, 1, IMM_NONE, NACLi_SSE, "unpckhps");
968 EncodeOpF3(0x15, 0, IMM_NONE, NACLi_INVALID, "invalid");
969 EncodeOp66(0x15, 1, IMM_NONE, NACLi_SSE2, "unpckhpd");
970 EncodeOpF2(0x15, 0, IMM_NONE, NACLi_INVALID, "invalid");
972 EncodeOp0F(0x16, 1, IMM_NONE, NACLi_SSE, "movhps"); /* or movlhps */
973 EncodeOpF3(0x16, 1, IMM_NONE, NACLi_SSE3, "movshdup");
974 EncodeOp66(0x16, 1, IMM_NONE, NACLi_SSE2, "movhpd");
975 EncodeOpF2(0x16, 0, IMM_NONE, NACLi_INVALID, "invalid");
977 EncodeOp0F(0x17, 1, IMM_NONE, NACLi_SSE, "movhps");
978 EncodeOpF3(0x17, 0, IMM_NONE, NACLi_INVALID, "invalid");
979 EncodeOp66(0x17, 1, IMM_NONE, NACLi_SSE2, "movhpd");
980 EncodeOpF2(0x17, 0, IMM_NONE, NACLi_INVALID, "invalid");
982 /* Instructions from ?? 0F 28 to ?? 0F 2F */
983 EncodeOp0F(0x28, 1, IMM_NONE, NACLi_SSE, "movaps");
984 EncodeOpF3(0x28, 0, IMM_NONE, NACLi_INVALID, "invalid");
985 EncodeOp66(0x28, 1, IMM_NONE, NACLi_SSE2, "movapd");
986 EncodeOpF2(0x28, 0, IMM_NONE, NACLi_INVALID, "invalid");
988 EncodeOp0F(0x29, 1, IMM_NONE, NACLi_SSE, "movaps");
989 EncodeOpF3(0x29, 0, IMM_NONE, NACLi_INVALID, "invalid");
990 EncodeOp66(0x29, 1, IMM_NONE, NACLi_SSE2, "movapd");
991 EncodeOpF2(0x29, 0, IMM_NONE, NACLi_INVALID, "invalid");
993 EncodeOp0F(0x2a, 1, IMM_NONE, NACLi_SSE, "cvtpi2ps");
994 EncodeOpF3(0x2a, 1, IMM_NONE, NACLi_SSE, "cvtsi2ss");
995 EncodeOp66(0x2a, 1, IMM_NONE, NACLi_SSE2, "cvtpi2pd");
996 EncodeOpF2(0x2a, 1, IMM_NONE, NACLi_SSE2, "cvtsi2sd");
998 EncodeOp0F(0x2b, 1, IMM_NONE, NACLi_SSE, "movntps");
999 EncodeOpF3(0x2b, 1, IMM_NONE, NACLi_SSE4A, "movntss");
1000 EncodeOp66(0x2b, 1, IMM_NONE, NACLi_SSE2, "movntpd");
1001 EncodeOpF2(0x2b, 1, IMM_NONE, NACLi_SSE4A, "movntsd");
1003 EncodeOp0F(0x2c, 1, IMM_NONE, NACLi_SSE, "cvttps2pi");
1004 EncodeOpF3(0x2c, 1, IMM_NONE, NACLi_SSE, "cvttss2si");
1005 EncodeOp66(0x2c, 1, IMM_NONE, NACLi_SSE2, "cvttpd2pi");
1006 EncodeOpF2(0x2c, 1, IMM_NONE, NACLi_SSE2, "cvttsd2si");
1008 EncodeOp0F(0x2d, 1, IMM_NONE, NACLi_SSE, "cvtps2pi");
1009 EncodeOpF3(0x2d, 1, IMM_NONE, NACLi_SSE, "cvtss2si");
1010 EncodeOp66(0x2d, 1, IMM_NONE, NACLi_SSE2, "cvtpd2pi");
1011 EncodeOpF2(0x2d, 1, IMM_NONE, NACLi_SSE2, "cvtsd2si");
1013 EncodeOp0F(0x2e, 1, IMM_NONE, NACLi_SSE, "ucomiss");
1014 EncodeOpF3(0x2e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1015 EncodeOp66(0x2e, 1, IMM_NONE, NACLi_SSE2, "ucomisd");
1016 EncodeOpF2(0x2e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1018 EncodeOp0F(0x2f, 1, IMM_NONE, NACLi_SSE, "comiss");
1019 EncodeOpF3(0x2f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1020 EncodeOp66(0x2f, 1, IMM_NONE, NACLi_SSE2, "comisd");
1021 EncodeOpF2(0x2f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1023 /* Instructions from ?? 0F 38 to ?? 0F 3F are invalid */
1025 /* Instructions from ?? 0F 50 to ?? 0F 7F */
1026 EncodeOp0F(0x50, 1, IMM_NONE, NACLi_SSE, "movmskps");
1027 EncodeOpF3(0x50, 0, IMM_NONE, NACLi_INVALID, "invalid");
1028 EncodeOp66(0x50, 1, IMM_NONE, NACLi_SSE2, "movmskpd");
1029 EncodeOpF2(0x50, 0, IMM_NONE, NACLi_INVALID, "invalid");
1031 EncodeOp0F(0x51, 1, IMM_NONE, NACLi_SSE, "sqrtps");
1032 EncodeOpF3(0x51, 1, IMM_NONE, NACLi_SSE, "sqrtss");
1033 EncodeOp66(0x51, 1, IMM_NONE, NACLi_SSE2, "sqrtpd");
1034 EncodeOpF2(0x51, 1, IMM_NONE, NACLi_SSE2, "sqrtsd");
1036 EncodeOp0F(0x52, 1, IMM_NONE, NACLi_SSE, "rsqrtps");
1037 EncodeOpF3(0x52, 1, IMM_NONE, NACLi_SSE, "rsqrtss");
1038 EncodeOp66(0x52, 0, IMM_NONE, NACLi_INVALID, "invalid");
1039 EncodeOpF2(0x52, 0, IMM_NONE, NACLi_INVALID, "invalid");
1041 EncodeOp0F(0x53, 1, IMM_NONE, NACLi_SSE, "rcpps");
1042 EncodeOpF3(0x53, 1, IMM_NONE, NACLi_SSE, "rcpss");
1043 EncodeOp66(0x53, 0, IMM_NONE, NACLi_INVALID, "invalid");
1044 EncodeOpF2(0x53, 0, IMM_NONE, NACLi_INVALID, "invalid");
1046 EncodeOp0F(0x54, 1, IMM_NONE, NACLi_SSE, "andps");
1047 EncodeOpF3(0x54, 0, IMM_NONE, NACLi_INVALID, "invalid");
1048 EncodeOp66(0x54, 1, IMM_NONE, NACLi_SSE2, "andpd");
1049 EncodeOpF2(0x54, 0, IMM_NONE, NACLi_INVALID, "invalid");
1051 EncodeOp0F(0x55, 1, IMM_NONE, NACLi_SSE, "andnps");
1052 EncodeOpF3(0x55, 0, IMM_NONE, NACLi_INVALID, "invalid");
1053 EncodeOp66(0x55, 1, IMM_NONE, NACLi_SSE2, "andnpd");
1054 EncodeOpF2(0x55, 0, IMM_NONE, NACLi_INVALID, "invalid");
1056 EncodeOp0F(0x56, 1, IMM_NONE, NACLi_SSE, "orps");
1057 EncodeOpF3(0x56, 1, IMM_NONE, NACLi_INVALID, "invalid");
1058 EncodeOp66(0x56, 1, IMM_NONE, NACLi_SSE2, "orpd");
1059 EncodeOpF2(0x56, 0, IMM_NONE, NACLi_INVALID, "invalid");
1061 EncodeOp0F(0x57, 1, IMM_NONE, NACLi_SSE, "xorps");
1062 EncodeOpF3(0x57, 0, IMM_NONE, NACLi_INVALID, "invalid");
1063 EncodeOp66(0x57, 1, IMM_NONE, NACLi_SSE2, "xorpd");
1064 EncodeOpF2(0x57, 0, IMM_NONE, NACLi_INVALID, "invalid");
1066 EncodeOp0F(0x58, 1, IMM_NONE, NACLi_SSE, "addps");
1067 EncodeOpF3(0x58, 1, IMM_NONE, NACLi_SSE, "addss");
1068 EncodeOp66(0x58, 1, IMM_NONE, NACLi_SSE2, "addpd");
1069 EncodeOpF2(0x58, 1, IMM_NONE, NACLi_SSE2, "addsd");
1071 EncodeOp0F(0x59, 1, IMM_NONE, NACLi_SSE, "mulps");
1072 EncodeOpF3(0x59, 1, IMM_NONE, NACLi_SSE, "mulss");
1073 EncodeOp66(0x59, 1, IMM_NONE, NACLi_SSE2, "mulpd");
1074 EncodeOpF2(0x59, 1, IMM_NONE, NACLi_SSE2, "mulsd");
1076 EncodeOp0F(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtps2pd");
1077 EncodeOpF3(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtss2sd");
1078 EncodeOp66(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtpd2ps");
1079 EncodeOpF2(0x5a, 1, IMM_NONE, NACLi_SSE2, "cvtsd2ss");
1081 EncodeOp0F(0x5b, 1, IMM_NONE, NACLi_SSE2, "cvtdq2ps");
1082 EncodeOpF3(0x5b, 1, IMM_NONE, NACLi_SSE2, "cvttps2dq");
1083 EncodeOp66(0x5b, 1, IMM_NONE, NACLi_SSE2, "cvtps2dq");
1084 EncodeOpF2(0x5b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1086 EncodeOp0F(0x5c, 1, IMM_NONE, NACLi_SSE, "subps");
1087 EncodeOpF3(0x5c, 1, IMM_NONE, NACLi_SSE, "subss");
1088 EncodeOp66(0x5c, 1, IMM_NONE, NACLi_SSE2, "subpd");
1089 EncodeOpF2(0x5c, 1, IMM_NONE, NACLi_SSE2, "subsd");
1091 EncodeOp0F(0x5d, 1, IMM_NONE, NACLi_SSE, "minps");
1092 EncodeOpF3(0x5d, 1, IMM_NONE, NACLi_SSE, "minss");
1093 EncodeOp66(0x5d, 1, IMM_NONE, NACLi_SSE2, "minpd");
1094 EncodeOpF2(0x5d, 1, IMM_NONE, NACLi_SSE2, "minsd");
1096 EncodeOp0F(0x5e, 1, IMM_NONE, NACLi_SSE, "divps");
1097 EncodeOpF3(0x5e, 1, IMM_NONE, NACLi_SSE, "divss");
1098 EncodeOp66(0x5e, 1, IMM_NONE, NACLi_SSE2, "divpd");
1099 EncodeOpF2(0x5e, 1, IMM_NONE, NACLi_SSE2, "divsd");
1101 EncodeOp0F(0x5f, 1, IMM_NONE, NACLi_SSE, "maxps");
1102 EncodeOpF3(0x5f, 1, IMM_NONE, NACLi_SSE, "maxss");
1103 EncodeOp66(0x5f, 1, IMM_NONE, NACLi_SSE2, "maxpd");
1104 EncodeOpF2(0x5f, 1, IMM_NONE, NACLi_SSE2, "maxsd");
1106 EncodeOp0F(0x60, 1, IMM_NONE, NACLi_MMX, "punpcklbw");
1107 EncodeOpF3(0x60, 0, IMM_NONE, NACLi_INVALID, "invalid");
1108 EncodeOp66(0x60, 1, IMM_NONE, NACLi_SSE2, "punpcklbw");
1109 EncodeOpF2(0x60, 0, IMM_NONE, NACLi_INVALID, "invalid");
1111 EncodeOp0F(0x61, 1, IMM_NONE, NACLi_MMX, "punpcklwd");
1112 EncodeOpF3(0x61, 0, IMM_NONE, NACLi_INVALID, "invalid");
1113 EncodeOp66(0x61, 1, IMM_NONE, NACLi_SSE2, "punpcklwd");
1114 EncodeOpF2(0x61, 0, IMM_NONE, NACLi_INVALID, "invalid");
1116 EncodeOp0F(0x62, 1, IMM_NONE, NACLi_MMX, "punpckldq");
1117 EncodeOpF3(0x62, 0, IMM_NONE, NACLi_INVALID, "invalid");
1118 EncodeOp66(0x62, 1, IMM_NONE, NACLi_SSE2, "punpckldq");
1119 EncodeOpF2(0x62, 0, IMM_NONE, NACLi_INVALID, "invalid");
1121 EncodeOp0F(0x63, 1, IMM_NONE, NACLi_MMX, "packsswb");
1122 EncodeOpF3(0x63, 0, IMM_NONE, NACLi_INVALID, "invalid");
1123 EncodeOp66(0x63, 1, IMM_NONE, NACLi_SSE2, "packsswb");
1124 EncodeOpF2(0x63, 0, IMM_NONE, NACLi_INVALID, "invalid");
1126 EncodeOp0F(0x64, 1, IMM_NONE, NACLi_MMX, "pcmpgtb");
1127 EncodeOpF3(0x64, 0, IMM_NONE, NACLi_INVALID, "invalid");
1128 EncodeOp66(0x64, 1, IMM_NONE, NACLi_SSE2, "pcmpgtb");
1129 EncodeOpF2(0x64, 0, IMM_NONE, NACLi_INVALID, "invalid");
1131 EncodeOp0F(0x65, 1, IMM_NONE, NACLi_MMX, "pcmpgtw");
1132 EncodeOpF3(0x65, 0, IMM_NONE, NACLi_INVALID, "invalid");
1133 EncodeOp66(0x65, 1, IMM_NONE, NACLi_SSE2, "pcmpgtw");
1134 EncodeOpF2(0x65, 0, IMM_NONE, NACLi_INVALID, "invalid");
1136 EncodeOp0F(0x66, 1, IMM_NONE, NACLi_MMX, "pcmpgtd");
1137 EncodeOpF3(0x66, 0, IMM_NONE, NACLi_INVALID, "invalid");
1138 EncodeOp66(0x66, 1, IMM_NONE, NACLi_SSE2, "pcmpgtd");
1139 EncodeOpF2(0x66, 0, IMM_NONE, NACLi_INVALID, "invalid");
1141 EncodeOp0F(0x67, 1, IMM_NONE, NACLi_MMX, "packuswb");
1142 EncodeOpF3(0x67, 0, IMM_NONE, NACLi_INVALID, "invalid");
1143 EncodeOp66(0x67, 1, IMM_NONE, NACLi_SSE2, "packuswb");
1144 EncodeOpF2(0x67, 0, IMM_NONE, NACLi_INVALID, "invalid");
1146 EncodeOp0F(0x68, 1, IMM_NONE, NACLi_MMX, "punpckhbw");
1147 EncodeOpF3(0x68, 0, IMM_NONE, NACLi_INVALID, "invalid");
1148 EncodeOp66(0x68, 1, IMM_NONE, NACLi_SSE2, "punpckhbw");
1149 EncodeOpF2(0x68, 0, IMM_NONE, NACLi_INVALID, "invalid");
1151 EncodeOp0F(0x69, 1, IMM_NONE, NACLi_MMX, "punpckhwd");
1152 EncodeOpF3(0x69, 0, IMM_NONE, NACLi_INVALID, "invalid");
1153 EncodeOp66(0x69, 1, IMM_NONE, NACLi_SSE2, "punpckhwd");
1154 EncodeOpF2(0x69, 0, IMM_NONE, NACLi_INVALID, "invalid");
1156 EncodeOp0F(0x6a, 1, IMM_NONE, NACLi_MMX, "punpckhdq");
1157 EncodeOpF3(0x6a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1158 EncodeOp66(0x6a, 1, IMM_NONE, NACLi_SSE2, "punpckhdq");
1159 EncodeOpF2(0x6a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1161 EncodeOp0F(0x6b, 1, IMM_NONE, NACLi_MMX, "packssdw");
1162 EncodeOpF3(0x6b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1163 EncodeOp66(0x6b, 1, IMM_NONE, NACLi_SSE2, "packssdw");
1164 EncodeOpF2(0x6b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1166 EncodeOp0F(0x6c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1167 EncodeOpF3(0x6c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1168 EncodeOp66(0x6c, 1, IMM_NONE, NACLi_SSE2, "punpcklqdq");
1169 EncodeOpF2(0x6c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1171 EncodeOp0F(0x6d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1172 EncodeOpF3(0x6d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1173 EncodeOp66(0x6d, 1, IMM_NONE, NACLi_SSE2, "punpckhqdq");
1174 EncodeOpF2(0x6d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1176 EncodeOp0F(0x6e, 1, IMM_NONE, NACLi_MMX, "movd");
1177 EncodeOpF3(0x6e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1178 EncodeOp66(0x6e, 1, IMM_NONE, NACLi_SSE2, "movd");
1179 EncodeOpF2(0x6e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1181 EncodeOp0F(0x6f, 1, IMM_NONE, NACLi_MMX, "movq");
1182 EncodeOpF3(0x6f, 1, IMM_NONE, NACLi_SSE2, "movdqu");
1183 EncodeOp66(0x6f, 1, IMM_NONE, NACLi_SSE2, "movdqa");
1184 EncodeOpF2(0x6f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1186 EncodeOp0F(0x70, 1, IMM_FIXED1, NACLi_SSE, "pshufw");
1187 EncodeOpF3(0x70, 1, IMM_FIXED1, NACLi_SSE2, "pshufhw");
1188 EncodeOp66(0x70, 1, IMM_FIXED1, NACLi_SSE2, "pshufd");
1189 EncodeOpF2(0x70, 1, IMM_FIXED1, NACLi_SSE2, "pshuflw");
1191 EncodeOp0F(0x71, 1, IMM_FIXED1, NACLi_OPINMRM, "$group12");
1192 EncodeOpF3(0x71, 0, IMM_NONE, NACLi_INVALID, "invalid");
1193 EncodeOp66(0x71, 1, IMM_FIXED1, NACLi_OPINMRM, "$group12");
1194 EncodeOpF2(0x71, 0, IMM_NONE, NACLi_INVALID, "invalid");
1195 SetOp0FOpInMRM(0x71, GROUP12);
1196 SetOp66OpInMRM(0x71, GROUP12);
1198 EncodeOp0F(0x72, 1, IMM_FIXED1, NACLi_OPINMRM, "$group13");
1199 EncodeOpF3(0x72, 0, IMM_NONE, NACLi_INVALID, "invalid");
1200 EncodeOp66(0x72, 1, IMM_FIXED1, NACLi_OPINMRM, "$group13");
1201 EncodeOpF2(0x72, 0, IMM_NONE, NACLi_INVALID, "invalid");
1202 SetOp0FOpInMRM(0x72, GROUP13);
1203 SetOp66OpInMRM(0x72, GROUP13);
1205 EncodeOp0F(0x73, 1, IMM_FIXED1, NACLi_OPINMRM, "$group14");
1206 EncodeOpF3(0x73, 0, IMM_NONE, NACLi_INVALID, "invalid");
1207 EncodeOp66(0x73, 1, IMM_FIXED1, NACLi_OPINMRM, "$group14");
1208 EncodeOpF2(0x73, 0, IMM_NONE, NACLi_INVALID, "invalid");
1209 SetOp0FOpInMRM(0x73, GROUP14);
1210 SetOp66OpInMRM(0x73, GROUP14);
1212 EncodeOp0F(0x74, 1, IMM_NONE, NACLi_MMX, "pcmpeqb");
1213 EncodeOpF3(0x74, 0, IMM_NONE, NACLi_INVALID, "invalid");
1214 EncodeOp66(0x74, 1, IMM_NONE, NACLi_SSE2, "pcmpeqb");
1215 EncodeOpF2(0x74, 0, IMM_NONE, NACLi_INVALID, "invalid");
1217 EncodeOp0F(0x75, 1, IMM_NONE, NACLi_MMX, "pcmpeqw");
1218 EncodeOpF3(0x75, 0, IMM_NONE, NACLi_INVALID, "invalid");
1219 EncodeOp66(0x75, 1, IMM_NONE, NACLi_SSE2, "pcmpeqw");
1220 EncodeOpF2(0x75, 0, IMM_NONE, NACLi_INVALID, "invalid");
1222 EncodeOp0F(0x76, 1, IMM_NONE, NACLi_MMX, "pcmpeqd");
1223 EncodeOpF3(0x76, 1, IMM_NONE, NACLi_INVALID, "invalid");
1224 EncodeOp66(0x76, 1, IMM_NONE, NACLi_SSE2, "pcmpeqd");
1225 EncodeOpF2(0x76, 0, IMM_NONE, NACLi_INVALID, "invalid");
1227 EncodeOp0F(0x77, 0, IMM_NONE, NACLi_MMX, "emms");
1228 EncodeOpF3(0x77, 0, IMM_NONE, NACLi_INVALID, "invalid");
1229 EncodeOp66(0x77, 0, IMM_NONE, NACLi_INVALID, "invalid");
1230 EncodeOpF2(0x77, 0, IMM_NONE, NACLi_INVALID, "invalid");
1232 EncodeOp0F(0x78, 0, IMM_NONE, NACLi_INVALID, "invalid");
1233 EncodeOpF3(0x78, 0, IMM_NONE, NACLi_INVALID, "invalid");
1234 EncodeOp66(0x78, 1, IMM_FIXED1, NACLi_OPINMRM, "$group17");
1235 SetOp66OpInMRM(0x78, GROUP17);
1236 EncodeOpF2(0x78, 1, IMM_FIXED2, NACLi_SSE4A, "insertq");
1238 EncodeOp0F(0x79, 0, IMM_NONE, NACLi_INVALID, "invalid");
1239 EncodeOpF3(0x79, 0, IMM_NONE, NACLi_INVALID, "invalid");
1240 EncodeOp66(0x79, 1, IMM_NONE, NACLi_SSE4A, "extrq");
1241 EncodeOpF2(0x79, 1, IMM_NONE, NACLi_SSE4A, "insertq");
1243 EncodeOp0F(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1244 EncodeOpF3(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1245 EncodeOp66(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1246 EncodeOpF2(0x7a, 0, IMM_NONE, NACLi_INVALID, "invalid");
1248 EncodeOp0F(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1249 EncodeOpF3(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1250 EncodeOp66(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1251 EncodeOpF2(0x7b, 0, IMM_NONE, NACLi_INVALID, "invalid");
1253 EncodeOp0F(0x7c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1254 EncodeOpF3(0x7c, 0, IMM_NONE, NACLi_INVALID, "invalid");
1255 EncodeOp66(0x7c, 1, IMM_NONE, NACLi_SSE3, "haddpd");
1256 EncodeOpF2(0x7c, 1, IMM_NONE, NACLi_SSE3, "haddps");
1258 EncodeOp0F(0x7d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1259 EncodeOpF3(0x7d, 0, IMM_NONE, NACLi_INVALID, "invalid");
1260 EncodeOp66(0x7d, 1, IMM_NONE, NACLi_SSE3, "hsubpd");
1261 EncodeOpF2(0x7d, 1, IMM_NONE, NACLi_SSE3, "hsubps");
1263 EncodeOp0F(0x7e, 1, IMM_NONE, NACLi_MMX, "movd");
1264 EncodeOpF3(0x7e, 1, IMM_NONE, NACLi_SSE2, "movq");
1265 EncodeOp66(0x7e, 1, IMM_NONE, NACLi_SSE2, "movd");
1266 EncodeOpF2(0x7e, 0, IMM_NONE, NACLi_INVALID, "invalid");
1268 EncodeOp0F(0x7f, 1, IMM_NONE, NACLi_MMX, "movq");
1269 EncodeOpF3(0x7f, 1, IMM_NONE, NACLi_SSE2, "movdqu");
1270 EncodeOp66(0x7f, 1, IMM_NONE, NACLi_SSE2, "movdqa");
1271 EncodeOpF2(0x7f, 0, IMM_NONE, NACLi_INVALID, "invalid");
1273 /* Instructions from ?? 0F b8 to ?? 0F bf */
1274 EncodeOp0F(0xb8, 0, IMM_NONE, NACLi_INVALID, "reserved");
1275 EncodeOpF3(0xb8, 1, IMM_NONE, NACLi_POPCNT, "popcnt");
1276 EncodeOp66(0xb8, 0, IMM_NONE, NACLi_INVALID, "reserved");
1277 EncodeOpF2(0xb8, 0, IMM_NONE, NACLi_INVALID, "reserved");
1279 EncodeOp0F(0xb9, 1, IMM_NONE, NACLi_OPINMRM, "$group10");
1280 EncodeOpF3(0xb9, 0, IMM_NONE, NACLi_INVALID, "reserved");
1281 EncodeOp66(0xb9, 1, IMM_NONE, NACLi_OPINMRM, "$group10");
1282 EncodeOpF2(0xb9, 0, IMM_NONE, NACLi_INVALID, "reserved");
1284 EncodeOp0F(0xba, 1, IMM_FIXED1, NACLi_OPINMRM, "$group8");
1285 EncodeOpF3(0xba, 0, IMM_FIXED1, NACLi_INVALID, "reserved");
1286 EncodeOp66(0xba, 1, IMM_FIXED1, NACLi_OPINMRM, "$group8");
1287 EncodeOpF2(0xba, 0, IMM_NONE, NACLi_INVALID, "reserved");
1288 SetOp0FOpInMRM(0xba, GROUP8);
1289 SetOp66OpInMRM(0xba, GROUP8);
1291 EncodeOp0F(0xbb, 1, IMM_NONE, NACLi_ILLEGAL, "btc");
1292 EncodeOpF3(0xbb, 0, IMM_NONE, NACLi_INVALID, "reserved");
1293 EncodeOp66(0xbb, 1, IMM_NONE, NACLi_ILLEGAL, "btc");
1294 EncodeOpF2(0xbb, 0, IMM_NONE, NACLi_INVALID, "reserved");
1296 EncodeOp0F(0xbc, 1, IMM_NONE, NACLi_386, "bsf");
1297 EncodeOpF3(0xbc, 0, IMM_NONE, NACLi_INVALID, "reserved");
1298 EncodeOp66(0xbc, 1, IMM_NONE, NACLi_386, "bsf");
1299 EncodeOpF2(0xbc, 0, IMM_NONE, NACLi_INVALID, "reserved");
1301 EncodeOp0F(0xbd, 1, IMM_NONE, NACLi_386, "bsr");
1302 /* lzcnt is treated as a bsr on machines that don't have lzcnt */
1303 EncodeOpF3(0xbd, 1, IMM_NONE, NACLi_LZCNT, "lzcnt");
1304 EncodeOp66(0xbd, 1, IMM_NONE, NACLi_386, "bsr");
1305 EncodeOpF2(0xbd, 0, IMM_NONE, NACLi_INVALID, "reserved");
1307 EncodeOp0F(0xbe, 1, IMM_NONE, NACLi_386, "movsx");
1308 EncodeOpF3(0xbe, 1, IMM_NONE, NACLi_INVALID, "reserved");
1309 EncodeOp66(0xbe, 1, IMM_NONE, NACLi_386, "movsx");
1310 EncodeOpF2(0xbe, 1, IMM_NONE, NACLi_INVALID, "reserved");
1312 EncodeOp0F(0xbf, 1, IMM_NONE, NACLi_386, "movsx");
1313 EncodeOpF3(0xbf, 0, IMM_NONE, NACLi_INVALID, "reserved");
1314 EncodeOp66(0xbf, 1, IMM_NONE, NACLi_386, "movsx");
1315 EncodeOpF2(0xbf, 0, IMM_NONE, NACLi_INVALID, "reserved");
1317 /* Instructions from ?? 0F C0 to ?? 0F FF */
1318 /* xadd and cmpxchg appear to be the only instructions designed */
1319 /* for use with multiple prefix bytes. We may need to create */
1320 /* a special case for this if somebody actually needs it. */
1321 EncodeOp0F(0xc0, 1, IMM_NONE, NACLi_386L, "xadd $E, $G");
1322 EncodeOp0F(0xc1, 1, IMM_NONE, NACLi_386L, "xadd $E, $G");
1324 EncodeOp0F(0xc2, 1, IMM_FIXED1, NACLi_SSE, "cmpps $V,$W,$I");
1325 EncodeOpF3(0xc2, 1, IMM_FIXED1, NACLi_SSE, "cmpss $V,$W,$I");
1326 EncodeOp66(0xc2, 1, IMM_FIXED1, NACLi_SSE2, "cmppd $V,$W,$I");
1327 EncodeOpF2(0xc2, 1, IMM_FIXED1, NACLi_SSE2, "cmpsd $V,$W,$I");
1329 EncodeOp0F(0xc3, 1, IMM_NONE, NACLi_SSE2, "movnti");
1330 EncodeOpF3(0xc3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1331 EncodeOp66(0xc3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1332 EncodeOpF2(0xc3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1334 EncodeOp0F(0xc4, 1, IMM_FIXED1, NACLi_SSE, "pinsrw");
1335 EncodeOpF3(0xc4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1336 EncodeOp66(0xc4, 1, IMM_FIXED1, NACLi_SSE2, "pinsrw");
1337 EncodeOpF2(0xc4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1339 EncodeOp0F(0xc5, 1, IMM_FIXED1, NACLi_SSE, "pextrw");
1340 EncodeOpF3(0xc5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1341 EncodeOp66(0xc5, 1, IMM_FIXED1, NACLi_SSE2, "pextrw");
1342 EncodeOpF2(0xc5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1344 EncodeOp0F(0xc6, 1, IMM_FIXED1, NACLi_SSE, "shufps");
1345 EncodeOpF3(0xc6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1346 EncodeOp66(0xc6, 1, IMM_FIXED1, NACLi_SSE2, "shufpd");
1347 EncodeOpF2(0xc6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1349 EncodeOp0F(0xc7, 1, IMM_NONE, NACLi_OPINMRM, "$group9");
1350 SetOp0FOpInMRM(0xc7, GROUP9);
1352 EncodeOp0F(0xd0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1353 EncodeOpF3(0xd0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1354 EncodeOp66(0xd0, 1, IMM_NONE, NACLi_SSE3, "addsubpd");
1355 EncodeOpF2(0xd0, 1, IMM_NONE, NACLi_SSE3, "addsubps");
1357 EncodeOp0F(0xd1, 1, IMM_NONE, NACLi_MMX, "psrlw");
1358 EncodeOpF3(0xd1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1359 EncodeOp66(0xd1, 1, IMM_NONE, NACLi_SSE2, "psrlw");
1360 EncodeOpF2(0xd1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1362 EncodeOp0F(0xd2, 1, IMM_NONE, NACLi_MMX, "psrld");
1363 EncodeOpF3(0xd2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1364 EncodeOp66(0xd2, 1, IMM_NONE, NACLi_SSE2, "psrld");
1365 EncodeOpF2(0xd2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1367 EncodeOp0F(0xd3, 1, IMM_NONE, NACLi_MMX, "psrlq");
1368 EncodeOpF3(0xd3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1369 EncodeOp66(0xd3, 1, IMM_NONE, NACLi_SSE2, "psrlq");
1370 EncodeOpF2(0xd3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1372 EncodeOp0F(0xd4, 1, IMM_NONE, NACLi_SSE2, "paddq");
1373 EncodeOpF3(0xd4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1374 EncodeOp66(0xd4, 1, IMM_NONE, NACLi_SSE2, "paddq");
1375 EncodeOpF2(0xd4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1377 EncodeOp0F(0xd5, 1, IMM_NONE, NACLi_MMX, "pmullw");
1378 EncodeOpF3(0xd5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1379 EncodeOp66(0xd5, 1, IMM_NONE, NACLi_SSE2, "pmullw");
1380 EncodeOpF2(0xd5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1382 EncodeOp0F(0xd6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1383 EncodeOpF3(0xd6, 1, IMM_NONE, NACLi_SSE2, "movq2dq");
1384 EncodeOp66(0xd6, 1, IMM_NONE, NACLi_SSE2, "movq");
1385 EncodeOpF2(0xd6, 1, IMM_NONE, NACLi_SSE2, "movdq2q");
1387 EncodeOp0F(0xd7, 1, IMM_NONE, NACLi_SSE, "pmovmskb");
1388 EncodeOpF3(0xd7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1389 EncodeOp66(0xd7, 1, IMM_NONE, NACLi_SSE2, "pmovmskb");
1390 EncodeOpF2(0xd7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1392 EncodeOp0F(0xd8, 1, IMM_NONE, NACLi_MMX, "psubusb");
1393 EncodeOpF3(0xd8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1394 EncodeOp66(0xd8, 1, IMM_NONE, NACLi_SSE2, "psubusb");
1395 EncodeOpF2(0xd8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1397 EncodeOp0F(0xd9, 1, IMM_NONE, NACLi_MMX, "psubusw");
1398 EncodeOpF3(0xd9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1399 EncodeOp66(0xd9, 1, IMM_NONE, NACLi_SSE2, "psubusw");
1400 EncodeOpF2(0xd9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1402 EncodeOp0F(0xda, 1, IMM_NONE, NACLi_SSE, "pminub");
1403 EncodeOpF3(0xda, 0, IMM_NONE, NACLi_INVALID, "invalid");
1404 EncodeOp66(0xda, 1, IMM_NONE, NACLi_SSE2, "pminub");
1405 EncodeOpF2(0xda, 0, IMM_NONE, NACLi_INVALID, "invalid");
1407 EncodeOp0F(0xdb, 1, IMM_NONE, NACLi_MMX, "pand");
1408 EncodeOpF3(0xdb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1409 EncodeOp66(0xdb, 1, IMM_NONE, NACLi_SSE2, "pand");
1410 EncodeOpF2(0xdb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1412 EncodeOp0F(0xdc, 1, IMM_NONE, NACLi_MMX, "paddusb");
1413 EncodeOpF3(0xdc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1414 EncodeOp66(0xdc, 1, IMM_NONE, NACLi_SSE2, "paddusb");
1415 EncodeOpF2(0xdc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1417 EncodeOp0F(0xdd, 1, IMM_NONE, NACLi_MMX, "paddusw");
1418 EncodeOpF3(0xdd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1419 EncodeOp66(0xdd, 1, IMM_NONE, NACLi_SSE2, "paddusw");
1420 EncodeOpF2(0xdd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1422 EncodeOp0F(0xde, 1, IMM_NONE, NACLi_SSE, "pmaxub");
1423 EncodeOpF3(0xde, 0, IMM_NONE, NACLi_INVALID, "invalid");
1424 EncodeOp66(0xde, 1, IMM_NONE, NACLi_SSE2, "pmaxub");
1425 EncodeOpF2(0xde, 0, IMM_NONE, NACLi_INVALID, "invalid");
1427 EncodeOp0F(0xdf, 1, IMM_NONE, NACLi_MMX, "pandn");
1428 EncodeOpF3(0xdf, 0, IMM_NONE, NACLi_INVALID, "invalid");
1429 EncodeOp66(0xdf, 1, IMM_NONE, NACLi_SSE2, "pandn");
1430 EncodeOpF2(0xdf, 0, IMM_NONE, NACLi_INVALID, "invalid");
1432 EncodeOp0F(0xe0, 1, IMM_NONE, NACLi_SSE, "pavgb");
1433 EncodeOpF3(0xe0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1434 EncodeOp66(0xe0, 1, IMM_NONE, NACLi_SSE2, "pavgb");
1435 EncodeOpF2(0xe0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1437 EncodeOp0F(0xe1, 1, IMM_NONE, NACLi_MMX, "psraw");
1438 EncodeOpF3(0xe1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1439 EncodeOp66(0xe1, 1, IMM_NONE, NACLi_SSE2, "psraw");
1440 EncodeOpF2(0xe1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1442 EncodeOp0F(0xe2, 1, IMM_NONE, NACLi_MMX, "psrad");
1443 EncodeOpF3(0xe2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1444 EncodeOp66(0xe2, 1, IMM_NONE, NACLi_SSE2, "psrad");
1445 EncodeOpF2(0xe2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1447 EncodeOp0F(0xe3, 1, IMM_NONE, NACLi_SSE, "pavgw");
1448 EncodeOpF3(0xe3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1449 EncodeOp66(0xe3, 1, IMM_NONE, NACLi_SSE2, "pavgw");
1450 EncodeOpF2(0xe3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1452 EncodeOp0F(0xe4, 1, IMM_NONE, NACLi_SSE, "pmulhuw");
1453 EncodeOpF3(0xe4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1454 EncodeOp66(0xe4, 1, IMM_NONE, NACLi_SSE2, "pmulhuw");
1455 EncodeOpF2(0xe4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1457 EncodeOp0F(0xe5, 1, IMM_NONE, NACLi_MMX, "pmulhw");
1458 EncodeOpF3(0xe5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1459 EncodeOp66(0xe5, 1, IMM_NONE, NACLi_SSE2, "pmulhw");
1460 EncodeOpF2(0xe5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1462 EncodeOp0F(0xe6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1463 EncodeOpF3(0xe6, 1, IMM_NONE, NACLi_SSE2, "cvtdq2pd");
1464 EncodeOp66(0xe6, 1, IMM_NONE, NACLi_SSE2, "cvttpd2dq");
1465 EncodeOpF2(0xe6, 1, IMM_NONE, NACLi_SSE2, "cvtpd2dq");
1467 EncodeOp0F(0xe7, 1, IMM_NONE, NACLi_SSE, "movntq");
1468 EncodeOpF3(0xe7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1469 EncodeOp66(0xe7, 1, IMM_NONE, NACLi_SSE2, "movntdq");
1470 EncodeOpF2(0xe7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1472 EncodeOp0F(0xe8, 1, IMM_NONE, NACLi_MMX, "psubsb");
1473 EncodeOpF3(0xe8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1474 EncodeOp66(0xe8, 1, IMM_NONE, NACLi_SSE2, "psubsb");
1475 EncodeOpF2(0xe8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1477 EncodeOp0F(0xe9, 1, IMM_NONE, NACLi_MMX, "psubsw");
1478 EncodeOpF3(0xe9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1479 EncodeOp66(0xe9, 1, IMM_NONE, NACLi_SSE2, "psubsw");
1480 EncodeOpF2(0xe9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1482 EncodeOp0F(0xea, 1, IMM_NONE, NACLi_SSE, "pminsw");
1483 EncodeOpF3(0xea, 0, IMM_NONE, NACLi_INVALID, "invalid");
1484 EncodeOp66(0xea, 1, IMM_NONE, NACLi_SSE2, "pminsw");
1485 EncodeOpF2(0xea, 0, IMM_NONE, NACLi_INVALID, "invalid");
1487 EncodeOp0F(0xeb, 1, IMM_NONE, NACLi_MMX, "por");
1488 EncodeOpF3(0xeb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1489 EncodeOp66(0xeb, 1, IMM_NONE, NACLi_SSE2, "por");
1490 EncodeOpF2(0xeb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1492 EncodeOp0F(0xec, 1, IMM_NONE, NACLi_MMX, "paddsb");
1493 EncodeOpF3(0xec, 0, IMM_NONE, NACLi_INVALID, "invalid");
1494 EncodeOp66(0xec, 1, IMM_NONE, NACLi_SSE2, "paddsb");
1495 EncodeOpF2(0xec, 0, IMM_NONE, NACLi_INVALID, "invalid");
1497 EncodeOp0F(0xed, 1, IMM_NONE, NACLi_MMX, "paddsw");
1498 EncodeOpF3(0xed, 0, IMM_NONE, NACLi_INVALID, "invalid");
1499 EncodeOp66(0xed, 1, IMM_NONE, NACLi_SSE2, "paddsw");
1500 EncodeOpF2(0xed, 0, IMM_NONE, NACLi_INVALID, "invalid");
1502 EncodeOp0F(0xee, 1, IMM_NONE, NACLi_SSE, "pmaxsw");
1503 EncodeOpF3(0xee, 0, IMM_NONE, NACLi_INVALID, "invalid");
1504 EncodeOp66(0xee, 1, IMM_NONE, NACLi_SSE2, "pmaxsw");
1505 EncodeOpF2(0xee, 0, IMM_NONE, NACLi_INVALID, "invalid");
1507 EncodeOp0F(0xef, 1, IMM_NONE, NACLi_MMX, "pxor");
1508 EncodeOpF3(0xef, 0, IMM_NONE, NACLi_INVALID, "invalid");
1509 EncodeOp66(0xef, 1, IMM_NONE, NACLi_SSE2, "pxor");
1510 EncodeOpF2(0xef, 0, IMM_NONE, NACLi_INVALID, "invalid");
1512 EncodeOp0F(0xf0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1513 EncodeOpF3(0xf0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1514 EncodeOp66(0xf0, 0, IMM_NONE, NACLi_INVALID, "invalid");
1515 EncodeOpF2(0xf0, 1, IMM_NONE, NACLi_SSE3, "lddqu");
1517 EncodeOp0F(0xf1, 1, IMM_NONE, NACLi_MMX, "psllw");
1518 EncodeOpF3(0xf1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1519 EncodeOp66(0xf1, 1, IMM_NONE, NACLi_SSE2, "psllw");
1520 EncodeOpF2(0xf1, 0, IMM_NONE, NACLi_INVALID, "invalid");
1522 EncodeOp0F(0xf2, 1, IMM_NONE, NACLi_MMX, "pslld");
1523 EncodeOpF3(0xf2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1524 EncodeOp66(0xf2, 1, IMM_NONE, NACLi_SSE2, "pslld");
1525 EncodeOpF2(0xf2, 0, IMM_NONE, NACLi_INVALID, "invalid");
1527 EncodeOp0F(0xf3, 1, IMM_NONE, NACLi_MMX, "psllq");
1528 EncodeOpF3(0xf3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1529 EncodeOp66(0xf3, 1, IMM_NONE, NACLi_SSE2, "psllq");
1530 EncodeOpF2(0xf3, 0, IMM_NONE, NACLi_INVALID, "invalid");
1532 EncodeOp0F(0xf4, 1, IMM_NONE, NACLi_SSE2, "pmuludq");
1533 EncodeOpF3(0xf4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1534 EncodeOp66(0xf4, 1, IMM_NONE, NACLi_SSE2, "pmuludq");
1535 EncodeOpF2(0xf4, 0, IMM_NONE, NACLi_INVALID, "invalid");
1537 EncodeOp0F(0xf5, 1, IMM_NONE, NACLi_MMX, "pmaddwd");
1538 EncodeOpF3(0xf5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1539 EncodeOp66(0xf5, 1, IMM_NONE, NACLi_SSE2, "pmaddwd");
1540 EncodeOpF2(0xf5, 0, IMM_NONE, NACLi_INVALID, "invalid");
1542 EncodeOp0F(0xf6, 1, IMM_NONE, NACLi_SSE, "psadbw");
1543 EncodeOpF3(0xf6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1544 EncodeOp66(0xf6, 1, IMM_NONE, NACLi_SSE2, "psadbw");
1545 EncodeOpF2(0xf6, 0, IMM_NONE, NACLi_INVALID, "invalid");
1547 EncodeOp0F(0xf7, 1, IMM_NONE, NACLi_SSE, "maskmovq");
1548 EncodeOpF3(0xf7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1549 EncodeOp66(0xf7, 1, IMM_NONE, NACLi_SSE2, "maskmovdqu");
1550 EncodeOpF2(0xf7, 0, IMM_NONE, NACLi_INVALID, "invalid");
1552 EncodeOp0F(0xf8, 1, IMM_NONE, NACLi_MMX, "psubb");
1553 EncodeOpF3(0xf8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1554 EncodeOp66(0xf8, 1, IMM_NONE, NACLi_SSE2, "psubb");
1555 EncodeOpF2(0xf8, 0, IMM_NONE, NACLi_INVALID, "invalid");
1557 EncodeOp0F(0xf9, 1, IMM_NONE, NACLi_MMX, "psubw");
1558 EncodeOpF3(0xf9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1559 EncodeOp66(0xf9, 1, IMM_NONE, NACLi_SSE2, "psubw");
1560 EncodeOpF2(0xf9, 0, IMM_NONE, NACLi_INVALID, "invalid");
1562 EncodeOp0F(0xfa, 1, IMM_NONE, NACLi_MMX, "psubd");
1563 EncodeOpF3(0xfa, 0, IMM_NONE, NACLi_INVALID, "invalid");
1564 EncodeOp66(0xfa, 1, IMM_NONE, NACLi_SSE2, "psubd");
1565 EncodeOpF2(0xfa, 0, IMM_NONE, NACLi_INVALID, "invalid");
1567 /* Here is an SSE2 instruction that doesn't require 0x66 */
1568 EncodeOp0F(0xfb, 1, IMM_NONE, NACLi_SSE2, "psubq");
1569 EncodeOpF3(0xfb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1570 EncodeOp66(0xfb, 1, IMM_NONE, NACLi_SSE2, "psubq");
1571 EncodeOpF2(0xfb, 0, IMM_NONE, NACLi_INVALID, "invalid");
1573 EncodeOp0F(0xfc, 1, IMM_NONE, NACLi_MMX, "paddb");
1574 EncodeOpF3(0xfc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1575 EncodeOp66(0xfc, 1, IMM_NONE, NACLi_SSE2, "paddb");
1576 EncodeOpF2(0xfc, 0, IMM_NONE, NACLi_INVALID, "invalid");
1578 EncodeOp0F(0xfd, 1, IMM_NONE, NACLi_MMX, "paddw");
1579 EncodeOpF3(0xfd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1580 EncodeOp66(0xfd, 1, IMM_NONE, NACLi_SSE2, "paddw");
1581 EncodeOpF2(0xfd, 0, IMM_NONE, NACLi_INVALID, "invalid");
1583 EncodeOp0F(0xfe, 1, IMM_NONE, NACLi_MMX, "paddd");
1584 EncodeOpF3(0xfe, 0, IMM_NONE, NACLi_INVALID, "invalid");
1585 EncodeOp66(0xfe, 1, IMM_NONE, NACLi_SSE2, "paddd");
1586 EncodeOpF2(0xfe, 0, IMM_NONE, NACLi_INVALID, "invalid");
1588 EncodeOp0F(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1589 EncodeOpF3(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1590 EncodeOp66(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1591 EncodeOpF2(0xff, 0, IMM_NONE, NACLi_INVALID, "invalid");
1593 /* three byte opcodes */
1594 /* 3DNow! */
1595 EncodeOp0F0F(0x90, 1, IMM_NONE, NACLi_3DNOW, "pfcmpge $P, $Q");
1596 EncodeOp0F0F(0x94, 1, IMM_NONE, NACLi_3DNOW, "pfmin $P, $Q");
1597 EncodeOp0F0F(0x96, 1, IMM_NONE, NACLi_3DNOW, "pfrcp $P, $Q");
1598 EncodeOp0F0F(0x97, 1, IMM_NONE, NACLi_3DNOW, "pfrsqrt $P, $Q");
1599 EncodeOp0F0F(0xa0, 1, IMM_NONE, NACLi_3DNOW, "pfcmpgt $P, $Q");
1600 EncodeOp0F0F(0xa4, 1, IMM_NONE, NACLi_3DNOW, "pfmax $P, $Q");
1601 EncodeOp0F0F(0xa6, 1, IMM_NONE, NACLi_3DNOW, "pfrcpit1 $P, $Q");
1602 EncodeOp0F0F(0xa7, 1, IMM_NONE, NACLi_3DNOW, "pfrsqit1 $P, $Q");
1603 EncodeOp0F0F(0xb0, 1, IMM_NONE, NACLi_3DNOW, "pfcmpeq $P, $Q");
1604 EncodeOp0F0F(0xb4, 1, IMM_NONE, NACLi_3DNOW, "pfmul $P, $Q");
1605 EncodeOp0F0F(0xb6, 1, IMM_NONE, NACLi_3DNOW, "pfrcpit2 $P, $Q");
1606 EncodeOp0F0F(0xb7, 1, IMM_NONE, NACLi_3DNOW, "pmulhrw $P, $Q");
1607 EncodeOp0F0F(0x0c, 1, IMM_NONE, NACLi_E3DNOW, "pi2fw $P, $Q");
1608 EncodeOp0F0F(0x0d, 1, IMM_NONE, NACLi_3DNOW, "pi2fd $P, $Q");
1609 EncodeOp0F0F(0x1c, 1, IMM_NONE, NACLi_E3DNOW, "pf2iw $P, $Q");
1610 EncodeOp0F0F(0x1d, 1, IMM_NONE, NACLi_3DNOW, "pf2id $P, $Q");
1611 EncodeOp0F0F(0x8a, 1, IMM_NONE, NACLi_E3DNOW, "pfnacc $P, $Q");
1612 EncodeOp0F0F(0x8e, 1, IMM_NONE, NACLi_E3DNOW, "pfpnacc $P, $Q");
1613 EncodeOp0F0F(0x9a, 1, IMM_NONE, NACLi_3DNOW, "pfsub $P, $Q");
1614 EncodeOp0F0F(0x9e, 1, IMM_NONE, NACLi_3DNOW, "pfadd $P, $Q");
1615 EncodeOp0F0F(0xaa, 1, IMM_NONE, NACLi_3DNOW, "pfsubr $P, $Q");
1616 EncodeOp0F0F(0xae, 1, IMM_NONE, NACLi_3DNOW, "pfacc $P, $Q");
1617 EncodeOp0F0F(0xbb, 1, IMM_NONE, NACLi_E3DNOW, "pswapd $P, $Q");
1618 EncodeOp0F0F(0xbf, 1, IMM_NONE, NACLi_3DNOW, "pavgusb $P, $Q");
1619 /* SSSE3 */
1620 EncodeOp0F38(0x00, 1, IMM_NONE, NACLi_SSSE3, "pshufb $P, $Q");
1621 EncodeOp0F38(0x01, 1, IMM_NONE, NACLi_SSSE3, "phaddw $P, $Q");
1622 EncodeOp0F38(0x02, 1, IMM_NONE, NACLi_SSSE3, "phaddd $P, $Q");
1623 EncodeOp0F38(0x03, 1, IMM_NONE, NACLi_SSSE3, "phaddsw $P, $Q");
1624 EncodeOp0F38(0x04, 1, IMM_NONE, NACLi_SSSE3, "pmaddubsw $P, $Q");
1625 EncodeOp0F38(0x05, 1, IMM_NONE, NACLi_SSSE3, "phsubw $P, $Q");
1626 EncodeOp0F38(0x06, 1, IMM_NONE, NACLi_SSSE3, "phsubd $P, $Q");
1627 EncodeOp0F38(0x07, 1, IMM_NONE, NACLi_SSSE3, "phsubsw $P, $Q");
1628 EncodeOp0F38(0x08, 1, IMM_NONE, NACLi_SSSE3, "psignb $P, $Q");
1629 EncodeOp0F38(0x09, 1, IMM_NONE, NACLi_SSSE3, "psignw $P, $Q");
1630 EncodeOp0F38(0x0a, 1, IMM_NONE, NACLi_SSSE3, "psignd $P, $Q");
1631 EncodeOp0F38(0x0b, 1, IMM_NONE, NACLi_SSSE3, "pabsb $P, $Q");
1632 EncodeOp0F38(0x1c, 1, IMM_NONE, NACLi_SSSE3, "pabsw $P, $Q");
1633 EncodeOp0F38(0x1d, 1, IMM_NONE, NACLi_SSSE3, "pabsd $P, $Q");
1634 EncodeOp0F38(0x1e, 1, IMM_NONE, NACLi_SSSE3, "pmulhrsw $P, $Q");
1635 EncodeOp0F3A(0x0f, 1, IMM_FIXED1, NACLi_SSSE3, "palignr $P, $Q, $Ib");
1637 Buildx87Tables();
1640 static void PrintHeader(FILE *f, const char *argv0, const char *fname) {
1641 time_t timeofday;
1643 if (time(&timeofday) < 0) {
1644 fprintf(stderr, "time() failed\n");
1645 exit(-1);
1647 fprintf(f, "/* %s\n", fname);
1648 fprintf(f, " * THIS FILE IS AUTO-GENERATED. DO NOT EDIT.\n");
1649 fprintf(f, " * This file was auto-generated by %s on %s",
1650 argv0, ctime(&timeofday));
1651 fprintf(f, "\n");
1652 fprintf(f, " * You must include ncdecode.h before this file.\n");
1653 fprintf(f, " */\n");
1656 static void PrintDecodeTable(FILE *f) {
1657 /* now print the table */
1658 int opc;
1659 int group, nnn;
1660 OpMetaInfo *opinfo = NULL;
1661 fprintf(f, "static const struct OpInfo kDecode1ByteOp[NCDTABLESIZE] = {\n");
1663 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1664 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1665 NaClInstTypeString(g_Op1ByteTable[opc]->insttype),
1666 g_Op1ByteTable[opc]->mrmbyte,
1667 g_Op1ByteTable[opc]->immtype,
1668 g_Op1ByteTable[opc]->opinmrm,
1669 g_Op1ByteTable[opc]->disfmt);
1671 fprintf(f, "};\n\n");
1673 fprintf(f, "static const struct OpInfo kDecodeModRMOp[kNaClMRMGroupsRange]");
1674 fprintf(f, "[kModRMOpcodeGroupSize] = {\n");
1675 for (group = 0; group < kNaClMRMGroupsRange; group++) {
1676 fprintf(f, " {\n");
1677 for (nnn = 0; nnn < kModRMOpcodeGroupSize; nnn++) {
1678 fprintf(f, " /* %d, %d */ { %s, %d, %d, %d },\t/* %s */\n",
1679 group, nnn,
1680 NaClInstTypeString(g_ModRMOpTable[group][nnn]->insttype),
1681 g_ModRMOpTable[group][nnn]->mrmbyte,
1682 g_ModRMOpTable[group][nnn]->immtype,
1683 g_ModRMOpTable[group][nnn]->opinmrm,
1684 g_ModRMOpTable[group][nnn]->disfmt);
1686 fprintf(f, " },\n");
1688 fprintf(f, "};\n\n");
1690 fprintf(f, "static const struct OpInfo kDecode0FXXOp[NCDTABLESIZE] = {\n");
1691 /* now print the table */
1692 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1693 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1694 NaClInstTypeString(g_Op0FXXMetaTable[opc]->insttype),
1695 g_Op0FXXMetaTable[opc]->mrmbyte,
1696 g_Op0FXXMetaTable[opc]->immtype,
1697 g_Op0FXXMetaTable[opc]->opinmrm,
1698 g_Op0FXXMetaTable[opc]->disfmt);
1700 fprintf(f, "};\n\n");
1702 /* NOTE: The 0x66 DATA16 prefix is allowed with basically all */
1703 /* instructions. So, if the g_Op660FXXTable doesn't have a defn */
1704 /* for the opcode we look in the g_Op0fXXTable. */
1705 fprintf(f, "static const struct OpInfo kDecode660FXXOp[NCDTABLESIZE] = {\n");
1706 /* now print the table */
1707 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1708 opinfo = g_Op660FXXTable[opc];
1709 if (opinfo == &DecodeUndefinedInstInfo) opinfo = g_Op0FXXMetaTable[opc];
1710 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1711 NaClInstTypeString(opinfo->insttype),
1712 opinfo->mrmbyte,
1713 opinfo->immtype,
1714 opinfo->opinmrm,
1715 opinfo->disfmt);
1717 fprintf(f, "};\n\n");
1719 fprintf(f, "static const struct OpInfo kDecodeF20FXXOp[NCDTABLESIZE] = {\n");
1720 /* now print the table */
1721 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1722 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1723 NaClInstTypeString(g_OpF20FXXTable[opc]->insttype),
1724 g_OpF20FXXTable[opc]->mrmbyte,
1725 g_OpF20FXXTable[opc]->immtype,
1726 g_OpF20FXXTable[opc]->opinmrm,
1727 g_OpF20FXXTable[opc]->disfmt);
1729 fprintf(f, "};\n\n");
1731 fprintf(f, "static const struct OpInfo kDecodeF30FXXOp[NCDTABLESIZE] = {\n");
1732 /* now print the table */
1733 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1734 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1735 NaClInstTypeString(g_OpF30FXXTable[opc]->insttype),
1736 g_OpF30FXXTable[opc]->mrmbyte,
1737 g_OpF30FXXTable[opc]->immtype,
1738 g_OpF30FXXTable[opc]->opinmrm,
1739 g_OpF30FXXTable[opc]->disfmt);
1741 fprintf(f, "};\n\n");
1743 /* three byte opcode tables */
1744 fprintf(f, "static const struct OpInfo kDecode0F0FOp[NCDTABLESIZE] = {\n");
1745 /* now print the table */
1746 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1747 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1748 NaClInstTypeString(g_Op0F0FTable[opc]->insttype),
1749 g_Op0F0FTable[opc]->mrmbyte,
1750 g_Op0F0FTable[opc]->immtype,
1751 g_Op0F0FTable[opc]->opinmrm,
1752 g_Op0F0FTable[opc]->disfmt);
1754 fprintf(f, "};\n\n");
1756 fprintf(f, "static const struct OpInfo kDecode0F38Op[NCDTABLESIZE] = {\n");
1757 /* now print the table */
1758 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1759 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1760 NaClInstTypeString(g_Op0F38Table[opc]->insttype),
1761 g_Op0F38Table[opc]->mrmbyte,
1762 g_Op0F38Table[opc]->immtype,
1763 g_Op0F38Table[opc]->opinmrm,
1764 g_Op0F38Table[opc]->disfmt);
1766 fprintf(f, "};\n\n");
1768 fprintf(f, "static const struct OpInfo kDecode0F3AOp[NCDTABLESIZE] = {\n");
1769 /* now print the table */
1770 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1771 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1772 NaClInstTypeString(g_Op0F3ATable[opc]->insttype),
1773 g_Op0F3ATable[opc]->mrmbyte,
1774 g_Op0F3ATable[opc]->immtype,
1775 g_Op0F3ATable[opc]->opinmrm,
1776 g_Op0F3ATable[opc]->disfmt);
1778 fprintf(f, "};\n\n");
1780 fprintf(f, "\n/* x87 opcode tables*/\n");
1781 fprintf(f, "static const struct OpInfo kDecode87D8[NCDTABLESIZE] = {\n");
1782 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1783 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1784 NaClInstTypeString(g_Op87D8[opc]->insttype),
1785 g_Op87D8[opc]->mrmbyte,
1786 g_Op87D8[opc]->immtype,
1787 g_Op87D8[opc]->opinmrm,
1788 g_Op87D8[opc]->disfmt);
1790 fprintf(f, "};\n\n");
1791 fprintf(f, "static const struct OpInfo kDecode87D9[NCDTABLESIZE] = {\n");
1792 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1793 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1794 NaClInstTypeString(g_Op87D9[opc]->insttype),
1795 g_Op87D9[opc]->mrmbyte,
1796 g_Op87D9[opc]->immtype,
1797 g_Op87D9[opc]->opinmrm,
1798 g_Op87D9[opc]->disfmt);
1800 fprintf(f, "};\n\n");
1801 fprintf(f, "static const struct OpInfo kDecode87DA[NCDTABLESIZE] = {\n");
1802 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1803 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1804 NaClInstTypeString(g_Op87DA[opc]->insttype),
1805 g_Op87DA[opc]->mrmbyte,
1806 g_Op87DA[opc]->immtype,
1807 g_Op87DA[opc]->opinmrm,
1808 g_Op87DA[opc]->disfmt);
1810 fprintf(f, "};\n\n");
1811 fprintf(f, "static const struct OpInfo kDecode87DB[NCDTABLESIZE] = {\n");
1812 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1813 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1814 NaClInstTypeString(g_Op87DB[opc]->insttype),
1815 g_Op87DB[opc]->mrmbyte,
1816 g_Op87DB[opc]->immtype,
1817 g_Op87DB[opc]->opinmrm,
1818 g_Op87DB[opc]->disfmt);
1820 fprintf(f, "};\n\n");
1821 fprintf(f, "static const struct OpInfo kDecode87DC[NCDTABLESIZE] = {\n");
1822 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1823 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1824 NaClInstTypeString(g_Op87DC[opc]->insttype),
1825 g_Op87DC[opc]->mrmbyte,
1826 g_Op87DC[opc]->immtype,
1827 g_Op87DC[opc]->opinmrm,
1828 g_Op87DC[opc]->disfmt);
1830 fprintf(f, "};\n\n");
1831 fprintf(f, "static const struct OpInfo kDecode87DD[NCDTABLESIZE] = {\n");
1832 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1833 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1834 NaClInstTypeString(g_Op87DD[opc]->insttype),
1835 g_Op87DD[opc]->mrmbyte,
1836 g_Op87DD[opc]->immtype,
1837 g_Op87DD[opc]->opinmrm,
1838 g_Op87DD[opc]->disfmt);
1840 fprintf(f, "};\n\n");
1841 fprintf(f, "static const struct OpInfo kDecode87DE[NCDTABLESIZE] = {\n");
1842 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1843 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1844 NaClInstTypeString(g_Op87DE[opc]->insttype),
1845 g_Op87DE[opc]->mrmbyte,
1846 g_Op87DE[opc]->immtype,
1847 g_Op87DE[opc]->opinmrm,
1848 g_Op87DE[opc]->disfmt);
1850 fprintf(f, "};\n\n");
1851 fprintf(f, "static const struct OpInfo kDecode87DF[NCDTABLESIZE] = {\n");
1852 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1853 fprintf(f, " /* %02x */ { %s, %d, %d, %d },\t/* %s */\n", opc,
1854 NaClInstTypeString(g_Op87DF[opc]->insttype),
1855 g_Op87DF[opc]->mrmbyte,
1856 g_Op87DF[opc]->immtype,
1857 g_Op87DF[opc]->opinmrm,
1858 g_Op87DF[opc]->disfmt);
1860 fprintf(f, "};\n\n");
1863 static void PrintDisasmTable(FILE *f) {
1864 int opc;
1865 int group, nnn;
1866 fprintf(f, "static const char *kDisasm1ByteOp[NCDTABLESIZE] = {\n");
1867 /* now print the table */
1869 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1870 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op1ByteTable[opc]->disfmt);
1872 fprintf(f, "};\n\n");
1874 fprintf(f, "static const char *kDisasmModRMOp[]");
1875 fprintf(f, "[kNaClMRMGroupsRange] = {\n");
1876 for (group = 0; group < kNaClMRMGroupsRange; group++) {
1877 fprintf(f, " {");
1878 for (nnn = 0; nnn < kModRMOpcodeGroupSize; nnn++) {
1879 fprintf(f, " /* %d %d */ \"%s\",\n", group, nnn,
1880 g_ModRMOpTable[group][nnn]->disfmt);
1882 fprintf(f, " },\n");
1884 fprintf(f, "};\n\n");
1886 fprintf(f, "static const char *kDisasm0FXXOp[NCDTABLESIZE] = {\n");
1887 /* now print the table */
1888 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1889 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0FXXMetaTable[opc]->disfmt);
1891 fprintf(f, "};\n\n");
1893 fprintf(f, "static const char *kDisasm660FXXOp[NCDTABLESIZE] = {\n");
1894 /* now print the table */
1895 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1896 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op660FXXTable[opc]->disfmt);
1898 fprintf(f, "};\n\n");
1900 fprintf(f, "static const char *kDisasmF20FXXOp[NCDTABLESIZE] = {\n");
1901 /* now print the table */
1902 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1903 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_OpF20FXXTable[opc]->disfmt);
1905 fprintf(f, "};\n\n");
1907 fprintf(f, "static const char *kDisasmF30FXXOp[NCDTABLESIZE] = {\n");
1908 /* now print the table */
1909 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1910 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_OpF30FXXTable[opc]->disfmt);
1912 fprintf(f, "};\n\n");
1914 /* three byte opcode tables including 3DNow */
1915 fprintf(f, "static const char *kDisasm0F0FOp[NCDTABLESIZE] = {\n");
1916 /* now print the table */
1917 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1918 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0F0FTable[opc]->disfmt);
1920 fprintf(f, "};\n\n");
1921 fprintf(f, "static const char *kDisasm0F38Op[NCDTABLESIZE] = {\n");
1922 /* now print the table */
1923 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1924 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0F38Table[opc]->disfmt);
1926 fprintf(f, "};\n\n");
1927 fprintf(f, "static const char *kDisasm0F3AOp[NCDTABLESIZE] = {\n");
1928 /* now print the table */
1929 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1930 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op0F3ATable[opc]->disfmt);
1932 fprintf(f, "};\n\n");
1934 fprintf(f, "\n/* x87 opcode tables*/\n");
1935 fprintf(f, "static const char *kDisasm87D8[NCDTABLESIZE] = {\n");
1936 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1937 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87D8[opc]->disfmt);
1939 fprintf(f, "};\n\n");
1940 fprintf(f, "static const char *kDisasm87D9[NCDTABLESIZE] = {\n");
1941 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1942 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87D9[opc]->disfmt);
1944 fprintf(f, "};\n\n");
1945 fprintf(f, "static const char *kDisasm87DA[NCDTABLESIZE] = {\n");
1946 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1947 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DA[opc]->disfmt);
1949 fprintf(f, "};\n\n");
1950 fprintf(f, "static const char *kDisasm87DB[NCDTABLESIZE] = {\n");
1951 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1952 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DB[opc]->disfmt);
1954 fprintf(f, "};\n\n");
1955 fprintf(f, "static const char *kDisasm87DC[NCDTABLESIZE] = {\n");
1956 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1957 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DC[opc]->disfmt);
1959 fprintf(f, "};\n\n");
1960 fprintf(f, "static const char *kDisasm87DD[NCDTABLESIZE] = {\n");
1961 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1962 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DD[opc]->disfmt);
1964 fprintf(f, "};\n\n");
1965 fprintf(f, "static const char *kDisasm87DE[NCDTABLESIZE] = {\n");
1966 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1967 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DE[opc]->disfmt);
1969 fprintf(f, "};\n\n");
1970 fprintf(f, "static const char *kDisasm87DF[NCDTABLESIZE] = {\n");
1971 for (opc = 0; opc < NCDTABLESIZE; opc++) {
1972 fprintf(f, " /* %02x */ \"%s\",\n", opc, g_Op87DF[opc]->disfmt);
1974 fprintf(f, "};\n\n");
1978 FILE *mustopen(const char *fname, const char *how) {
1979 FILE *f = fopen(fname, how);
1980 if (f == NULL) {
1981 fprintf(stderr, "could not fopen(%s, %s)\n", fname, how);
1982 fprintf(stderr, "exiting now\n");
1983 exit(-1);
1985 return f;
1988 #define DECODETAB "ncdecodetab.h"
1989 #define DISASMTAB "ncdisasmtab.h"
1990 int main(const int argc, const char *argv[]) {
1991 FILE *f;
1992 UNREFERENCED_PARAMETER(argc);
1993 BuildMetaTables();
1994 f = mustopen(DECODETAB, "w");
1995 PrintHeader(f, argv[0], DECODETAB);
1996 PrintDecodeTable(f);
1997 fclose(f);
1999 f = mustopen(DISASMTAB, "w");
2000 PrintHeader(f, argv[0], DISASMTAB);
2001 PrintDisasmTable(f);
2002 fclose(f);
2003 return 0;