arch-x86.C

Go to the documentation of this file.
00001 /*
00002  * See the dyninst/COPYRIGHT file for copyright information.
00003  * 
00004  * We provide the Paradyn Tools (below described as "Paradyn")
00005  * on an AS IS basis, and do not warrant its validity or performance.
00006  * We reserve the right to update, modify, or discontinue this
00007  * software at any time.  We shall have no obligation to supply such
00008  * updates or modifications or any other form of support to you.
00009  * 
00010  * By your use of Paradyn, you understand and agree that we (or any
00011  * other person or entity with proprietary rights in Paradyn) are
00012  * under no obligation to provide either maintenance services,
00013  * update services, notices of latent defects, or correction of
00014  * defects for Paradyn.
00015  * 
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00029  */
00030 
00031 // $Id: arch-x86.C,v 1.5 2008/09/04 21:06:48 bill Exp $
00032 
00033 // Official documentation used:    - IA-32 Intel Architecture Software Developer Manual (2001 ed.)
00034 //                                 - AMD x86-64 Architecture Programmer's Manual (rev 3.00, 1/2002)
00035 // Unofficial documentation used:  - www.sandpile.org/ia32
00036 //                                 - NASM documentation
00037 
00038 // Note: Unless specified "book" refers to Intel's manual
00039 
00040 // This include *must* come first in the file.
00041 #include "common/h/Types.h"
00042 
00043 #include <assert.h>
00044 #include <stdio.h>
00045 #include <map>
00046 #include <string>
00047 #include <iostream>
00048 
00049 #include "boost/assign/list_of.hpp"
00050 #include "boost/assign/std/vector.hpp"
00051 #include "boost/assign/std/set.hpp"
00052 
00053 #include "common/h/arch-x86.h"
00054 #include "dyn_regs.h"
00055 
00056 #if defined(os_vxworks)
00057 #include "common/h/wtxKludges.h"
00058 #endif
00059 
00060 using namespace std;
00061 using namespace boost::assign;
00062 
00063 namespace NS_x86 {
00064 
00065 unsigned int swapBytesIfNeeded(unsigned int i)
00066 {
00067     return i;
00068 }
00069 
00070 // groups
00071 enum {
00072   Grp1a=0, Grp1b, Grp1c, Grp1d, Grp2, Grp3a, Grp3b, Grp4, Grp5, Grp6, Grp7,
00073   Grp8, Grp9, Grp11, Grp12, Grp13, Grp14, Grp15, Grp16, Grp17, GrpAMD
00074 };
00075 
00076 // SSE
00077 enum {
00078   SSE10=0, SSE11, SSE12, SSE13, SSE14, SSE15, SSE16, SSE17,
00079   SSE28, SSE29, SSE2A, SSE2B, SSE2C, SSE2D, SSE2E, SSE2F,
00080   SSE50, SSE51, SSE52, SSE53, SSE54, SSE55, SSE56, SSE57,
00081   SSE58, SSE59, SSE5A, SSE5B, SSE5C, SSE5D, SSE5E, SSE5F,
00082   SSE60, SSE61, SSE62, SSE63, SSE64, SSE65, SSE66, SSE67,
00083   SSE68, SSE69, SSE6A, SSE6B, SSE6C, SSE6D, SSE6E, SSE6F,
00084   SSE70, SSE74, SSE75, SSE76,
00085   SSE78, SSE79, SSE7C, SSE7D, SSE7E, SSE7F,
00086   SSEB8,
00087   SSEC2, SSEC4, SSEC5, SSEC6,
00088   SSED0, SSED1, SSED2, SSED3, SSED4, SSED5, SSED6, SSED7,
00089   SSED8, SSED9, SSEDA, SSEDB, SSEDC, SSEDD, SSEDE, SSEDF,
00090   SSEE0, SSEE1, SSEE2, SSEE3, SSEE4, SSEE5, SSEE6, SSEE7,
00091   SSEE8, SSEE9, SSEEA, SSEEB, SSEEC, SSEED, SSEEE, SSEEF,
00092   SSEF0, SSEF1, SSEF2, SSEF3, SSEF4, SSEF5, SSEF6, SSEF7,
00093   SSEF8, SSEF9, SSEFA, SSEFB, SSEFC, SSEFD, SSEFE, SSEFF
00094 };
00095 
00096 // SSE BIS
00097 enum {
00098     SSEB00=0, SSEB01, SSEB02, SSEB03, SSEB04, SSEB05, SSEB06, SSEB07,
00099     SSEB08, SSEB09, SSEB0A, SSEB0B,
00100     SSEB10, SSEB14, SSEB15, SSEB17,
00101     SSEB1C, SSEB1D, SSEB1E,
00102     SSEB20, SSEB21, SSEB22, SSEB23, SSEB24, SSEB25, 
00103     SSEB28, SSEB29, SSEB2A, SSEB2B,
00104     SSEB30, SSEB31, SSEB32, SSEB33, SSEB34, SSEB35, SSEB37,
00105     SSEB38, SSEB39, SSEB3A, SSEB3B, SSEB3C, SSEB3D, SSEB3E, SSEB3F,
00106     SSEB40, SSEB41,
00107     SSEBF0, SSEBF1
00108 };
00109 
00110 // SSE TER 
00111 enum {
00112     SSET08=0, SSET09,
00113     SSET0A, SSET0B, SSET0C, SSET0D, SSET0E, SSET0F,
00114     SSET14, SSET15, SSET16, SSET17,
00115     SSET20, SSET21, SSET22,
00116     SSET40, SSET41, SSET42,
00117     SSET60, SSET61, SSET62, SSET63
00118 };
00119 
00120 // SSE groups
00121 enum {
00122   G12SSE010B=0, G12SSE100B, G12SSE110B,
00123   G13SSE010B, G13SSE100B, G13SSE110B,
00124   G14SSE010B, G14SSE011B, G14SSE110B, G14SSE111B,
00125 };
00126 
00127 enum {
00128     GrpD8=0, GrpD9, GrpDA, GrpDB, GrpDC, GrpDD, GrpDE, GrpDF
00129 };
00130 
00131 #define Zz   { 0, 0 }
00132 #define ImplImm { am_ImplImm, op_b }
00133 #define Ap   { am_A, op_p }
00134 #define Cd   { am_C, op_d }
00135 #define Dd   { am_D, op_d }
00136 #define Eb   { am_E, op_b }
00137 #define Ed   { am_E, op_d }
00138 #define Ef   { am_E, op_f }
00139 #define Efd  { am_E, op_dbl }
00140 #define Ep   { am_E, op_p }
00141 #define Ev   { am_E, op_v }
00142 #define Ew   { am_E, op_w }
00143 #define Ey   { am_E, op_y }
00144 #define Fv   { am_F, op_v }
00145 #define Gb   { am_G, op_b }
00146 #define Gd   { am_G, op_d }
00147 #define Gv   { am_G, op_v }
00148 #define Gw   { am_G, op_w }
00149 #define Gf   { am_G, op_f }
00150 #define Gfd  { am_G, op_dbl }
00151 #define Ib   { am_I, op_b }
00152 #define Iv   { am_I, op_v }
00153 #define Iw   { am_I, op_w }
00154 #define Iz   { am_I, op_z }
00155 #define Jb   { am_J, op_b }
00156 #define Jv   { am_J, op_v }
00157 #define Jz   { am_J, op_z }
00158 #define Ma   { am_M, op_a }
00159 #define Mb   { am_M, op_b }
00160 #define Mlea { am_M, op_lea }
00161 #define Mp   { am_M, op_p }
00162 #define Ms   { am_M, op_s }
00163 #define Md   { am_M, op_d }
00164 #define Mq   { am_M, op_q }
00165 #define Mdq   { am_M, op_dq }
00166 #define M512 { am_M, op_512 }
00167 #define Mf   { am_M, op_f }
00168 #define Mfd  { am_M, op_dbl }
00169 #define M14  { am_M, op_14 }
00170 #define Ob   { am_O, op_b }
00171 #define Ov   { am_O, op_v }
00172 #define Pd   { am_P, op_d }
00173 #define Pdq  { am_P, op_dq }
00174 #define Ppi  { am_P, op_pi }
00175 #define Pq   { am_P, op_q }
00176 #define Qdq  { am_Q, op_dq }
00177 #define Qd   { am_Q, op_d }
00178 #define Qpi  { am_Q, op_pi }
00179 #define Qq   { am_Q, op_q }
00180 #define Rd   { am_R, op_d }
00181 #define RMb  { am_RM, op_b }
00182 #define RMw  { am_RM, op_w }
00183 #define Td   { am_T, op_d }
00184 #define UMd  { am_UM, op_d }
00185 #define Sw   { am_S, op_w }
00186 #define Vd   { am_V, op_d }
00187 #define Vdq  { am_V, op_dq }
00188 #define Vpd  { am_V, op_pd }
00189 #define Vps  { am_V, op_ps }
00190 #define Vq   { am_V, op_q }
00191 #define VRq  { am_VR, op_q }
00192 #define VRdq { am_VR, op_dq }
00193 #define Vss  { am_V, op_ss }
00194 #define Vsd  { am_V, op_sd }
00195 #define Wdq  { am_W, op_dq }
00196 #define Wpd  { am_W, op_pd }
00197 #define Wps  { am_W, op_ps }
00198 #define Wq   { am_W, op_q }
00199 #define Ws   { am_W, op_s }
00200 #define Wsd  { am_W, op_sd }
00201 #define Wss  { am_W, op_ss }
00202 #define Xb   { am_X, op_b }
00203 #define Xv   { am_X, op_v }
00204 #define Yb   { am_Y, op_b }
00205 #define Yv   { am_Y, op_v }
00206 #define STHb { am_stackH, op_b }
00207 #define STPb { am_stackP, op_b }
00208 #define STHv { am_stackH, op_v }
00209 #define STPv { am_stackP, op_v }
00210 #define STHw { am_stackH, op_w }
00211 #define STPw { am_stackP, op_w }
00212 #define STHd { am_stackH, op_d }
00213 #define STPd { am_stackP, op_d }
00214 #define STHa { am_stackH, op_allgprs }
00215 #define STPa { am_stackP, op_allgprs }
00216 
00217 #define STKb { am_stack, op_b }
00218 #define STKv { am_stack, op_v }
00219 #define STKw { am_stack, op_w }
00220 #define STKd { am_stack, op_d }
00221 #define STKa { am_stack, op_allgprs }
00222 
00223 
00224 #define GPRS { am_allgprs, op_allgprs }
00225 
00226 #define AH  { am_reg, x86::iah }
00227 #define AX  { am_reg, x86::iax }
00228 #define BH  { am_reg, x86::ibh }
00229 #define CH  { am_reg, x86::ich }
00230 #define DH  { am_reg, x86::idh }
00231 #define AL  { am_reg, x86::ial }
00232 #define BL  { am_reg, x86::ibl }
00233 #define CL  { am_reg, x86::icl }
00234 #define CS  { am_reg, x86::ics }
00235 #define DL  { am_reg, x86::idl }
00236 #define DX  { am_reg, x86::idx }
00237 #define eAX { am_reg, x86::ieax }
00238 #define eBX { am_reg, x86::iebx }
00239 #define eCX { am_reg, x86::iecx }
00240 #define eDX { am_reg, x86::iedx }
00241 #define EAX { am_reg, x86::ieax }
00242 #define EBX { am_reg, x86::iebx }
00243 #define ECX { am_reg, x86::iecx }
00244 #define EDX { am_reg, x86::iedx }
00245 #define DS  { am_reg, x86::ids }
00246 #define ES  { am_reg, x86::ies }
00247 #define FS  { am_reg, x86::ifs }
00248 #define GS  { am_reg, x86::igs }
00249 #define SS  { am_reg, x86::iss }
00250 #define eSP { am_reg, x86::iesp }
00251 #define eBP { am_reg, x86::iebp }
00252 #define eSI { am_reg, x86::iesi }
00253 #define eDI { am_reg, x86::iedi }
00254 #define ESP { am_reg, x86::iesp }
00255 #define EBP { am_reg, x86::iebp }
00256 #define ESI { am_reg, x86::iesi }
00257 #define EDI { am_reg, x86::iedi }
00258 #define ECXEBX { am_tworeghack, op_ecxebx }
00259 #define EDXEAX { am_tworeghack, op_edxeax }
00260 #define rAX { am_reg, x86_64::irax }
00261 #define rBX { am_reg, x86_64::irbx }
00262 #define rCX { am_reg, x86_64::ircx }
00263 #define rDX { am_reg, x86_64::irdx }
00264 #define rSP { am_reg, x86_64::irsp }
00265 #define rBP { am_reg, x86_64::irbp }
00266 #define rSI { am_reg, x86_64::irsi }
00267 #define rDI { am_reg, x86_64::irdi }
00268 #define ST0 { am_reg, x86::ist0 }
00269 #define ST1 { am_reg, x86::ist1 }
00270 #define ST2 { am_reg, x86::ist2 }
00271 #define ST3 { am_reg, x86::ist3 }
00272 #define ST4 { am_reg, x86::ist4 }
00273 #define ST5 { am_reg, x86::ist5 }
00274 #define ST6 { am_reg, x86::ist6 }
00275 #define ST7 { am_reg, x86::ist7 }
00276 #define FPOS 16
00277 
00278 enum {
00279   fNT=1,   // non-temporal
00280   fPREFETCHNT,
00281   fPREFETCHT0,
00282   fPREFETCHT1,
00283   fPREFETCHT2,
00284   fPREFETCHAMDE,
00285   fPREFETCHAMDW,
00286   fCALL,
00287   fNEARRET,
00288   fFARRET,
00289   fIRET,
00290   fENTER,
00291   fLEAVE,
00292   fXLAT,
00293   fIO,
00294   fSEGDESC,
00295   fCOND,
00296   fCMPXCH,
00297   fCMPXCH8,
00298   fINDIRCALL,
00299   fINDIRJUMP,
00300   fFXSAVE,
00301   fFXRSTOR,
00302   fCLFLUSH,
00303   fREP,   // only rep prefix allowed: ins, movs, outs, lods, stos
00304   fSCAS,
00305   fCMPS
00306 };
00307 
00308 COMMON_EXPORT dyn_hash_map<entryID, std::string> entryNames_IAPI = map_list_of
00309   (e_aaa, "aaa")
00310   (e_aad, "aad")
00311   (e_aam, "aam")
00312   (e_aas, "aas")
00313   (e_adc, "adc")
00314   (e_add, "add")
00315   (e_addpd, "addpd")
00316   (e_addps, "addps")
00317   (e_addsd, "addsd")
00318   (e_addss, "addss")
00319   (e_addsubpd, "addsubpd")
00320   (e_addsubps, "addsubps")
00321   (e_and, "and")
00322   (e_andnpd, "andnpd")
00323   (e_andnps, "andnps")
00324   (e_andpd, "andpd")
00325   (e_andps, "andps")
00326   (e_arpl, "arpl")
00327   (e_blendpd,"blendpd")
00328   (e_blendps, "blendps")
00329   (e_blendvpd, "blendvpd")
00330   (e_blendvps, "blendvps")
00331   (e_bound, "bound")
00332   (e_bsf, "bsf")
00333   (e_bsr, "bsr")
00334   (e_bswap, "bswap")
00335   (e_bt, "bt")
00336   (e_btc, "btc")
00337   (e_btr, "btr")
00338   (e_bts, "bts")
00339   (e_call, "call")
00340   (e_cbw, "cbw")
00341   (e_cdq, "cdq")
00342   (e_clc, "clc")
00343   (e_cld, "cld")
00344   (e_clflush, "clflush")
00345   (e_cli, "cli")
00346   (e_clts, "clts")
00347   (e_cmc, "cmc")
00348   (e_cmovbe, "cmovbe")
00349   (e_cmove, "cmove")
00350   (e_cmovnae, "cmovnae")
00351   (e_cmovnb, "cmovnb")
00352   (e_cmovnbe, "cmovnbe")
00353   (e_cmovne, "cmovne")
00354   (e_cmovng, "cmovng")
00355   (e_cmovnge, "cmovnge")
00356   (e_cmovnl, "cmovnl")
00357   (e_cmovno, "cmovno")
00358   (e_cmovns, "cmovns")
00359   (e_cmovo, "cmovo")
00360   (e_cmovpe, "cmovpe")
00361   (e_cmovpo, "cmovpo")
00362   (e_cmovs, "cmovs")
00363   (e_cmp, "cmp")
00364   (e_cmppd, "cmppd")
00365   (e_cmpps, "cmpps")
00366   (e_cmpsb, "cmpsb")
00367   (e_cmpsd, "cmpsd")
00368   (e_cmpss, "cmpss")
00369   (e_cmpsw, "cmpsw")
00370   (e_cmpxch, "cmpxch")
00371   (e_cmpxch8b, "cmpxch8b")
00372   (e_comisd, "comisd")
00373   (e_comiss, "comiss")
00374   (e_cpuid, "cpuid")
00375   (e_crc32, "crc32")
00376   (e_cvtdq2pd, "cvtdq2pd")
00377   (e_cvtdq2ps, "cvtdq2ps")
00378   (e_cvtpd2dq, "cvtpd2dq")
00379   (e_cvtpd2pi, "cvtpd2pi")
00380   (e_cvtpd2ps, "cvtpd2ps")
00381   (e_cvtpi2pd, "cvtpi2pd")
00382   (e_cvtpi2ps, "cvtpi2ps")
00383   (e_cvtps2dq, "cvtps2dq")
00384   (e_cvtps2pd, "cvtps2pd")
00385   (e_cvtps2pi, "cvtps2pi")
00386   (e_cvtsd2si, "cvtsd2si")
00387   (e_cvtsd2ss, "cvtsd2ss")
00388   (e_cvtsi2sd, "cvtsi2sd")
00389   (e_cvtsi2ss, "cvtsi2ss")
00390   (e_cvtss2sd, "cvtss2sd")
00391   (e_cvtss2si, "cvtss2si")
00392   (e_cvttpd2dq, "cvttpd2dq")
00393   (e_cvttpd2pi, "cvttpd2pi")
00394   (e_cvttps2dq, "cvttps2dq")
00395   (e_cvttps2pi, "cvttps2pi")
00396   (e_cvttsd2si, "cvttsd2si")
00397   (e_cvttss2si, "cvttss2si")
00398   (e_cwd, "cwd")
00399   (e_cwde, "cwde")
00400   (e_daa, "daa")
00401   (e_das, "das")
00402   (e_dec, "dec")
00403   (e_div, "div")
00404   (e_divpd, "divpd")
00405   (e_divps, "divps")
00406   (e_divsd, "divsd")
00407   (e_divss, "divss")
00408   (e_dppd, "dppd")
00409   (e_dpps, "dpps")
00410   (e_emms, "emms")
00411   (e_enter, "enter")
00412   (e_extractps, "extractps")
00413   (e_extrq, "extrq")
00414   (e_fadd, "fadd")
00415   (e_faddp, "faddp")
00416   (e_fbld, "fbld")
00417   (e_fbstp, "fbstp")
00418   (e_fcom, "fcom")
00419   (e_fcomp, "fcomp")
00420   (e_fdiv, "fdiv")
00421   (e_fdivr, "fdivr")
00422   (e_femms, "femms")
00423   (e_fiadd, "fiadd")
00424   (e_ficom, "ficom")
00425   (e_ficomp, "ficomp")
00426   (e_fidiv, "fidiv")
00427   (e_fidivr, "fidivr")
00428   (e_fild, "fild")
00429   (e_fimul, "fimul")
00430   (e_fist, "fist")
00431   (e_fistp, "fistp")
00432   (e_fisttp, "fisttp")
00433   (e_fisub, "fisub")
00434   (e_fisubr, "fisubr")
00435   (e_fld, "fld")
00436   (e_fldcw, "fldcw")
00437   (e_fldenv, "fldenv")
00438   (e_fmul, "fmul")
00439   (e_fnop, "fnop")
00440   (e_frstor, "frstor")
00441   (e_fsave, "fsave")
00442   (e_fst, "fst")
00443   (e_fstcw, "fstcw")
00444   (e_fstenv, "fstenv")
00445   (e_fstp, "fstp")
00446   (e_fstsw, "fstsw")
00447   (e_fsub, "fsub")
00448   (e_fsubr, "fsubr")
00449   (e_fucomp, "fucomp")
00450   (e_fucompp, "fucompp")
00451   (e_fxrstor, "fxrstor")
00452   (e_fxsave, "fxsave")
00453   (e_haddpd, "haddpd")
00454   (e_haddps, "haddps")
00455   (e_hlt, "hlt")
00456   (e_hsubpd, "hsubpd")
00457   (e_hsubps, "hsubps")
00458   (e_idiv, "idiv")
00459   (e_imul, "imul")
00460   (e_in, "in")
00461   (e_inc, "inc")
00462   (e_insb, "insb")
00463   (e_insd, "insd")
00464   (e_insertps, "insertps")
00465   (e_insertq, "insertq")
00466   (e_insw, "insw")
00467   (e_int, "int")
00468   (e_int3, "int 3")
00469   (e_int1, "int1")
00470   (e_int80, "int 80")
00471   (e_into, "into")
00472   (e_invd, "invd")
00473   (e_invlpg, "invlpg")
00474   (e_iret, "iret")
00475   (e_jb, "jb")
00476   (e_jb_jnaej_j, "jb/jnaej/j")
00477   (e_jbe, "jbe")
00478   (e_jcxz_jec, "jcxz/jec")
00479   (e_jl, "jl")
00480   (e_jle, "jle")
00481   (e_jmp, "jmp")
00482   (e_jnb, "jnb")
00483   (e_jnb_jae_j, "jnb/jae/j")
00484   (e_jnbe, "jnbe")
00485   (e_jnl, "jnl")
00486   (e_jnle, "jnle")
00487   (e_jno, "jno")
00488   (e_jnp, "jnp")
00489   (e_jns, "jns")
00490   (e_jnz, "jnz")
00491   (e_jo, "jo")
00492   (e_jp, "jp")
00493   (e_js, "js")
00494   (e_jz, "jz")
00495   (e_lahf, "lahf")
00496   (e_lar, "lar")
00497   (e_ldmxcsr, "ldmxcsr")
00498   (e_lds, "lds")
00499   (e_lddqu, "lddqu")
00500   (e_lea, "lea")
00501   (e_leave, "leave")
00502   (e_les, "les")
00503   (e_lfence, "lfence")
00504   (e_lfs, "lfs")
00505   (e_lgdt, "lgdt")
00506   (e_lgs, "lgs")
00507   (e_lidt, "lidt")
00508   (e_lldt, "lldt")
00509   (e_lmsw, "lmsw")
00510   (e_lodsb, "lodsb")
00511   (e_lodsd, "lodsd")
00512   (e_lodsw, "lodsw")
00513   (e_loop, "loop")
00514   (e_loope, "loope")
00515   (e_loopn, "loopn")
00516   (e_lsl, "lsl")
00517   (e_lss, "lss")
00518   (e_ltr, "ltr")
00519   (e_maskmovdqu, "maskmovdqu")
00520   (e_maskmovq, "maskmovq")
00521   (e_maxpd, "maxpd")
00522   (e_maxps, "maxps")
00523   (e_maxsd, "maxsd")
00524   (e_maxss, "maxss")
00525   (e_mfence, "mfence")
00526   (e_minpd, "minpd")
00527   (e_minps, "minps")
00528   (e_minsd, "minsd")
00529   (e_minss, "minss")
00530   (e_mmxud, "mmxud")
00531   (e_mov, "mov")
00532   (e_movapd, "movapd")
00533   (e_movaps, "movaps")
00534   (e_movd, "movd")
00535   (e_movddup, "movddup")
00536   (e_movdq2q, "movdq2q")
00537   (e_movdqa, "movdqa")
00538   (e_movdqu, "movdqu")
00539   (e_movhpd, "movhpd")
00540   (e_movhps, "movhps")
00541   (e_movhps_movlhps, "movhps/movlhps")
00542   (e_movlpd, "movlpd")
00543   (e_movlps, "movlps")
00544   (e_movlps_movhlps, "movlps/movhlps")
00545   (e_movmskpd, "movmskpd")
00546   (e_movmskps, "movmskps")
00547   (e_movntdq, "movntdq")
00548   (e_movntdqa, "movntdqa")
00549   (e_movnti, "movnti")
00550   (e_movntpd, "movntpd")
00551   (e_movntps, "movntps")
00552   (e_movntq, "movntq")
00553   (e_movq, "movq")
00554   (e_movq2dq, "movq2dq")
00555   (e_movsb, "movsb")
00556   (e_movsd, "movsd")
00557   (e_movsd_sse, "movsd")
00558   (e_movshdup, "movshdup")
00559   (e_movsldup, "movsldup")
00560   (e_movss, "movss")
00561   (e_movsw, "movsw")
00562   (e_movsx, "movsx")
00563   (e_movsxd, "movsxd")
00564   (e_movupd, "movupd")
00565   (e_movups, "movups")
00566   (e_movzx, "movzx")
00567   (e_mpsadbw, "mpsadbw")
00568   (e_mul, "mul")
00569   (e_mulpd, "mulpd")
00570   (e_mulps, "mulps")
00571   (e_mulsd, "mulsd")
00572   (e_mulss, "mulss")
00573   (e_neg, "neg")
00574   (e_nop, "nop")
00575   (e_not, "not")
00576   (e_or, "or")
00577   (e_orpd, "orpd")
00578   (e_orps, "orps")
00579   (e_out, "out")
00580   (e_outsb, "outsb")
00581   (e_outsd, "outsd")
00582   (e_outsw, "outsw")
00583   (e_pabsb, "pabsb")
00584   (e_pabsd, "pabsd")
00585   (e_pabsw, "pabsw")
00586   (e_packssdw, "packssdw")
00587   (e_packsswb, "packsswb")
00588   (e_packusdw, "packusdw")
00589   (e_packuswb, "packuswb")
00590   (e_paddb, "paddb")
00591   (e_paddd, "paddd")
00592   (e_paddq, "paddq")
00593   (e_paddsb, "paddsb")
00594   (e_paddsw, "paddsw")
00595   (e_paddusb, "paddusb")
00596   (e_paddusw, "paddusw")
00597   (e_paddw, "paddw")
00598   (e_palignr, "palignr")
00599   (e_pand, "pand")
00600   (e_pandn, "pandn")
00601   (e_pavgb, "pavgb")
00602   (e_pavgw, "pavgw")
00603   (e_pblendvb, "pblendvb")
00604   (e_pblendw, "pblendw")
00605   (e_pcmpeqb, "pcmpeqb")
00606   (e_pcmpeqd, "pcmpeqd")
00607   (e_pcmpeqq, "pcmpeqq")
00608   (e_pcmpeqw, "pcmpeqw")
00609   (e_pcmpestri, "pcmpestri")
00610   (e_pcmpestrm, "pcmpestrm")
00611   (e_pcmpgdt, "pcmpgdt")
00612   (e_pcmpgtb, "pcmpgtb")
00613   (e_pcmpgtq, "pcmpgtq")
00614   (e_pcmpgtw, "pcmpgtw")
00615   (e_pcmpistri, "pcmpistri")
00616   (e_pcmpistrm, "pcmpistrm")
00617   (e_pextrb, "pextrb")
00618   (e_pextrd_pextrq, "pextrd/pextrq")
00619   (e_pextrw, "pextrw")
00620   (e_phaddd, "phaddd")
00621   (e_phaddsw, "phaddsw")
00622   (e_phaddw, "phaddw")
00623   (e_phminposuw, "phminposuw")
00624   (e_phsubd, "phsubd")
00625   (e_phsubsw, "phsubsw")
00626   (e_phsubw, "phsubw")
00627   (e_pinsrb, "pinsrb")
00628   (e_pinsrd_pinsrq, "pinsrd/pinsrq")
00629   (e_pinsrw, "pinsrw")
00630   (e_pmaddubsw, "pmaddubsw")
00631   (e_pmaddwd, "pmaddwd")
00632   (e_pmaxsb, "pmaxsb")
00633   (e_pmaxsd, "pmaxsd")
00634   (e_pmaxsw, "pmaxsw")
00635   (e_pmaxub, "pmaxub")
00636   (e_pmaxud, "pmaxud")
00637   (e_pmaxuw, "pmaxuw")
00638   (e_pminsb, "pminsb")
00639   (e_pminsd, "pminsd")
00640   (e_pminsw, "pminsw")
00641   (e_pminub, "pminub")
00642   (e_pminud, "pminud")
00643   (e_pminuw, "pminuw")
00644   (e_pmovmskb, "pmovmskb")
00645   (e_pmovsxbd, "pmovsxbd")
00646   (e_pmovsxbq, "pmovsxbq")
00647   (e_pmovsxbw, "pmovsxbw")
00648   (e_pmovsxdq, "pmovsxdq")
00649   (e_pmovsxwd, "pmovsxwd")
00650   (e_pmovsxwq, "pmovsxwq")
00651   (e_pmovzxbd, "pmovzxbd")
00652   (e_pmovzxbq, "pmovzxbq")
00653   (e_pmovzxbw, "pmovzxbw")
00654   (e_pmovzxdq, "pmovzxdq")
00655   (e_pmovzxwd, "pmovzxwd")
00656   (e_pmovzxwq, "pmovzxwq")
00657   (e_pmuldq, "pmuldq")
00658   (e_pmulhrsw, "pmulhrsw")
00659   (e_pmulhuw, "pmulhuw")
00660   (e_pmulhw, "pmulhw")
00661   (e_pmullw, "pmullw")
00662   (e_pmulld, "pmulld")
00663   (e_pmuludq, "pmuludq")
00664   (e_pop, "pop")
00665   (e_popa, "popa")
00666   (e_popad, "popad")
00667   (e_popcnt, "popcnt")
00668   (e_popf, "popf")
00669   (e_popfd, "popfd")
00670   (e_por, "por")
00671   (e_prefetch, "prefetch")
00672   (e_prefetchNTA, "prefetchNTA")
00673   (e_prefetchT0, "prefetchT0")
00674   (e_prefetchT1, "prefetchT1")
00675   (e_prefetchT2, "prefetchT2")
00676   (e_prefetch_w, "prefetch(w)")
00677   (e_prefetchw, "prefetchw")
00678   (e_psadbw, "psadbw")
00679   (e_pshufb, "pshufb")
00680   (e_pshufd, "pshufd")
00681   (e_pshufhw, "pshufhw")
00682   (e_pshuflw, "pshuflw")
00683   (e_pshufw, "pshufw")
00684   (e_psignb, "psignb")
00685   (e_psignd, "psignd")
00686   (e_psignw, "psignw")
00687   (e_pslld, "pslld")
00688   (e_pslldq, "pslldq")
00689   (e_psllq, "psllq")
00690   (e_psllw, "psllw")
00691   (e_psrad, "psrad")
00692   (e_psraw, "psraw")
00693   (e_psrld, "psrld")
00694   (e_psrldq, "psrldq")
00695   (e_psrlq, "psrlq")
00696   (e_psrlw, "psrlw")
00697   (e_psubb, "psubb")
00698   (e_psubd, "psubd")
00699   (e_psubsb, "psubsb")
00700   (e_psubsw, "psubsw")
00701   (e_psubusb, "psubusb")
00702   (e_psubusw, "psubusw")
00703   (e_psubw, "psubw")
00704   (e_ptest, "ptest")
00705   (e_punpckhbw, "punpckhbw")
00706   (e_punpckhdq, "punpckhdq")
00707   (e_punpckhqd, "punpckhqd")
00708   (e_punpckhwd, "punpckhwd")
00709   (e_punpcklbw, "punpcklbw")
00710   (e_punpcklqd, "punpcklqd")
00711   (e_punpcklqld, "punpcklqld")
00712   (e_punpcklwd, "punpcklwd")
00713   (e_push, "push")
00714   (e_pusha, "pusha")
00715   (e_pushad, "pushad")
00716   (e_pushf, "pushf")
00717   (e_pushfd, "pushfd")
00718   (e_pxor, "pxor")
00719   (e_rcl, "rcl")
00720   (e_rcpps, "rcpps")
00721   (e_rcpss, "rcpss")
00722   (e_rcr, "rcr")
00723   (e_rdmsr, "rdmsr")
00724   (e_rdpmc, "rdpmc")
00725   (e_rdtsc, "rdtsc")
00726   (e_ret_far, "ret far")
00727   (e_ret_near, "ret near")
00728   (e_rol, "rol")
00729   (e_ror, "ror")
00730   (e_roundpd, "roundpd")
00731   (e_roundps, "roundps")
00732   (e_roundsd, "roundsd")
00733   (e_roundss, "roundss")
00734   (e_rsm, "rsm")
00735   (e_rsqrtps, "rsqrtps")
00736   (e_rsqrtss, "rsqrtss")
00737   (e_sahf, "sahf")
00738   (e_salc, "salc")
00739   (e_sar, "sar")
00740   (e_sbb, "sbb")
00741   (e_scasb, "scasb")
00742   (e_scasd, "scasd")
00743   (e_scasw, "scasw")
00744   (e_setb, "setb")
00745   (e_setbe, "setbe")
00746   (e_setl, "setl")
00747   (e_setle, "setle")
00748   (e_setnb, "setnb")
00749   (e_setnbe, "setnbe")
00750   (e_setnl, "setnl")
00751   (e_setnle, "setnle")
00752   (e_setno, "setno")
00753   (e_setnp, "setnp")
00754   (e_setns, "setns")
00755   (e_setnz, "setnz")
00756   (e_seto, "seto")
00757   (e_setp, "setp")
00758   (e_sets, "sets")
00759   (e_setz, "setz")
00760   (e_sfence, "sfence")
00761   (e_sgdt, "sgdt")
00762   (e_shl_sal, "shl/sal")
00763   (e_shld, "shld")
00764   (e_shr, "shr")
00765   (e_shrd, "shrd")
00766   (e_shufpd, "shufpd")
00767   (e_shufps, "shufps")
00768   (e_sidt, "sidt")
00769   (e_sldt, "sldt")
00770   (e_smsw, "smsw")
00771   (e_sqrtpd, "sqrtpd")
00772   (e_sqrtps, "sqrtps")
00773   (e_sqrtsd, "sqrtsd")
00774   (e_sqrtss, "sqrtss")
00775   (e_stc, "stc")
00776   (e_std, "std")
00777   (e_sti, "sti")
00778   (e_stmxcsr, "stmxcsr")
00779   (e_stosb, "stosb")
00780   (e_stosd, "stosd")
00781   (e_stosw, "stosw")
00782   (e_str, "str")
00783   (e_sub, "sub")
00784   (e_subpd, "subpd")
00785   (e_subps, "subps")
00786   (e_subsd, "subsd")
00787   (e_subss, "subss")
00788   (e_syscall, "syscall")
00789   (e_sysenter, "sysenter")
00790   (e_sysexit, "sysexit")
00791   (e_sysret, "sysret")
00792   (e_test, "test")
00793   (e_ucomisd, "ucomisd")
00794   (e_ucomiss, "ucomiss")
00795   (e_ud2, "ud2")
00796   (e_ud2grp10, "ud2grp10")
00797   (e_unpckhpd, "unpckhpd")
00798   (e_unpckhps, "unpckhps")
00799   (e_unpcklpd, "unpcklpd")
00800   (e_unpcklps, "unpcklps")
00801   (e_verr, "verr")
00802   (e_verw, "verw")
00803   (e_wait, "wait")
00804   (e_wbinvd, "wbinvd")
00805   (e_wrmsr, "wrmsr")
00806   (e_xadd, "xadd")
00807   (e_xchg, "xchg")
00808   (e_xlat, "xlat")
00809   (e_xor, "xor")
00810   (e_xorpd, "xorpd")
00811   (e_xorps, "xorps")
00812   (e_fp_generic, "[FIXME: GENERIC FPU INSN]")
00813   (e_3dnow_generic, "[FIXME: GENERIC 3DNow INSN]")
00814         ;
00815 
00816 dyn_hash_map<prefixEntryID, std::string> prefixEntryNames_IAPI = map_list_of
00817   (prefix_rep, "REP")
00818   (prefix_repnz, "REPNZ")
00819         ;
00820 
00821 COMMON_EXPORT dyn_hash_map<entryID, flagInfo> const& ia32_instruction::getFlagTable()
00822 {
00823   static dyn_hash_map<entryID, flagInfo> flagTable;
00824   if(flagTable.empty()) 
00825   {
00826     ia32_instruction::initFlagTable(flagTable);
00827   }
00828   return flagTable;
00829 }
00830   
00831 void ia32_instruction::initFlagTable(dyn_hash_map<entryID, flagInfo>& flagTable)
00832 {
00833   static const vector<Dyninst::MachRegister> standardFlags = list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf)(x86::cf);
00834 
00835   flagTable[e_aaa] = flagInfo(list_of(x86::af), standardFlags);
00836   flagTable[e_aad] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00837   flagTable[e_aam] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00838   flagTable[e_aas] = flagInfo(list_of(x86::af), standardFlags);
00839   flagTable[e_adc] = flagInfo(list_of(x86::cf), standardFlags);
00840   flagTable[e_add] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00841   flagTable[e_and] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00842   flagTable[e_arpl] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::zf));
00843   flagTable[e_bsf] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00844   flagTable[e_bsr] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00845   flagTable[e_bt] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00846   flagTable[e_bts] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00847   flagTable[e_btr] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00848   flagTable[e_btc] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00849   flagTable[e_clc] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::cf));
00850   flagTable[e_cld] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::df));
00851   flagTable[e_cli] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::if_));
00852   flagTable[e_cmc] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::cf));
00853   flagTable[e_cmovbe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00854   flagTable[e_cmove] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00855   flagTable[e_cmovnae] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00856   flagTable[e_cmovnb] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00857   flagTable[e_cmovnbe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00858   flagTable[e_cmovne] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00859   flagTable[e_cmovng] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00860   flagTable[e_cmovnge] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00861   flagTable[e_cmovnl] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00862   flagTable[e_cmovno] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00863   flagTable[e_cmovns] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00864   flagTable[e_cmovo] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00865   flagTable[e_cmovpe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00866   flagTable[e_cmovpo] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00867   flagTable[e_cmovs] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00868   flagTable[e_cmp] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00869   flagTable[e_cmpsb] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00870   flagTable[e_cmpsd] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00871   flagTable[e_cmpss] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00872   flagTable[e_cmpsw] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00873   flagTable[e_cmpxch] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00874   flagTable[e_cmpxch8b] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::zf));
00875   flagTable[e_comisd] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00876   flagTable[e_comiss] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00877   flagTable[e_daa] = flagInfo(list_of(x86::af)(x86::cf), standardFlags);
00878   flagTable[e_das] = flagInfo(list_of(x86::af)(x86::cf), standardFlags);
00879   flagTable[e_dec] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf));
00880   flagTable[e_div] = flagInfo(list_of(x86::af)(x86::cf), standardFlags);
00881   // TODO: FCMOVcc (not in our entry table) (reads zf/pf/cf)
00882   // TODO: FCOMI/FCOMIP/FUCOMI/FUCOMIP (writes/zf/pf/cf)
00883   flagTable[e_idiv] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00884   flagTable[e_imul] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00885   flagTable[e_inc] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf));
00886   flagTable[e_insb] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00887   flagTable[e_insw] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00888   flagTable[e_insd] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00889   flagTable[e_int] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::tf)(x86::nt_));
00890   flagTable[e_int3] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::tf)(x86::nt_));
00891   flagTable[e_int80] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::tf)(x86::nt_));
00892   flagTable[e_into] = flagInfo(list_of(x86::of), list_of(x86::tf)(x86::nt_));
00893   flagTable[e_ucomisd] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00894   flagTable[e_ucomiss] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00895   flagTable[e_iret] = flagInfo(list_of(x86::nt_),
00896 list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf)(x86::cf)(x86::tf)(x86::if_)(x86::df));
00897   flagTable[e_jb] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00898   flagTable[e_jb_jnaej_j] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00899   flagTable[e_jbe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00900   flagTable[e_jl] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00901   flagTable[e_jle] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00902   flagTable[e_jnb] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00903   flagTable[e_jnb_jae_j] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00904   flagTable[e_jnbe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00905   flagTable[e_jnl] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00906   flagTable[e_jnle] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00907   flagTable[e_jno] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00908   flagTable[e_jnp] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00909   flagTable[e_jns] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00910   flagTable[e_jnz] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00911   flagTable[e_jo] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00912   flagTable[e_jp] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00913   flagTable[e_js] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00914   flagTable[e_jz] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00915   flagTable[e_lar] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::zf));
00916   flagTable[e_lodsb] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00917   flagTable[e_lodsd] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00918   flagTable[e_lodsw] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00919   flagTable[e_loope] = flagInfo(list_of(x86::zf), vector<Dyninst::MachRegister>());
00920   flagTable[e_loopn] = flagInfo(list_of(x86::zf), vector<Dyninst::MachRegister>());
00921   flagTable[e_lsl] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::zf));
00922   // I'd expect that mov control/debug/test gets handled when we do operand analysis
00923   // If it doesn't, fix later
00924   flagTable[e_mul] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00925   flagTable[e_neg] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00926   flagTable[e_or] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00927   flagTable[e_outsb] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00928   flagTable[e_outsw] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00929   flagTable[e_outsd] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00930   flagTable[e_popf] = flagInfo(vector<Dyninst::MachRegister>(),
00931 list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf)(x86::cf)(x86::tf)(x86::if_)(x86::df)(x86::nt_));
00932   flagTable[e_popfd] = flagInfo(vector<Dyninst::MachRegister>(),
00933 list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf)(x86::cf)(x86::tf)(x86::if_)(x86::df)(x86::nt_));
00934   flagTable[e_rcl] = flagInfo(list_of(x86::cf), list_of(x86::of)(x86::cf));
00935   flagTable[e_rcr] = flagInfo(list_of(x86::cf), list_of(x86::of)(x86::cf));
00936   flagTable[e_rol] = flagInfo(list_of(x86::cf), list_of(x86::of)(x86::cf));
00937   flagTable[e_ror] = flagInfo(list_of(x86::cf), list_of(x86::of)(x86::cf));
00938   flagTable[e_rsm] = flagInfo(vector<Dyninst::MachRegister>(),
00939 list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::pf)(x86::cf)(x86::tf)(x86::if_)(x86::df)(x86::nt_)(x86::rf));
00940   flagTable[e_sahf] = flagInfo(list_of(x86::sf)(x86::zf)(x86::af)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00941   flagTable[e_sar] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00942   flagTable[e_shr] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00943   flagTable[e_salc] = flagInfo(list_of(x86::cf), vector<Dyninst::MachRegister>());
00944   flagTable[e_sbb] = flagInfo(list_of(x86::cf), standardFlags);
00945   flagTable[e_setb] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00946   flagTable[e_setbe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00947   flagTable[e_setl] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00948   flagTable[e_setle] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00949   flagTable[e_setnb] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00950   flagTable[e_setnbe] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00951   flagTable[e_setnl] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00952   flagTable[e_setnle] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00953   flagTable[e_setno] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00954   flagTable[e_setnp] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00955   flagTable[e_setns] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00956   flagTable[e_setnz] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00957   flagTable[e_seto] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00958   flagTable[e_setp] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00959   flagTable[e_sets] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00960   flagTable[e_setz] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::pf)(x86::cf), vector<Dyninst::MachRegister>());
00961   flagTable[e_shld] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00962   flagTable[e_shrd] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00963   flagTable[e_shl_sal] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00964   flagTable[e_stc] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::cf));
00965   flagTable[e_std] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::df));
00966   flagTable[e_sti] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::if_));
00967   flagTable[e_stosb] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00968   flagTable[e_stosd] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00969   flagTable[e_stosw] = flagInfo(list_of(x86::df), vector<Dyninst::MachRegister>());
00970   flagTable[e_sub] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00971   flagTable[e_test] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00972   flagTable[e_verr] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::zf));
00973   flagTable[e_verw] = flagInfo(vector<Dyninst::MachRegister>(), list_of(x86::zf));
00974   flagTable[e_xadd] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00975   flagTable[e_xor] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00976   flagTable[e_scasb] = flagInfo(list_of(x86::df), standardFlags);
00977   flagTable[e_scasw] = flagInfo(list_of(x86::df), standardFlags);
00978   flagTable[e_scasd] = flagInfo(list_of(x86::df), standardFlags);
00979   flagTable[e_pcmpestri] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00980   flagTable[e_pcmpestrm] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00981   flagTable[e_pcmpistri] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00982   flagTable[e_pcmpistrm] = flagInfo(vector<Dyninst::MachRegister>(), standardFlags);
00983   flagTable[e_popcnt] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::cf)(x86::pf), vector<Dyninst::MachRegister>());
00984   flagTable[e_ptest] = flagInfo(list_of(x86::of)(x86::sf)(x86::zf)(x86::af)(x86::cf)(x86::pf), vector<Dyninst::MachRegister>());
00985 }
00986 
00987 bool ia32_entry::flagsUsed(std::set<MachRegister>& flagsRead, std::set<MachRegister>& flagsWritten, ia32_locations* locs)
00988 {
00989   dyn_hash_map<entryID, flagInfo>::const_iterator found = ia32_instruction::getFlagTable().find(getID(locs));
00990   if(found == ia32_instruction::getFlagTable().end())
00991   {
00992     return false;
00993   }
00994   // No entries for something that touches no flags, so always return true if we had an entry
00995 
00996   copy((found->second).readFlags.begin(), (found->second).readFlags.end(), inserter(flagsRead, flagsRead.begin()));
00997   copy((found->second).writtenFlags.begin(), (found->second).writtenFlags.end(), inserter(flagsWritten,flagsWritten.begin()));
00998   return true;
00999 }
01000 
01001 
01002 
01003 // Modded table entry for push/pop, daa, das, aaa, aas, insb/w/d, outsb/w/d, xchg, cbw
01004 // les, lds, aam, aad, loop(z/nz), cmpxch, lss, mul, imul, div, idiv, cmpxch8, [ld/st]mxcsr
01005 // clflush, prefetch*
01006 
01007 
01008 // oneByteMap: one byte opcode map
01009 static ia32_entry oneByteMap[256] = {
01010   /* 00 */
01011   { e_add,  t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2R },
01012   { e_add,  t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01013   { e_add,  t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01014   { e_add,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01015   { e_add,  t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01016   { e_add,  t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01017   { e_push, t_done, 0, false, { ES, eSP, Zz }, 0, s1R2RW }, // Semantics rewritten to ignore stack "operand"
01018   { e_pop,  t_done, 0, false, { ES, eSP, Zz }, 0, s1W2RW },
01019   /* 08 */
01020   { e_or,   t_done, 0, 
01021 true, { Eb, Gb, Zz }, 0, s1RW2R },
01022   { e_or,   t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01023   { e_or,   t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01024   { e_or,   t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01025   { e_or,   t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01026   { e_or,   t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01027   { e_push, t_done, 0, false, { CS, eSP, Zz }, 0, s1R2RW },
01028   { e_No_Entry,      t_twoB, 0, false, { Zz, Zz, Zz }, 0, 0 },
01029   /* 10 */
01030   { e_adc,  t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2R },
01031   { e_adc,  t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01032   { e_adc,  t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01033   { e_adc,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01034   { e_adc,  t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01035   { e_adc,  t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01036   { e_push, t_done, 0, false, { SS, eSP, Zz }, 0, s1R2RW },
01037   { e_pop,  t_done, 0, false, { SS, eSP, Zz }, 0, s1W2RW },
01038   /* 18 */
01039   { e_sbb,  t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2R },
01040   { e_sbb,  t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01041   { e_sbb,  t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01042   { e_sbb,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01043   { e_sbb,  t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01044   { e_sbb,  t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01045   { e_push, t_done, 0, false, { DS, eSP, Zz }, 0, s1R2RW },
01046   { e_pop , t_done, 0, false, { DS, eSP, Zz }, 0, s1W2RW },
01047   /* 20 */
01048   { e_and, t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2R },
01049   { e_and, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01050   { e_and, t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01051   { e_and, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01052   { e_and, t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01053   { e_and, t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01054   { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_SEG_OVR
01055   { e_daa, t_done, 0, false, { AL, Zz, Zz }, 0, s1RW },
01056   /* 28 */
01057   { e_sub, t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2R },
01058   { e_sub, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01059   { e_sub, t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01060   { e_sub, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01061   { e_sub, t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01062   { e_sub, t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01063   { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_SEG_OVR
01064   { e_das , t_done, 0, false, { AL, Zz, Zz }, 0, s1RW },
01065   /* 30 */
01066   { e_xor, t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2R },
01067   { e_xor, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01068   { e_xor, t_done, 0, true, { Gb, Eb, Zz }, 0, s1RW2R },
01069   { e_xor, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01070   { e_xor, t_done, 0, false, { AL, Ib, Zz }, 0, s1RW2R },
01071   { e_xor, t_done, 0, false, { eAX, Iz, Zz }, 0, s1RW2R },
01072   { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_SEG_OVR
01073   { e_aaa, t_done, 0, false, { AX, Zz, Zz }, 0, s1RW },
01074   /* 38 */
01075   { e_cmp, t_done, 0, true, { Eb, Gb, Zz }, 0, s1R2R },
01076   { e_cmp, t_done, 0, true, { Ev, Gv, Zz }, 0, s1R2R },
01077   { e_cmp, t_done, 0, true, { Gb, Eb, Zz }, 0, s1R2R },
01078   { e_cmp, t_done, 0, true, { Gv, Ev, Zz }, 0, s1R2R },
01079   { e_cmp, t_done, 0, false, { AL, Ib, Zz }, 0, s1R2R },
01080   { e_cmp, t_done, 0, false, { eAX, Iz, Zz }, 0, s1R2R },
01081   { e_No_Entry,     t_ill,  0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_SEG_OVR
01082   { e_aas, t_done, 0, false, { AX, Zz, Zz }, 0, s1RW },
01083   /* 40 */
01084   { e_inc, t_done, 0, false, { eAX, Zz, Zz }, 0, s1RW },
01085   { e_inc, t_done, 0, false, { eCX, Zz, Zz }, 0, s1RW },
01086   { e_inc, t_done, 0, false, { eDX, Zz, Zz }, 0, s1RW },
01087   { e_inc, t_done, 0, false, { eBX, Zz, Zz }, 0, s1RW },
01088   { e_inc, t_done, 0, false, { eSP, Zz, Zz }, 0, s1RW },
01089   { e_inc, t_done, 0, false, { eBP, Zz, Zz }, 0, s1RW },
01090   { e_inc, t_done, 0, false, { eSI, Zz, Zz }, 0, s1RW },
01091   { e_inc, t_done, 0, false, { eDI, Zz, Zz }, 0, s1RW },
01092   /* 48 */
01093   { e_dec, t_done, 0, false, { eAX, Zz, Zz }, 0, s1RW },
01094   { e_dec, t_done, 0, false, { eCX, Zz, Zz }, 0, s1RW },
01095   { e_dec, t_done, 0, false, { eDX, Zz, Zz }, 0, s1RW },
01096   { e_dec, t_done, 0, false, { eBX, Zz, Zz }, 0, s1RW },
01097   { e_dec, t_done, 0, false, { eSP, Zz, Zz }, 0, s1RW },
01098   { e_dec, t_done, 0, false, { eBP, Zz, Zz }, 0, s1RW },
01099   { e_dec, t_done, 0, false, { eSI, Zz, Zz }, 0, s1RW },
01100   { e_dec, t_done, 0, false, { eDI, Zz, Zz }, 0, s1RW },
01101   /* 50 */
01102   { e_push, t_done, 0, false, { rAX, eSP, Zz }, 0, s1R2RW },
01103   { e_push, t_done, 0, false, { rCX, eSP, Zz }, 0, s1R2RW },
01104   { e_push, t_done, 0, false, { rDX, eSP, Zz }, 0, s1R2RW },
01105   { e_push, t_done, 0, false, { rBX, eSP, Zz }, 0, s1R2RW },
01106   { e_push, t_done, 0, false, { rSP, eSP, Zz }, 0, s1R2RW },
01107   { e_push, t_done, 0, false, { rBP, eSP, Zz }, 0, s1R2RW },
01108   { e_push, t_done, 0, false, { rSI, eSP, Zz }, 0, s1R2RW },
01109   { e_push, t_done, 0, false, { rDI, eSP, Zz }, 0, s1R2RW },
01110   /* 58 */
01111   { e_pop, t_done, 0, false, { rAX, eSP, Zz }, 0, s1W2RW },
01112   { e_pop, t_done, 0, false, { rCX, eSP, Zz }, 0, s1W2RW },
01113   { e_pop, t_done, 0, false, { rDX, eSP, Zz }, 0, s1W2RW },
01114   { e_pop, t_done, 0, false, { rBX, eSP, Zz }, 0, s1W2RW },
01115   { e_pop, t_done, 0, false, { rSP, eSP, Zz }, 0, s1W2RW },
01116   { e_pop, t_done, 0, false, { rBP, eSP, Zz }, 0, s1W2RW },
01117   { e_pop, t_done, 0, false, { rSI, eSP, Zz }, 0, s1W2RW },
01118   { e_pop, t_done, 0, false, { rDI, eSP, Zz }, 0, s1W2RW },
01119   /* 60 */
01120   { e_pushad, t_done, 0, false, { GPRS, eSP, Zz }, 0, s1R2RW },
01121   { e_popad,  t_done, 0, false, { GPRS, eSP, Zz }, 0, s1W2RW },
01122   { e_bound,    t_done, 0, true, { Gv, Ma, Zz }, 0, s1R2R },
01123   { e_arpl,     t_done, 0, true, { Ew, Gw, Zz }, 0, s1R2R },
01124   { e_No_Entry,          t_ill,  0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_SEG_OVR
01125   { e_No_Entry,          t_ill,  0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_SEG_OVR
01126   { e_No_Entry,   t_prefixedSSE, 2, false, { Zz, Zz, Zz }, 0, 0 }, /* operand size prefix (PREFIX_OPR_SZ)*/
01127   { e_No_Entry,          t_ill,  0, false, { Zz, Zz, Zz }, 0, 0 }, /* address size prefix (PREFIX_ADDR_SZ)*/
01128   /* 68 */
01129   { e_push,    t_done, 0, false, { Iz, eSP, Zz }, 0, s1R2RW },
01130   { e_imul,    t_done, 0, true, { Gv, Ev, Iz }, 0, s1W2R3R },
01131   { e_push,    t_done, 0, false, { Ib, eSP, Zz }, 0, s1R2RW },
01132   { e_imul,    t_done, 0, true, { Gv, Ev, Ib }, 0, s1W2R3R },
01133   { e_insb,    t_done, 0, false, { Yb, DX, Zz }, 0, s1W2R | (fREP << FPOS) }, // (e)SI/DI changed
01134   { e_insd,  t_done, 0, false, { Yv, DX, Zz }, 0, s1W2R | (fREP << FPOS) },
01135   { e_outsb,   t_done, 0, false, { DX, Xb, Zz }, 0, s1W2R | (fREP << FPOS) },
01136   { e_outsd, t_done, 0, false, { DX, Xv, Zz }, 0, s1W2R | (fREP << FPOS) },
01137   /* 70 */
01138   { e_jo,         t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01139   { e_jno,        t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01140   { e_jb_jnaej_j, t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01141   { e_jnb_jae_j,  t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01142   { e_jz,         t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01143   { e_jnz,        t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01144   { e_jbe,        t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01145   { e_jnbe,       t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01146   /* 78 */
01147   { e_js,   t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01148   { e_jns,  t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01149   { e_jp,   t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01150   { e_jnp,  t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01151   { e_jl,   t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01152   { e_jnl,  t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01153   { e_jle,  t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01154   { e_jnle, t_done, 0, false, { Jb, Zz, Zz }, (IS_JCC | REL_B), s1R },
01155   /* 80 */
01156   { e_No_Entry, t_grp, Grp1a, true, { Zz, Zz, Zz }, 0, 0 },
01157   { e_No_Entry, t_grp, Grp1b, true, { Zz, Zz, Zz }, 0, 0 },
01158   { e_No_Entry, t_grp, Grp1c, true, { Zz, Zz, Zz }, 0, 0 }, // book says Grp1 however;sandpile.org agrees.
01159   { e_No_Entry, t_grp, Grp1d, true, { Zz, Zz, Zz }, 0, 0 },
01160   { e_test, t_done, 0, true, { Eb, Gb, Zz }, 0, s1R2R },
01161   { e_test, t_done, 0, true, { Ev, Gv, Zz }, 0, s1R2R },
01162   { e_xchg, t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2RW },
01163   { e_xchg, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2RW },
01164   /* 88 */
01165   { e_mov, t_done, 0, true, { Eb, Gb, Zz }, 0, s1W2R },
01166   { e_mov, t_done, 0, true, { Ev, Gv, Zz }, 0, s1W2R },
01167   { e_mov, t_done, 0, true, { Gb, Eb, Zz }, 0, s1W2R },
01168   { e_mov, t_done, 0, true, { Gv, Ev, Zz }, 0, s1W2R },
01169   { e_mov, t_done, 0, true, { Ew, Sw, Zz }, 0, s1W2R },
01170   { e_lea, t_done, 0, true, { Gv, Mlea, Zz }, IS_NOP, s1W2R }, // this is just M in the book
01171                                                         // AFAICT the 2nd operand is not accessed
01172   { e_mov, t_done, 0, true, { Sw, Ew, Zz }, 0, s1W2R },
01173   { e_pop, t_done, 0, true, { Ev, eSP, Zz }, 0, s1W2RW },
01174   /* 90 */
01175   { e_nop,  t_done, 0, false, { Zz, Zz, Zz }, IS_NOP, sNONE }, // actually xchg eax,eax
01176   { e_xchg, t_done, 0, false, { eCX, eAX, Zz }, 0, s1RW2RW },
01177   { e_xchg, t_done, 0, false, { eDX, eAX, Zz }, 0, s1RW2RW },
01178   { e_xchg, t_done, 0, false, { eBX, eAX, Zz }, 0, s1RW2RW },
01179   { e_xchg, t_done, 0, false, { eSP, eAX, Zz }, 0, s1RW2RW },
01180   { e_xchg, t_done, 0, false, { eBP, eAX, Zz }, 0, s1RW2RW },
01181   { e_xchg, t_done, 0, false, { eSI, eAX, Zz }, 0, s1RW2RW },
01182   { e_xchg, t_done, 0, false, { eDI, eAX, Zz }, 0, s1RW2RW },
01183   /* 98 */
01184   { e_cwde, t_done, 0, false, { eAX, Zz, Zz }, 0, s1RW },
01185   { e_cdq,  t_done, 0, false, { eDX, eAX, Zz }, 0, s1W2R },
01186   { e_call,     t_done, 0, false, { Ap, Zz, Zz }, IS_CALL | PTR_WX, s1R },
01187   { e_wait,     t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01188   { e_pushfd, t_done, 0, false, { Fv, eSP, Zz }, 0, s1R2RW },
01189   { e_popfd,  t_done, 0, false, { Fv, eSP, Zz }, 0, s1W2RW },
01190   { e_sahf,     t_done, 0, false, { Zz, Zz, Zz }, 0, 0 }, // FIXME Intel
01191   { e_lahf,     t_done, 0, false, { Zz, Zz, Zz }, 0, 0 }, // FIXME Intel
01192   /* A0 */
01193   { e_mov,   t_done, 0, false, { AL, Ob, Zz },  0, s1W2R },
01194   { e_mov,   t_done, 0, false, { eAX, Ov, Zz }, 0, s1W2R },
01195   { e_mov,   t_done, 0, false, { Ob, AL, Zz },  0, s1W2R },
01196   { e_mov,   t_done, 0, false, { Ov, eAX, Zz }, 0, s1W2R },
01197   // XXX: Xv is source, Yv is destination for movs, so they're swapped!
01198   { e_movsb, t_done, 0, false, { Yb, Xb, Zz },  0, s1W2R | (fREP << FPOS) }, // (e)SI/DI changed
01199   { e_movsd, t_done, 0, false, { Yv, Xv, Zz }, 0, s1W2R | (fREP << FPOS) },
01200   { e_cmpsb, t_done, 0, false, { Xb, Yb, Zz },  0, s1R2R | (fCMPS << FPOS) },
01201   { e_cmpsw, t_done, 0, false, { Xv, Yv, Zz },  0, s1R2R | (fCMPS << FPOS) },
01202   /* A8 */
01203   { e_test,     t_done, 0, false, { AL, Ib, Zz },  0, s1R2R },
01204   { e_test,     t_done, 0, false, { eAX, Iz, Zz }, 0, s1R2R },
01205   { e_stosb,    t_done, 0, false, { Yb, AL, Zz },  0, s1W2R | (fREP << FPOS) },
01206   { e_stosd,  t_done, 0, false, { Yv, eAX, Zz }, 0, s1W2R | (fREP << FPOS) },
01207   { e_lodsb,    t_done, 0, false, { AL, Xb, Zz },  0, s1W2R | (fREP << FPOS) },
01208   { e_lodsd,    t_done, 0, false, { eAX, Xv, Zz }, 0, s1W2R | (fREP << FPOS) },
01209   { e_scasb,    t_done, 0, false, { AL, Yb, Zz },  0, s1R2R | (fSCAS << FPOS) },
01210   { e_scasd,  t_done, 0, false, { eAX, Yv, Zz }, 0, s1R2R | (fSCAS << FPOS) },
01211   /* B0 */
01212   { e_mov, t_done, 0, false, { AL, Ib, Zz }, 0, s1W2R },
01213   { e_mov, t_done, 0, false, { CL, Ib, Zz }, 0, s1W2R },
01214   { e_mov, t_done, 0, false, { DL, Ib, Zz }, 0, s1W2R },
01215   { e_mov, t_done, 0, false, { BL, Ib, Zz }, 0, s1W2R },
01216   { e_mov, t_done, 0, false, { AH, Ib, Zz }, 0, s1W2R },
01217   { e_mov, t_done, 0, false, { CH, Ib, Zz }, 0, s1W2R },
01218   { e_mov, t_done, 0, false, { DH, Ib, Zz }, 0, s1W2R },
01219   { e_mov, t_done, 0, false, { BH, Ib, Zz }, 0, s1W2R },
01220   /* B8 */
01221   { e_mov, t_done, 0, false, { eAX, Iv, Zz }, 0, s1W2R },
01222   { e_mov, t_done, 0, false, { eCX, Iv, Zz }, 0, s1W2R },
01223   { e_mov, t_done, 0, false, { eDX, Iv, Zz }, 0, s1W2R },
01224   { e_mov, t_done, 0, false, { eBX, Iv, Zz }, 0, s1W2R },
01225   { e_mov, t_done, 0, false, { eSP, Iv, Zz }, 0, s1W2R },
01226   { e_mov, t_done, 0, false, { eBP, Iv, Zz }, 0, s1W2R },
01227   { e_mov, t_done, 0, false, { eSI, Iv, Zz }, 0, s1W2R },
01228   { e_mov, t_done, 0, false, { eDI, Iv, Zz }, 0, s1W2R },
01229   /* C0 */
01230   { e_No_Entry, t_grp, Grp2, true, { Eb, Ib, Zz }, 0, s1RW2R },
01231   { e_No_Entry, t_grp, Grp2, true, { Ev, Ib, Zz }, 0, s1RW2R },
01232   { e_ret_near, t_done, 0, false, { Iw, Zz, Zz }, (IS_RET | IS_RETC), s1R | (fNEARRET << FPOS) },
01233   { e_ret_near, t_done, 0, false, { Zz, Zz, Zz }, (IS_RET), fNEARRET << FPOS },
01234   { e_les,      t_done, 0, true, { ES, Gv, Mp }, 0, s1W2W3R },
01235   { e_lds,      t_done, 0, true, { DS, Gv, Mp }, 0, s1W2W3R },
01236   { e_No_Entry, t_grp, Grp11, true, { Eb, Ib, Zz }, 0, s1W2R },
01237   { e_No_Entry, t_grp, Grp11, true, { Ev, Iz, Zz }, 0, s1W2R },
01238   /* C8 */
01239   { e_enter,   t_done, 0, false, { Iw, Ib, Zz }, 0, s1R2R | (fENTER << FPOS) },
01240   { e_leave,   t_done, 0, false, { Zz, Zz, Zz }, 0, fLEAVE << FPOS },
01241   { e_ret_far, t_done, 0, false, { Iw, Zz, Zz }, (IS_RETF | IS_RETC), s1R | (fFARRET << FPOS) },
01242   { e_ret_far, t_done, 0, false, { Zz, Zz, Zz }, (IS_RETF), fFARRET << FPOS },
01243   { e_int3,   t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01244   { e_int,     t_done, 0, false, { Ib, Zz, Zz }, 0, s1R },
01245   { e_into,    t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01246   { e_iret,    t_done, 0, false, { Zz, Zz, Zz }, (IS_RET), fIRET << FPOS},
01247   /* D0 */
01248   { e_No_Entry, t_grp, Grp2, true, { Eb, ImplImm, Zz }, 0, s1RW2R }, // const1
01249   { e_No_Entry, t_grp, Grp2, true, { Ev, ImplImm, Zz }, 0, s1RW2R }, // --"--
01250   { e_No_Entry, t_grp, Grp2, true, { Eb, CL, Zz }, 0, s1RW2R },
01251   { e_No_Entry, t_grp, Grp2, true, { Ev, CL, Zz }, 0, s1RW2R },
01252   { e_aam,  t_done, 0, false, { AX, Ib, Zz }, 0, s1RW2R },
01253   { e_aad,  t_done, 0, false, { AX, Ib, Zz }, 0, s1RW2R },
01254   { e_salc, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE }, // undocumeted
01255   { e_xlat, t_done, 0, false, { Zz, Zz, Zz }, 0, fXLAT << FPOS }, // scream
01256   /* D8 */
01257   { e_No_Entry, t_coprocEsc, GrpD8, true, { Zz, Zz, Zz }, 0, 0 },
01258   { e_No_Entry, t_coprocEsc, GrpD9, true, { Zz, Zz, Zz }, 0, 0 },
01259   { e_No_Entry, t_coprocEsc, GrpDA, true, { Zz, Zz, Zz }, 0, 0 },
01260   { e_No_Entry, t_coprocEsc, GrpDB, true, { Zz, Zz, Zz }, 0, 0 },
01261   { e_No_Entry, t_coprocEsc, GrpDC, true, { Zz, Zz, Zz }, 0, 0 },
01262   { e_No_Entry, t_coprocEsc, GrpDD, true, { Zz, Zz, Zz }, 0, 0 },
01263   { e_No_Entry, t_coprocEsc, GrpDE, true, { Zz, Zz, Zz }, 0, 0 },
01264   { e_No_Entry, t_coprocEsc, GrpDF, true, { Zz, Zz, Zz }, 0, 0 },
01265   /* E0 */
01266   { e_loopn,    t_done, 0, false, { Jb, eCX, Zz }, (IS_JCC | REL_B), s1R2R }, 
01267   { e_loope,    t_done, 0, false, { Jb, eCX, Zz }, (IS_JCC | REL_B), s1R2R },
01268   { e_loop,     t_done, 0, false, { Jb, eCX, Zz }, (IS_JCC | REL_B), s1R2R },
01269   { e_jcxz_jec, t_done, 0, false, { Jb, eCX, Zz }, (IS_JCC | REL_B), s1R2R },
01270   { e_in,       t_done, 0, false, { AL, Ib, Zz }, 0, s1W2R | (fIO << FPOS) },
01271   { e_in,       t_done, 0, false, { eAX, Ib, Zz }, 0, s1W2R | (fIO << FPOS) },
01272   { e_out,      t_done, 0, false, { Ib, AL, Zz }, 0, s1W2R | (fIO << FPOS) },
01273   { e_out,      t_done, 0, false, { Ib, eAX, Zz }, 0, s1W2R | (fIO << FPOS) },
01274   /* E8 */
01275   { e_call, t_done, 0, false, { Jz, Zz, Zz }, (IS_CALL | REL_X), s1R | (fCALL << FPOS) },
01276   { e_jmp,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JUMP | REL_X), s1R },
01277   { e_jmp,  t_done, 0, false, { Ap, Zz, Zz }, (IS_JUMP | PTR_WX), s1R },
01278   { e_jmp,  t_done, 0, false, { Jb, Zz, Zz }, (IS_JUMP | REL_B), s1R },
01279   { e_in,   t_done, 0, false, { AL, DX, Zz }, 0, s1W2R | (fIO << FPOS) },
01280   { e_in,   t_done, 0, false, { eAX, DX, Zz }, 0, s1W2R | (fIO << FPOS) },
01281   { e_out,  t_done, 0, false, { DX, AL, Zz }, 0, s1W2R | (fIO << FPOS) },
01282   { e_out,  t_done, 0, false, { DX, eAX, Zz }, 0, s1W2R | (fIO << FPOS) },
01283   /* F0 */
01284   { e_No_Entry,      t_ill,  0, false, { Zz, Zz, Zz }, 0, 0 }, // PREFIX_INSTR
01285   { e_int1, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE }, // undocumented
01286   { e_No_Entry, t_prefixedSSE, 3, false, { Zz, Zz, Zz }, 0, 0 },
01287   { e_No_Entry, t_prefixedSSE, 1, false, { Zz, Zz, Zz }, 0, 0 },
01288   { e_hlt,  t_done, 0, false, { Zz, Zz, Zz }, PRVLGD, sNONE },
01289   { e_cmc,  t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01290   { e_No_Entry, t_grp, Grp3a, true, { Zz, Zz, Zz }, 0, sNONE },
01291   { e_No_Entry, t_grp, Grp3b, true, { Zz, Zz, Zz }, 0, sNONE },
01292   /* F8 */
01293   { e_clc, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01294   { e_stc, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01295   { e_cli, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01296   { e_sti, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01297   { e_cld, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01298   { e_std, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01299   { e_No_Entry, t_grp, Grp4, true, { Zz, Zz, Zz }, 0, sNONE },
01300   { e_No_Entry, t_grp, Grp5, true, { Zz, Zz, Zz }, 0, sNONE }
01301 };
01302 
01303 
01304 // twoByteMap: two byte opcode instructions (first byte is 0x0F)
01305 static ia32_entry twoByteMap[256] = {
01306   /* 00 */
01307   // Syscall/sysret are somewhat hacked
01308   // Syscall on amd64 will also read CS/SS for where to call in 32-bit mode
01309   { e_No_Entry, t_grp, Grp6, true, { Zz, Zz, Zz }, 0, 0 },
01310   { e_No_Entry, t_grp, Grp7, false, { Zz, Zz, Zz }, 0, 0 },
01311   { e_lar,        t_done, 0, true, { Gv, Ew, Zz }, 0, s1W2R | (fSEGDESC << FPOS) },
01312   { e_lsl,        t_done, 0, true, { Gv, Ew, Zz }, 0, s1W2R | (fSEGDESC << FPOS) },
01313   { e_No_Entry,    t_ill, 0, false, { Zz, Zz, Zz }, 0, 0},
01314   { e_syscall,    t_done, 0, false, { eCX, Zz, Zz }, 0, s1W }, // AMD: writes return address to eCX; for liveness, treat as hammering all
01315   { e_clts,       t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01316   { e_sysret,     t_done, 0, false, { eCX, Zz, Zz }, 0, s1R }, // AMD; reads return address from eCX; unlikely to occur in Dyninst use cases but we'll be paranoid
01317   /* 08 */
01318   { e_invd,   t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE }, // only in priviledge 0, so ignored
01319   { e_wbinvd, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE }, // idem
01320   { e_No_Entry,        t_ill,  0, false, { Zz, Zz, Zz }, 0, 0 },
01321   { e_ud2,    t_ill,  0, 0, { Zz, Zz, Zz }, 0, 0 },
01322   { e_No_Entry,        t_ill,  0, 0, { Zz, Zz, Zz }, 0, 0 },
01323   { e_prefetch_w, t_grp, GrpAMD, true, { Zz, Zz, Zz }, 0, 0 },    // AMD prefetch group
01324   { e_femms,       t_done,  0, false, { Zz, Zz, Zz }, 0, sNONE },  // AMD specific
01325   // semantic is bogus for the 1st operand - but correct for the 2nd,
01326   // which is the only one that can be a memory operand :)
01327   // fixing the 1st operand requires an extra table for the 3dnow instructions...
01328   { e_No_Entry,             t_3dnow, 0, true,  { Pq, Qq, Zz }, 0, s1RW2R }, // AMD 3DNow! suffixes
01329   /* 10 */
01330   { e_No_Entry, t_sse, SSE10, true, { Zz, Zz, Zz }, 0, 0 },
01331   { e_No_Entry, t_sse, SSE11, true, { Zz, Zz, Zz }, 0, 0 },
01332   { e_No_Entry, t_sse, SSE12, true, { Zz, Zz, Zz }, 0, 0 },
01333   { e_No_Entry, t_sse, SSE13, true, { Zz, Zz, Zz }, 0, 0 },
01334   { e_No_Entry, t_sse, SSE14, true, { Zz, Zz, Zz }, 0, 0 },
01335   { e_No_Entry, t_sse, SSE15, true, { Zz, Zz, Zz }, 0, 0 },
01336   { e_No_Entry, t_sse, SSE16, true, { Zz, Zz, Zz }, 0, 0 },
01337   { e_No_Entry, t_sse, SSE17, true, { Zz, Zz, Zz }, 0, 0 },
01338   /* 18 */
01339   { e_No_Entry, t_grp, Grp16, 0, { Zz, Zz, Zz }, 0, 0 },
01340   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 }, // 19-1F according to sandpile and AMD are NOPs with an Ev operand
01341   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 }, // Can we go out on a limb that the 'operand' of a NOP is never read?
01342   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 }, // I think we can...so nullary operand semantics, but consume the
01343   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 }, // mod/rm byte operand.
01344   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 }, // -- BW 1/08
01345   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 },
01346   { e_nop, t_done, 0, true, { Ev, Zz, Zz }, IS_NOP, 0 },
01347   /* 20 */
01348   { e_mov, t_done, 0, true, { Rd, Cd, Zz }, 0, s1W2R },
01349   { e_mov, t_done, 0, true, { Rd, Dd, Zz }, 0, s1W2R },
01350   { e_mov, t_done, 0, true, { Cd, Rd, Zz }, 0, s1W2R },
01351   { e_mov, t_done, 0, true, { Dd, Rd, Zz }, 0, s1W2R },
01352   { e_mov, t_done, 0, true, { Rd, Td, Zz }, 0, s1W2R }, // actually a SSE5A
01353   { e_No_Entry,     t_ill,  0, 0, { Zz, Zz, Zz }, 0, 0 }, // SSE5A
01354   { e_mov, t_done, 0, true, { Td, Rd, Zz }, 0, s1W2R },
01355   { e_No_Entry,     t_ill,  0, 0, { Zz, Zz, Zz }, 0, 0 },
01356   /* 28 */
01357   { e_No_Entry, t_sse, SSE28, true, { Zz, Zz, Zz }, 0, 0 },
01358   { e_No_Entry, t_sse, SSE29, true, { Zz, Zz, Zz }, 0, 0 },
01359   { e_No_Entry, t_sse, SSE2A, true, { Zz, Zz, Zz }, 0, 0 },
01360   { e_No_Entry, t_sse, SSE2B, true, { Zz, Zz, Zz }, 0, 0 },
01361   { e_No_Entry, t_sse, SSE2C, true, { Zz, Zz, Zz }, 0, 0 },
01362   { e_No_Entry, t_sse, SSE2D, true, { Zz, Zz, Zz }, 0, 0 },
01363   { e_No_Entry, t_sse, SSE2E, true, { Zz, Zz, Zz }, 0, 0 },
01364   { e_No_Entry, t_sse, SSE2F, true, { Zz, Zz, Zz }, 0, 0 },
01365   /* 30 */
01366   { e_wrmsr, t_done, 0, false, { rAX, rDX, rCX }, 0, s1R2R3R },
01367   { e_rdtsc, t_done, 0, false, { rAX, rDX, Zz }, 0, s1W2W3R },
01368   { e_rdmsr, t_done, 0, false, { rAX, rDX, rCX }, 0, s1W2W3R },
01369   { e_rdpmc, t_done, 0, false, { rAX, rDX, rCX }, 0, s1W2W3R },
01370   { e_sysenter, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE }, // XXX: fixme for kernel work
01371   { e_sysexit,  t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE }, // XXX: fixme for kernel work
01372   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0, 0 }, 
01373   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01374   /* 38 */
01375   { e_No_Entry, t_threeB, 0, 0, { Zz, Zz, Zz }, 0, 0 }, //3-Byte escape (Book Table A-4)
01376   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01377   { e_No_Entry, t_threeB2, 0, 0, { Zz, Zz, Zz }, 0, 0 }, //3-Byte escape (Book Table A-5)
01378   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01379   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01380   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01381   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01382   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0 ,0 },
01383   /* 40 */
01384   { e_cmovo,   t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01385   { e_cmovno,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01386   { e_cmovnae, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01387   { e_cmovnb,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01388   { e_cmove,   t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01389   { e_cmovne,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01390   { e_cmovbe,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01391   { e_cmovnbe, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01392   /* 48 */
01393   { e_cmovs,   t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01394   { e_cmovns,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01395   { e_cmovpe,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01396   { e_cmovpo,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01397   { e_cmovnge, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01398   { e_cmovnl,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01399   { e_cmovng,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01400   { e_cmovnl,  t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R | (fCOND << FPOS) },
01401   /* 50 */
01402   { e_No_Entry, t_sse, SSE50, true, { Zz, Zz, Zz }, 0, 0 },
01403   { e_No_Entry, t_sse, SSE51, true, { Zz, Zz, Zz }, 0, 0 },
01404   { e_No_Entry, t_sse, SSE52, true, { Zz, Zz, Zz }, 0, 0 },
01405   { e_No_Entry, t_sse, SSE53, true, { Zz, Zz, Zz }, 0, 0 },
01406   { e_No_Entry, t_sse, SSE54, true, { Zz, Zz, Zz }, 0, 0 },
01407   { e_No_Entry, t_sse, SSE55, true, { Zz, Zz, Zz }, 0, 0 },
01408   { e_No_Entry, t_sse, SSE56, true, { Zz, Zz, Zz }, 0, 0 },
01409   { e_No_Entry, t_sse, SSE57, true, { Zz, Zz, Zz }, 0, 0 },
01410   /* 58 */
01411   { e_No_Entry, t_sse, SSE58, true, { Zz, Zz, Zz }, 0, 0 },
01412   { e_No_Entry, t_sse, SSE59, true, { Zz, Zz, Zz }, 0, 0 },
01413   { e_No_Entry, t_sse, SSE5A, true, { Zz, Zz, Zz }, 0, 0 },
01414   { e_No_Entry, t_sse, SSE5B, true, { Zz, Zz, Zz }, 0, 0 },
01415   { e_No_Entry, t_sse, SSE5C, true, { Zz, Zz, Zz }, 0, 0 },
01416   { e_No_Entry, t_sse, SSE5D, true, { Zz, Zz, Zz }, 0, 0 },
01417   { e_No_Entry, t_sse, SSE5E, true, { Zz, Zz, Zz }, 0, 0 },
01418   { e_No_Entry, t_sse, SSE5F, true, { Zz, Zz, Zz }, 0, 0 },
01419   /* 60 */
01420   { e_No_Entry, t_sse, SSE60, true, { Zz, Zz, Zz }, 0, 0 },
01421   { e_No_Entry, t_sse, SSE61, true, { Zz, Zz, Zz }, 0, 0 },
01422   { e_No_Entry, t_sse, SSE62, true, { Zz, Zz, Zz }, 0, 0 },
01423   { e_No_Entry, t_sse, SSE63, true, { Zz, Zz, Zz }, 0, 0 },
01424   { e_No_Entry, t_sse, SSE64, true, { Zz, Zz, Zz }, 0, 0 },
01425   { e_No_Entry, t_sse, SSE65, true, { Zz, Zz, Zz }, 0, 0 },
01426   { e_No_Entry, t_sse, SSE66, true, { Zz, Zz, Zz }, 0, 0 },
01427   { e_No_Entry, t_sse, SSE67, true, { Zz, Zz, Zz }, 0, 0 },
01428   /* 68 */
01429   { e_No_Entry, t_sse, SSE68, true, { Zz, Zz, Zz }, 0, 0 },
01430   { e_No_Entry, t_sse, SSE69, true, { Zz, Zz, Zz }, 0, 0 },
01431   { e_No_Entry, t_sse, SSE6A, true, { Zz, Zz, Zz }, 0, 0 },
01432   { e_No_Entry, t_sse, SSE6B, true, { Zz, Zz, Zz }, 0, 0 },
01433   { e_No_Entry, t_sse, SSE6C, true, { Zz, Zz, Zz }, 0, 0 },
01434   { e_No_Entry, t_sse, SSE6D, true, { Zz, Zz, Zz }, 0, 0 },
01435   { e_No_Entry, t_sse, SSE6E, true, { Zz, Zz, Zz }, 0, 0 },
01436   { e_No_Entry, t_sse, SSE6F, true, { Zz, Zz, Zz }, 0, 0 },
01437   /* 70 */
01438   { e_No_Entry, t_sse, SSE70, true, { Zz, Zz, Zz }, 0, 0 },
01439   { e_No_Entry, t_grp, Grp12, false, { Zz, Zz, Zz }, 0, 0 },
01440   { e_No_Entry, t_grp, Grp13, false, { Zz, Zz, Zz }, 0, 0 },
01441   { e_No_Entry, t_grp, Grp14, false, { Zz, Zz, Zz }, 0, 0 },
01442   { e_No_Entry, t_sse, SSE74, true, { Zz, Zz, Zz }, 0, 0 },
01443   { e_No_Entry, t_sse, SSE75, true, { Zz, Zz, Zz }, 0, 0 },
01444   { e_No_Entry, t_sse, SSE76, true, { Zz, Zz, Zz }, 0, 0 },
01445   { e_emms, t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01446   /* 78 */
01447   { e_No_Entry, t_sse, SSE78, 0, { Zz, Zz, Zz }, 0, 0 },
01448   { e_No_Entry, t_sse, SSE79, 0, { Zz, Zz, Zz }, 0, 0 },
01449   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0, 0 }, // SSE5A will go in 7A and 7B when it comes out
01450   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0, 0 },
01451   { e_No_Entry, t_sse, SSE7C, 0, { Zz, Zz, Zz }, 0, 0 },
01452   { e_No_Entry, t_sse, SSE7D, 0, { Zz, Zz, Zz }, 0, 0 },
01453   { e_No_Entry, t_sse, SSE7E, 0, { Zz, Zz, Zz }, 0, 0 },
01454   { e_No_Entry, t_sse, SSE7F, 0, { Zz, Zz, Zz }, 0, 0 },
01455   /* 80 */
01456   { e_jo,   t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01457   { e_jno,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01458   { e_jb,   t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01459   { e_jnb,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01460   { e_jz,   t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01461   { e_jnz,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01462   { e_jbe,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01463   { e_jnbe, t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01464   /* 88 */
01465   { e_js,   t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01466   { e_jns,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01467   { e_jp,   t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01468   { e_jnp,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01469   { e_jl,   t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01470   { e_jnl,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01471   { e_jle,  t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01472   { e_jnle, t_done, 0, false, { Jz, Zz, Zz }, (IS_JCC | REL_X), s1R | (fCOND << FPOS) },
01473   /* 90 */
01474   { e_seto,   t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01475   { e_setno,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01476   { e_setb,   t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01477   { e_setnb,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01478   { e_setz,   t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01479   { e_setnz,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01480   { e_setbe,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01481   { e_setnbe, t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01482   /* 98 */
01483   { e_sets,   t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01484   { e_setns,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01485   { e_setp,   t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01486   { e_setnp,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01487   { e_setl,   t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01488   { e_setnl,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01489   { e_setle,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01490   { e_setnle, t_done, 0, true, { Eb, Zz, Zz }, 0, s1W | (fCOND << FPOS) },
01491   /* A0 */
01492   { e_push,   t_done, 0, false, { FS, eSP, Zz }, 0, s1R2RW },
01493   { e_pop,    t_done, 0, false, { FS, eSP, Zz }, 0, s1W2RW },
01494   { e_cpuid,  t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01495   { e_bt,     t_done, 0, true, { Ev, Gv, Zz }, 0, s1R2R },
01496   { e_shld,   t_done, 0, true, { Ev, Gv, Ib }, 0, s1RW2R3R },
01497   { e_shld,   t_done, 0, true, { Ev, Gv, CL }, 0, s1RW2R3R },
01498   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0, 0 }, 
01499   { e_No_Entry, t_ill, 0, 0, { Zz, Zz, Zz }, 0, 0 },
01500   /* A8 */
01501   { e_push, t_done, 0, false, { GS, eSP, Zz }, 0, s1R2RW },
01502   { e_pop,  t_done, 0, false, { GS, eSP, Zz }, 0, s1W2RW },
01503   { e_rsm,  t_done, 0, false, { Zz, Zz, Zz }, 0, sNONE },
01504   { e_bts,  t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01505   { e_shrd, t_done, 0, true, { Ev, Gv, Ib }, 0, s1RW2R3R },
01506   { e_shrd, t_done, 0, true, { Ev, Gv, CL }, 0, s1RW2R3R },
01507   { e_No_Entry, t_grp, Grp15, 0, { Zz, Zz, Zz }, 0, 0 }, 
01508   { e_imul, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
01509   /* B0 */
01510   // Assuming this is used with LOCK prefix, the destination gets a write anyway
01511   // This is not the case without lock prefix, but I ignore that case
01512   // Also, given that the 3rd operand is a register I ignore that it may be written
01513   { e_cmpxch, t_done, 0, true, { Eb, Gb, AL }, 0, s1RW2R3R | (fCMPXCH << FPOS) },
01514   { e_cmpxch, t_done, 0, true, { Ev, Gv, eAX }, 0, s1RW2R3R | (fCMPXCH << FPOS) },
01515   { e_lss, t_done, 0, true, { SS, Gv, Mp }, 0, s1W2W3R },
01516   { e_btr, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01517   { e_lfs, t_done, 0, true, { FS, Gv, Mp }, 0, s1W2W3R },
01518   { e_lgs, t_done, 0, true, { GS, Gv, Mp }, 0, s1W2W3R },
01519   { e_movzx, t_done, 0, true, { Gv, Eb, Zz }, 0, s1W2R },
01520   { e_movzx, t_done, 0, true, { Gv, Ew, Zz }, 0, s1W2R },
01521   /* B8 */
01522   { e_No_Entry, t_sse, SSEB8, 0, { Zz, Zz, Zz }, 0, 0 },
01523   { e_ud2grp10, t_ill, 0, 0, { Zz, Zz, Zz }, 0, sNONE },
01524   { e_No_Entry, t_grp, Grp8, true, { Zz, Zz, Zz }, 0, 0 },
01525   { e_btc, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2R },
01526   { e_bsf, t_done, 0, true, { Gv, Ev, Zz }, 0, s1W2R },
01527   { e_bsr, t_done, 0, true, { Gv, Ev, Zz }, 0, s1W2R },
01528   { e_movsx, t_done, 0, true, { Gv, Eb, Zz }, 0, s1W2R },
01529   { e_movsx, t_done, 0, true, { Gv, Ew, Zz }, 0, s1W2R },
01530   /* C0 */
01531   { e_xadd, t_done, 0, true, { Eb, Gb, Zz }, 0, s1RW2RW },
01532   { e_xadd, t_done, 0, true, { Ev, Gv, Zz }, 0, s1RW2RW },
01533   { e_No_Entry, t_sse, SSEC2, true, { Zz, Zz, Zz }, 0, 0 },
01534   { e_movnti , t_done, 0, true, { Ev, Gv, Zz }, 0, s1W2R | (fNT << FPOS) },
01535   { e_No_Entry, t_sse, SSEC4, true, { Zz, Zz, Zz }, 0, 0 },
01536   { e_No_Entry, t_sse, SSEC5, true, { Zz, Zz, Zz }, 0, 0 },
01537   { e_No_Entry, t_sse, SSEC6, true, { Zz, Zz, Zz }, 0, 0 },
01538   { e_No_Entry, t_grp, Grp9,  true, { Zz, Zz, Zz }, 0, 0 },
01539   /* C8 */
01540   { e_bswap, t_done, 0, false, { EAX, Zz, Zz }, 0, s1RW }, 
01541   { e_bswap, t_done, 0, false, { ECX, Zz, Zz }, 0, s1RW },
01542   { e_bswap, t_done, 0, false, { EDX, Zz, Zz }, 0, s1RW }, 
01543   { e_bswap, t_done, 0, false, { EBX, Zz, Zz }, 0, s1RW }, 
01544   { e_bswap, t_done, 0, false, { ESP, Zz, Zz }, 0, s1RW },
01545   { e_bswap, t_done, 0, false, { EBP, Zz, Zz }, 0, s1RW }, 
01546   { e_bswap, t_done, 0, false, { ESI, Zz, Zz }, 0, s1RW }, 
01547   { e_bswap, t_done, 0, false, { EDI, Zz, Zz }, 0, s1RW }, 
01548   /* D0 */
01549   { e_No_Entry, t_sse, SSED0, false, { Zz, Zz, Zz }, 0, 0 },
01550   { e_No_Entry, t_sse, SSED1, true, { Zz, Zz, Zz }, 0, 0 },
01551   { e_No_Entry, t_sse, SSED2, true, { Zz, Zz, Zz }, 0, 0 },
01552   { e_No_Entry, t_sse, SSED3, true, { Zz, Zz, Zz }, 0, 0 },
01553   { e_No_Entry, t_sse, SSED4, true, { Zz, Zz, Zz }, 0, 0 },
01554   { e_No_Entry, t_sse, SSED5, true, { Zz, Zz, Zz }, 0, 0 },
01555   { e_No_Entry, t_sse, SSED6, true, { Zz, Zz, Zz }, 0, 0 },
01556   { e_No_Entry, t_sse, SSED7, true, { Zz, Zz, Zz }, 0, 0 },
01557   /* D8 */
01558   { e_No_Entry, t_sse, SSED8, true, { Zz, Zz, Zz }, 0, 0 },
01559   { e_No_Entry, t_sse, SSED9, true, { Zz, Zz, Zz }, 0, 0 },
01560   { e_No_Entry, t_sse, SSEDA, true, { Zz, Zz, Zz }, 0, 0 },
01561   { e_No_Entry, t_sse, SSEDB, true, { Zz, Zz, Zz }, 0, 0 },
01562   { e_No_Entry, t_sse, SSEDC, true, { Zz, Zz, Zz }, 0, 0 },
01563   { e_No_Entry, t_sse, SSEDD, true, { Zz, Zz, Zz }, 0, 0 },
01564   { e_No_Entry, t_sse, SSEDE, true, { Zz, Zz, Zz }, 0, 0 },
01565   { e_No_Entry, t_sse, SSEDF, true, { Zz, Zz, Zz }, 0, 0 },
01566   /* E0 */
01567   { e_No_Entry, t_sse, SSEE0, true, { Zz, Zz, Zz }, 0, 0 },
01568   { e_No_Entry, t_sse, SSEE1, true, { Zz, Zz, Zz }, 0, 0 },
01569   { e_No_Entry, t_sse, SSEE2, true, { Zz, Zz, Zz }, 0, 0 },
01570   { e_No_Entry, t_sse, SSEE3, true, { Zz, Zz, Zz }, 0, 0 },
01571   { e_No_Entry, t_sse, SSEE4, true, { Zz, Zz, Zz }, 0, 0 },
01572   { e_No_Entry, t_sse, SSEE5, true, { Zz, Zz, Zz }, 0, 0 },
01573   { e_No_Entry, t_sse, SSEE6, true, { Zz, Zz, Zz }, 0, 0 },
01574   { e_No_Entry, t_sse, SSEE7, true, { Zz, Zz, Zz }, 0, 0 },
01575   /* E8 */
01576   { e_No_Entry, t_sse, SSEE8, true, { Zz, Zz, Zz }, 0, 0 },
01577   { e_No_Entry, t_sse, SSEE9, true, { Zz, Zz, Zz }, 0, 0 },
01578   { e_No_Entry, t_sse, SSEEA, true, { Zz, Zz, Zz }, 0, 0 },
01579   { e_No_Entry, t_sse, SSEEB, true, { Zz, Zz, Zz }, 0, 0 },
01580   { e_No_Entry, t_sse, SSEEC, true, { Zz, Zz, Zz }, 0, 0 },
01581   { e_No_Entry, t_sse, SSEED, true, { Zz, Zz, Zz }, 0, 0 },
01582   { e_No_Entry, t_sse, SSEEE, true, { Zz, Zz, Zz }, 0, 0 },
01583   { e_No_Entry, t_sse, SSEEF, true, { Zz, Zz, Zz }, 0, 0 },
01584   /* F0 */
01585   { e_No_Entry, t_sse, SSEF0, false, { Zz, Zz, Zz }, 0, 0 },
01586   { e_No_Entry, t_sse, SSEF1, true, { Zz, Zz, Zz }, 0, 0 },
01587   { e_No_Entry, t_sse, SSEF2, true, { Zz, Zz, Zz }, 0, 0 },
01588   { e_No_Entry, t_sse, SSEF3, true, { Zz, Zz, Zz }, 0, 0 },
01589   { e_No_Entry, t_sse, SSEF4, true, { Zz, Zz, Zz }, 0, 0 },
01590   { e_No_Entry, t_sse, SSEF5, true, { Zz, Zz, Zz }, 0, 0 },
01591   { e_No_Entry, t_sse, SSEF6, true, { Zz, Zz, Zz }, 0, 0 },
01592   { e_No_Entry, t_sse, SSEF7, true, { Zz, Zz, Zz }, 0, 0 },
01593   /* F8 */
01594   { e_No_Entry, t_sse, SSEF8, true, { Zz, Zz, Zz }, 0, 0 },
01595   { e_No_Entry, t_sse, SSEF9, true, { Zz, Zz, Zz }, 0, 0 },
01596   { e_No_Entry, t_sse, SSEFA, true, { Zz, Zz, Zz }, 0, 0 },
01597   { e_No_Entry, t_sse, SSEFB, true, { Zz, Zz, Zz }, 0, 0 },
01598   { e_No_Entry, t_sse, SSEFC, true, { Zz, Zz, Zz }, 0, 0 },
01599   { e_No_Entry, t_sse, SSEFD, true, { Zz, Zz, Zz }, 0, 0 },
01600   { e_No_Entry, t_sse, SSEFE, true, { Zz, Zz, Zz }, 0, 0 },
01601   { e_No_Entry, t_sse, SSEFF, false, { Zz, Zz, Zz }, 0, 0 }
01602 };
01603 
01604 static ia32_entry threeByteMap[256] = {
01605         /* 00 */
01606         { e_No_Entry, t_sse_bis, SSEB00, true, { Zz, Zz, Zz }, 0, 0 },
01607         { e_No_Entry, t_sse_bis, SSEB01, true, { Zz, Zz, Zz }, 0, 0 },
01608         { e_No_Entry, t_sse_bis, SSEB02, true, { Zz, Zz, Zz }, 0, 0 },
01609         { e_No_Entry, t_sse_bis, SSEB03, true, { Zz, Zz, Zz }, 0, 0 },
01610         { e_No_Entry, t_sse_bis, SSEB04, true, { Zz, Zz, Zz }, 0, 0 },
01611         { e_No_Entry, t_sse_bis, SSEB05, true, { Zz, Zz, Zz }, 0, 0 },
01612         { e_No_Entry, t_sse_bis, SSEB06, true, { Zz, Zz, Zz }, 0, 0 },
01613         { e_No_Entry, t_sse_bis, SSEB07, true, { Zz, Zz, Zz }, 0, 0 },
01614         /* 08*/
01615         { e_No_Entry, t_sse_bis, SSEB08, true, { Zz, Zz, Zz }, 0, 0 },
01616         { e_No_Entry, t_sse_bis, SSEB09, true, { Zz, Zz, Zz }, 0, 0 },
01617         { e_No_Entry, t_sse_bis, SSEB0A, true, { Zz, Zz, Zz }, 0, 0 },
01618         { e_No_Entry, t_sse_bis, SSEB0B, true, { Zz, Zz, Zz }, 0, 0 },
01619         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01620         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01621         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01622         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01623         /* 10 */
01624         { e_No_Entry, t_sse_bis, SSEB10, true, { Zz, Zz, Zz }, 0, 0 },
01625         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01626         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01627         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01628         { e_No_Entry, t_sse_bis, SSEB14, true, { Zz, Zz, Zz }, 0, 0 },
01629         { e_No_Entry, t_sse_bis, SSEB15, true, { Zz, Zz, Zz }, 0, 0 },
01630         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01631         { e_No_Entry, t_sse_bis, SSEB17, true, { Zz, Zz, Zz }, 0, 0 },
01632         /* 18 */
01633         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01634         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01635         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01636         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01637         { e_No_Entry, t_sse_bis, SSEB1C, true, { Zz, Zz, Zz }, 0, 0 },
01638         { e_No_Entry, t_sse_bis, SSEB1D, true, { Zz, Zz, Zz }, 0, 0 },
01639         { e_No_Entry, t_sse_bis, SSEB1E, true, { Zz, Zz, Zz }, 0, 0 },
01640         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01641         /* 20 */
01642         { e_No_Entry, t_sse_bis, SSEB20, true, { Zz, Zz, Zz }, 0, 0 },
01643         { e_No_Entry, t_sse_bis, SSEB21, true, { Zz, Zz, Zz }, 0, 0 },
01644         { e_No_Entry, t_sse_bis, SSEB22, true, { Zz, Zz, Zz }, 0, 0 },
01645         { e_No_Entry, t_sse_bis, SSEB23, true, { Zz, Zz, Zz }, 0, 0 },
01646         { e_No_Entry, t_sse_bis, SSEB24, true, { Zz, Zz, Zz }, 0, 0 },
01647         { e_No_Entry, t_sse_bis, SSEB25, true, { Zz, Zz, Zz }, 0, 0 },
01648         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01649         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01650         /* 28 */
01651         { e_No_Entry, t_sse_bis, SSEB28, true, { Zz, Zz, Zz }, 0, 0 },
01652         { e_No_Entry, t_sse_bis, SSEB29, true, { Zz, Zz, Zz }, 0, 0 },
01653         { e_No_Entry, t_sse_bis, SSEB2A, true, { Zz, Zz, Zz }, 0, 0 },
01654         { e_No_Entry, t_sse_bis, SSEB2B, true, { Zz, Zz, Zz }, 0, 0 },
01655         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01656         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01657         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01658         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01659         /* 30 */
01660         { e_No_Entry, t_sse_bis, SSEB30, true, { Zz, Zz, Zz }, 0, 0 },
01661         { e_No_Entry, t_sse_bis, SSEB31, true, { Zz, Zz, Zz }, 0, 0 },
01662         { e_No_Entry, t_sse_bis, SSEB32, true, { Zz, Zz, Zz }, 0, 0 },
01663         { e_No_Entry, t_sse_bis, SSEB33, true, { Zz, Zz, Zz }, 0, 0 },
01664         { e_No_Entry, t_sse_bis, SSEB34, true, { Zz, Zz, Zz }, 0, 0 },
01665         { e_No_Entry, t_sse_bis, SSEB35, true, { Zz, Zz, Zz }, 0, 0 },
01666         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01667         { e_No_Entry, t_sse_bis, SSEB37, true, { Zz, Zz, Zz }, 0, 0 },
01668         /* 38 */
01669         { e_No_Entry, t_sse_bis, SSEB38, true, { Zz, Zz, Zz }, 0, 0 },
01670         { e_No_Entry, t_sse_bis, SSEB39, true, { Zz, Zz, Zz }, 0, 0 },
01671         { e_No_Entry, t_sse_bis, SSEB3A, true, { Zz, Zz, Zz }, 0, 0 },
01672         { e_No_Entry, t_sse_bis, SSEB3B, true, { Zz, Zz, Zz }, 0, 0 },
01673         { e_No_Entry, t_sse_bis, SSEB3C, true, { Zz, Zz, Zz }, 0, 0 },
01674         { e_No_Entry, t_sse_bis, SSEB3D, true, { Zz, Zz, Zz }, 0, 0 },
01675         { e_No_Entry, t_sse_bis, SSEB3E, true, { Zz, Zz, Zz }, 0, 0 },
01676         { e_No_Entry, t_sse_bis, SSEB3F, true, { Zz, Zz, Zz }, 0, 0 },
01677         /* 40 */
01678         { e_No_Entry, t_sse_bis, SSEB40, true, { Zz, Zz, Zz }, 0, 0 },
01679         { e_No_Entry, t_sse_bis, SSEB41, true, { Zz, Zz, Zz }, 0, 0 },
01680         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01681         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01682         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01683         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01684         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01685         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01686         /* 48 */
01687         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01688         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01689         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01690         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01691         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01692         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01693         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01694         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01695         /* 50 */
01696         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01697         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01698         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01699         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01700         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01701         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01702         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01703         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01704         /* 58 */
01705         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01706         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01707         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01708         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01709         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01710         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01711         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01712         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01713         /* 60 */
01714         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01715         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01716         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01717         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01718         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01719         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01720         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01721         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01722         /* 68 */
01723         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01724         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01725         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01726         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01727         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01728         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01729         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01730         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01731         /* 70 */
01732         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01733         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01734         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01735         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01736         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01737         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01738         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01739         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01740         /* 78 */
01741         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01742         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01743         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01744         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01745         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01746         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01747         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01748         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01749         /* 80 */
01750         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01751         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01752         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01753         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01754         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01755         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01756         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01757         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01758         /* 88 */
01759         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01760         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01761         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01762         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01763         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01764         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01765         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01766         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01767         /* 90 */
01768         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01769         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01770         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01771         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01772         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01773         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01774         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01775         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01776         /* 98 */
01777         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01778         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01779         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01780         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01781         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01782         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01783         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01784         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01785         /* A0 */
01786         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01787         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01788         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01789         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01790         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01791         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01792         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01793         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01794         /* A8 */
01795         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01796         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01797         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01798         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01799         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01800         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01801         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01802         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01803         /* B0 */
01804         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01805         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01806         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01807         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01808         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01809         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01810         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01811         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },  
01812         /* B8 */
01813         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01814         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01815         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01816         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01817         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01818         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01819         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01820         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01821         /* C0 */
01822         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01823         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01824         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01825         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01826         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01827         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01828         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01829         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01830         /* C8 */
01831         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01832         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01833         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01834         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01835         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01836         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01837         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01838         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01839         /* D0 */
01840         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01841         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01842         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01843         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01844         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01845         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01846         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01847         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01848         /* D8 */
01849         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01850         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01851         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01852         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01853         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01854         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01855         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01856         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01857         /* E0 */
01858         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01859         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01860         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01861         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01862         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01863         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01864         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01865         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01866         /* E8 */
01867         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01868         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01869         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01870         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01871         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01872         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01873         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01874         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01875         /* F0 */
01876         { e_No_Entry, t_sse_bis, SSEBF0, true, { Zz, Zz, Zz }, 0, 0 },
01877         { e_No_Entry, t_sse_bis, SSEBF1, true, { Zz, Zz, Zz }, 0, 0 },
01878         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01879         { e_No_Entry, t_grp, Grp17, true, { Zz, Zz, Zz }, 0, 0 },
01880         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01881         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01882         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01883         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01884         /* F8 */
01885         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01886         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01887         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01888         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01889         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01890         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01891         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01892         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
01893 };
01894 
01895 static ia32_entry threeByteMap2[256] = {
01896         /* 00 */
01897         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01898         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01899         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01900         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01901         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01902         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01903         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01904         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01905         /* 08*/
01906         { e_No_Entry, t_sse_ter, SSET08, true, { Zz, Zz, Zz }, 0, 0 },
01907         { e_No_Entry, t_sse_ter, SSET09, true, { Zz, Zz, Zz }, 0, 0 },
01908         { e_No_Entry, t_sse_ter, SSET0A, true, { Zz, Zz, Zz }, 0, 0 },
01909         { e_No_Entry, t_sse_ter, SSET0B, true, { Zz, Zz, Zz }, 0, 0 },
01910         { e_No_Entry, t_sse_ter, SSET0C, true, { Zz, Zz, Zz }, 0, 0 },
01911         { e_No_Entry, t_sse_ter, SSET0D, true, { Zz, Zz, Zz }, 0, 0 },
01912         { e_No_Entry, t_sse_ter, SSET0E, true, { Zz, Zz, Zz }, 0, 0 },
01913         { e_No_Entry, t_sse_ter, SSET0F, true, { Zz, Zz, Zz }, 0, 0 },
01914         /* 10 */
01915         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01916         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01917         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01918         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01919         { e_No_Entry, t_sse_ter, SSET14, true, { Zz, Zz, Zz }, 0, 0 },
01920         { e_No_Entry, t_sse_ter, SSET15, true, { Zz, Zz, Zz }, 0, 0 },
01921         { e_No_Entry, t_sse_ter, SSET16, true, { Zz, Zz, Zz }, 0, 0 },
01922         { e_No_Entry, t_sse_ter, SSET17, true, { Zz, Zz, Zz }, 0, 0 },
01923         /* 18 */
01924         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01925         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01926         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01927         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01928         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01929         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01930         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01931         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01932         /* 20 */
01933         { e_No_Entry, t_sse_ter, SSET20, true, { Zz, Zz, Zz }, 0, 0 },
01934         { e_No_Entry, t_sse_ter, SSET21, true, { Zz, Zz, Zz }, 0, 0 },
01935         { e_No_Entry, t_sse_ter, SSET22, true, { Zz, Zz, Zz }, 0, 0 },
01936         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01937         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01938         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01939         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01940         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01941         /* 28 */
01942         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01943         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01944         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01945         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01946         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01947         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01948         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01949         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01950         /* 30 */
01951         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01952         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01953         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01954         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01955         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01956         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01957         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01958         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01959         /* 38 */
01960         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01961         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01962         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01963         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01964         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01965         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01966         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01967         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01968         /* 40 */
01969         { e_No_Entry, t_sse_ter, SSET40, true, { Zz, Zz, Zz }, 0, 0 },
01970         { e_No_Entry, t_sse_ter, SSET41, true, { Zz, Zz, Zz }, 0, 0 },
01971         { e_No_Entry, t_sse_ter, SSET42, true, { Zz, Zz, Zz }, 0, 0 },
01972         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01973         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01974         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01975         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01976         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01977         /* 48 */
01978         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01979         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01980         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01981         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01982         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01983         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01984         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01985         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01986         /* 50 */
01987         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01988         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01989         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01990         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01991         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01992         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01993         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01994         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01995         /* 58 */
01996         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01997         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01998         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
01999         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02000         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02001         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02002         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02003         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02004         /* 60 */
02005         { e_No_Entry, t_sse_ter, SSET60, true, { Zz, Zz, Zz }, 0, 0 },
02006         { e_No_Entry, t_sse_ter, SSET61, true, { Zz, Zz, Zz }, 0, 0 },
02007         { e_No_Entry, t_sse_ter, SSET62, true, { Zz, Zz, Zz }, 0, 0 },
02008         { e_No_Entry, t_sse_ter, SSET63, true, { Zz, Zz, Zz }, 0, 0 },
02009         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02010         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02011         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02012         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02013         /* 68 */
02014         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02015         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02016         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02017         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02018         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02019         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02020         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02021         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02022         /* 70 */
02023         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02024         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02025         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02026         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02027         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02028         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02029         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02030         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02031         /* 78 */
02032         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02033         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02034         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02035         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02036         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02037         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02038         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02039         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02040         /* 80 */
02041         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02042         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02043         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02044         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02045         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02046         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02047         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02048         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02049         /* 88 */
02050         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02051         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02052         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02053         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02054         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02055         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02056         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02057         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02058         /* 90 */
02059         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02060         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02061         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02062         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02063         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02064         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02065         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02066         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02067         /* 98 */
02068         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02069         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02070         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02071         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02072         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02073         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02074         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02075         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02076         /* A0 */
02077         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02078         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02079         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02080         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02081         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02082         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02083         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02084         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02085         /* A8 */
02086         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02087         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02088         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02089         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02090         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02091         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02092         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02093         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02094         /* B0 */
02095         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02096         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02097         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02098         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02099         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02100         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02101         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02102         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },  
02103         /* B8 */
02104         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02105         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02106         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02107         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02108         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02109         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02110         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02111         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02112         /* C0 */
02113         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02114         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02115         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02116         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02117         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02118         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02119         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02120         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02121         /* C8 */
02122         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02123         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02124         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02125         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02126         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02127         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02128         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02129         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02130         /* D0 */
02131         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02132         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02133         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02134         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02135         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02136         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02137         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02138         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02139         /* D8 */
02140         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02141         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02142         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02143         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02144         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02145         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02146         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02147         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02148         /* E0 */
02149         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02150         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02151         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02152         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02153         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02154         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02155         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02156         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02157         /* E8 */
02158         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02159         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02160         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02161         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02162         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02163         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02164         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02165         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02166         /* F0 */
02167         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02168         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02169         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02170         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02171         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02172         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02173         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02174         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02175         /* F8 */
02176         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02177         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02178         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02179         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02180         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02181         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02182         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02183         { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
02184 };
02185 
02186 static ia32_entry fpuMap[][2][8] = {
02187 {
02188     { // D8
02189         { e_fadd,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02190         { e_fmul,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02191         { e_fcom,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02192         { e_fcomp, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }, // stack pop
02193         { e_fsub,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02194         { e_fsubr, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02195         { e_fdiv,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02196         { e_fdivr, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }
02197     },
02198     { // D8 -- IMPORTANT NOTE: the C0-FF tables in the book are interleaved from how they
02199         // need to appear here (and for all FPU insns).  i.e. book rows 0, 4, 1, 5, 2, 6, 3, 7 are table rows
02200         // 0, 1, 2, 3, 4, 5, 6, 7.
02201         { e_fadd,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02202         { e_fmul,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02203         { e_fcom,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02204         { e_fcomp, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }, // stack pop
02205         { e_fsub,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02206         { e_fsubr, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02207         { e_fdiv,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02208         { e_fdivr, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }
02209     },
02210 },
02211 {
02212     { // D9 
02213         { e_fld,    t_done, 0, true, { ST0, Ef, Zz }, 0, s1W2R }, // stack push
02214         { e_fnop,   t_done, 0, true, { Zz,  Zz, Zz }, 0, sNONE },
02215         { e_fst,    t_done, 0, true, { Ef, ST0, Zz }, 0, s1W2R },
02216         { e_fstp,   t_done, 0, true, { Ef, ST0, Zz }, 0, s1W2R }, // stack pop
02217         { e_fldenv, t_done, 0, true, { M14, Zz, Zz }, 0, s1R },
02218         { e_fldcw,  t_done, 0, true, { Ew,  Zz, Zz }, 0, s1R },
02219         { e_fstenv, t_done, 0, true, { M14, Zz, Zz }, 0, s1W },
02220         { e_fstcw,  t_done, 0, true, { Ew,  Zz, Zz }, 0, s1W }
02221     },
02222     { // D9 
02223         { e_fld,    t_done, 0, true, { ST0, Ef, Zz }, 0, s1W2R }, // stack push
02224         { e_fxch, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2RW },
02225         { e_fnop,   t_done, 0, true, { Zz,  Zz, Zz }, 0, sNONE },
02226         { e_No_Entry,  t_done, 0, true, { Zz,  Zz, Zz }, 0, sNONE },
02227         { e_fchs,    t_done, 0, true, { ST0, Zz, Zz }, 0, s1RW }, // FIXME: using first of group as placeholder
02228         { e_fld1, t_done, 0, true, { ST0, Zz, Zz }, 0, s1RW }, // FIXME: using first of group
02229         { e_f2xm1,   t_done, 0, true, { ST0, ST1, Zz }, 0, s1RW2R }, // FIXME: using first of group as placeholder
02230         { e_fprem,  t_done, 0, true, { ST0, ST1, Zz }, 0, s1RW2R } // FIXME: using first of group
02231     },
02232 },
02233 {
02234     { // DA 
02235         { e_fiadd,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02236         { e_fimul,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02237         { e_ficom,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02238         { e_ficomp, t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R }, // stack pop
02239         { e_fisub,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02240         { e_fisubr, t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02241         { e_fidiv,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02242         { e_fidivr, t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R }
02243     },
02244     { // DA
02245         { e_fcmovb,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02246         { e_fcmove,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02247         { e_fcmovbe, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02248         { e_fcmovu, t_done, 0, true,  { ST0, Ef, Zz }, 0, s1RW2R },
02249         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02250         { e_fucompp,  t_done, 0, true, { ST0, ST1, Zz }, 0, s1RW2RW }, // double pop
02251         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02252         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02253     },
02254 },
02255 {
02256     { // DB 
02257       { e_fild,   t_done, 0, true, { ST0, Ev, Zz }, 0, s1W2R },
02258       { e_fisttp, t_done, 0, true, { Ev, ST0, Zz }, 0, s1W2R }, //stack pop
02259       { e_fist,   t_done, 0, true, { Ev, ST0, Zz }, 0, s1W2R },
02260       { e_fistp,  t_done, 0, true, { Ev, ST0, Zz }, 0, s1W2R }, // stack pop
02261       { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02262       { e_fld,    t_done, 0, true, { ST0, Ef, Zz }, 0, s1W2R },
02263       { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02264       { e_fstp,   t_done, 0, true, { Ef, ST0, Zz }, 0, s1W2R }
02265     },
02266     { // DB
02267         { e_fcmovnb,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02268         { e_fcmovne,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02269         { e_fcmovnbe, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02270         { e_fcmovnu,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02271         { e_fp_generic,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE }, // FIXME: needs FCLEX and FINIT in group
02272         { e_fucomi,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02273         { e_fcomi,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02274         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02275     },
02276 },
02277 {
02278     { // DC
02279         { e_fadd,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02280         { e_fmul,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02281         { e_fcom,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02282         { e_fcomp, t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R }, // stack pop
02283         { e_fsub,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02284         { e_fsubr, t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02285         { e_fdiv,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02286         { e_fdivr, t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R }
02287     },
02288     { // DC
02289         { e_fadd,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02290         { e_fmul,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02291         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02292         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02293         { e_fsubr,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02294         { e_fsub,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02295         { e_fdivr,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02296         { e_fdiv,  t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02297     },
02298 },
02299 {
02300     { // DD TODO semantics check
02301         { e_fld,    t_done, 0, true, { ST0, Efd, Zz }, 0, s1W2R },
02302         { e_fisttp, t_done, 0, true, { Mq, ST0, Zz }, 0, s1W2R },
02303         { e_fst,    t_done, 0, true, { Efd, ST0, Zz }, 0, s1W2R },
02304         { e_fstp,   t_done, 0, true, { Efd, ST0, Zz }, 0, s1W2R }, // stack pop
02305         { e_frstor, t_done, 0, true, { M512, Zz, Zz }, 0, s1R },
02306         { e_fucomp, t_done, 0, true, { ST0, Efd, Zz }, 0, s1R2R }, // stack pop
02307         { e_fsave,  t_done, 0, true, { M512, Zz, Zz }, 0, s1W },
02308         { e_fstsw,  t_done, 0, true, { Ew, Zz, Zz }, 0, s1W }
02309     },
02310     { // DD TODO semantics check
02311         { e_ffree,    t_done, 0, true, { Efd, Zz, Zz }, 0, s1W },
02312         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02313         { e_fst, t_done, 0, true, { Efd, ST0, Zz }, 0, s1W2R },
02314         { e_fstp, t_done, 0, true, { Efd, ST0, Zz }, 0, s1W2RW },
02315         { e_fucom,    t_done, 0, true, { ST0, Efd, Zz }, 0, s1R2R },
02316         { e_fucomp,    t_done, 0, true, { ST0, Efd, Zz }, 0, s1RW2R },
02317         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02318         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02319     },
02320 },
02321 {    
02322     { // DE 
02323         { e_fiadd,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02324         { e_fimul,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02325         { e_ficom,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02326         { e_ficomp, t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R }, // stack pop
02327         { e_fisub,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02328         { e_fisubr, t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02329         { e_fidiv,  t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R },
02330         { e_fidivr, t_done, 0, true, { ST0, Ev, Zz }, 0, s1RW2R }
02331     },
02332     { // DE
02333         { e_faddp,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02334         { e_fmulp,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02335         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02336         { e_fcompp, t_done, 0, true, { ST0, ST1, Zz }, 0, s1RW2R },
02337         { e_fsubrp,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02338         { e_fsubp,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R },
02339         { e_fdivrp, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }, // stack pop
02340         { e_fdivp, t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }
02341     },
02342 },
02343 {
02344     { // DF TODO semantics/operand sizes
02345         { e_fild,   t_done, 0, true, { ST0, Ew, Zz }, 0, s1W2R },
02346         { e_fisttp, t_done, 0, true, { Ew, ST0, Zz }, 0, s1W2R },
02347         { e_fist,   t_done, 0, true, { Ew, ST0, Zz }, 0, s1W2R },
02348         { e_fistp,  t_done, 0, true, { Ew, ST0, Zz }, 0, s1W2R }, // stack pop
02349         { e_fbld,   t_done, 0, true, { ST0, Mq, Zz }, 0, s1W2R }, // BCD 80 bit
02350         { e_fild,   t_done, 0, true, { ST0, Ev, Zz }, 0, s1W2R },
02351         { e_fbstp,  t_done, 0, true, { Mq, ST0, Zz }, 0, s1RW2R },// BCD 80 bit
02352         { e_fistp,  t_done, 0, true, { Ev, ST0, Zz }, 0, s1W2R }
02353     },
02354     { // DF TODO semantics/operand sizes
02355         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02356         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02357         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02358         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02359         { e_fstsw,   t_done, 0, true, { AX, Zz, Zz }, 0, s1W },
02360         { e_fucomip,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }, // stack pop
02361         { e_fcomip,  t_done, 0, true, { ST0, Ef, Zz }, 0, s1RW2R }, // stack pop
02362         { e_No_Entry,  t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02363     }
02364 }
02365 };
02366 
02367 static ia32_entry groupMap[][8] = {
02368   { /* group 1a */
02369     { e_add, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02370     { e_or,  t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02371     { e_adc, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02372     { e_sbb, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02373     { e_and, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02374     { e_sub, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02375     { e_xor, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02376     { e_cmp, t_done, 0, true, { Eb, Ib, Zz }, 0, s1R2R },
02377   },
02378   { /* group 1b */
02379     { e_add, t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02380     { e_or,  t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02381     { e_adc, t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02382     { e_sbb, t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02383     { e_and, t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02384     { e_sub, t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02385     { e_xor, t_done, 0, true, { Ev, Iz, Zz }, 0, s1RW2R },
02386     { e_cmp, t_done, 0, true, { Ev, Iz, Zz }, 0, s1R2R },
02387   },
02388   { /* group 1c */
02389     { e_add, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02390     { e_or,  t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02391     { e_adc, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02392     { e_sbb, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02393     { e_and, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02394     { e_sub, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02395     { e_xor, t_done, 0, true, { Eb, Ib, Zz }, 0, s1RW2R },
02396     { e_cmp, t_done, 0, true, { Eb, Ib, Zz }, 0, s1R2R },
02397   },
02398   { /* group 1d */
02399     { e_add, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02400     { e_or,  t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02401     { e_adc, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02402     { e_sbb, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02403     { e_and, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02404     { e_sub, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02405     { e_xor, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02406     { e_cmp, t_done, 0, true, { Ev, Ib, Zz }, 0, s1R2R },
02407   },
02408 
02409 
02410  {  /* group 2 - only opcode is defined here, 
02411        operands are defined in the one or two byte maps above */
02412   { e_rol, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 },
02413   { e_ror, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 },
02414   { e_rcl, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 },
02415   { e_rcr, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 },
02416   { e_shl_sal, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 },
02417   { e_shr, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 },
02418   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02419   { e_sar, t_done, 0, true, { Zz, Zz, Zz }, 0, 0 }
02420  },
02421 
02422  { /* group 3a - operands are defined here */
02423   { e_test, t_done, 0, true, { Eb, Ib, Zz }, 0, s1R2R },
02424   { e_test, t_done, 0, true, { Eb, Ib, Zz }, 0, s1R2R }, // book swears this is illegal, sandpile claims it's an aliased TEST
02425   { e_not,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1RW },
02426   { e_neg,  t_done, 0, true, { Eb, Zz, Zz }, 0, s1RW },
02427   { e_mul,  t_done, 0, true, { AX, AL, Eb }, 0, s1W2RW3R },
02428   { e_imul, t_done, 0, true, { AX, AL, Eb }, 0, s1W2R3R },
02429   { e_div,  t_done, 0, true, { AX, AL, Eb }, 0, s1RW2R3R },
02430   { e_idiv, t_done, 0, true, { AX, AL, Eb }, 0, s1W2R3R }
02431  },
02432 
02433  { /* group 3b - operands are defined here */
02434   { e_test, t_done, 0, true, { Ev, Iz, Zz }, 0, s1R2R },
02435   { e_test, t_done, 0, true, { Ev, Iz, Zz }, 0, s1R2R }, // book swears this is illegal, sandpile claims it's an aliased TEST
02436   { e_not,  t_done, 0, true, { Ev, Zz, Zz }, 0, s1RW },
02437   { e_neg,  t_done, 0, true, { Ev, Zz, Zz }, 0, s1RW },
02438   { e_mul,  t_done, 0, true, { eDX, eAX, Ev }, 0, s1W2RW3R },
02439   { e_imul, t_done, 0, true, { eDX, eAX, Ev }, 0, s1W2RW3R },
02440   { e_div,  t_done, 0, true, { eDX, eAX, Ev }, 0, s1RW2RW3R },
02441   { e_idiv, t_done, 0, true, { eDX, eAX, Ev }, 0, s1RW2RW3R }
02442  },
02443 
02444  { /* group 4 - operands are defined here */
02445   { e_inc, t_done, 0, true, { Eb, Zz, Zz }, 0, s1RW },
02446   { e_dec, t_done, 0, true, { Eb, Zz, Zz }, 0, s1RW },
02447   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02448   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02449   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02450   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02451   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02452   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02453  },
02454 
02455  { /* group 5 - operands are defined here */
02456   { e_inc,  t_done, 0, true, { Ev, Zz, Zz }, 0, s1RW },
02457   { e_dec,  t_done, 0, true, { Ev, Zz, Zz }, 0, s1RW },
02458   { e_call, t_done, 0, true, { Ev, Zz, Zz }, (IS_CALL | INDIR), s1R | (fINDIRCALL << FPOS) },
02459   { e_call, t_done, 0, true, { Ep, Zz, Zz }, (IS_CALL | INDIR), s1R | (fINDIRCALL << FPOS) },
02460   { e_jmp,  t_done, 0, true, { Ev, Zz, Zz }, (IS_JUMP | INDIR), s1R | (fINDIRJUMP << FPOS) },
02461   { e_jmp,  t_done, 0, true, { Ep, Zz, Zz }, (IS_JUMP | INDIR), s1R | (fINDIRJUMP << FPOS) },
02462   { e_push, t_done, 0, true, { Ev, eSP, Zz }, 0, s1R2RW },
02463   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02464  },
02465 
02466  { /* group 6 - operands are defined here */
02467    // these need to be fixed for kernel mode accesses
02468   { e_sldt, t_done, 0, true, { Ew, Zz, Zz }, 0, s1W },
02469   { e_str,  t_done, 0, true, { Ew, Zz, Zz }, 0, s1W },
02470   { e_lldt, t_done, 0, true, { Ew, Zz, Zz }, 0, s1R },
02471   { e_ltr,  t_done, 0, true, { Ew, Zz, Zz }, 0, s1R },
02472   { e_verr, t_done, 0, true, { Ew, Zz, Zz }, 0, s1R },
02473   { e_verw, t_done, 0, true, { Ew, Zz, Zz }, 0, s1R },
02474   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02475   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02476  },
02477 
02478  { /* group 7 - operands are defined here */
02479    // idem
02480   { e_sgdt, t_done, 0, true, { Ms, Zz, Zz }, 0, s1W },
02481   { e_sidt, t_done, 0, true, { Ms, Zz, Zz }, 0, s1W },
02482   { e_lgdt, t_done, 0, true, { Ms, Zz, Zz }, 0, s1R },
02483   { e_lidt, t_done, 0, true, { Ms, Zz, Zz }, 0, s1R },
02484   { e_smsw, t_done, 0, true, { Ew, Zz, Zz }, 0, s1W },
02485   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02486   { e_lmsw, t_done, 0, true, { Ew, Zz, Zz }, 0, s1R },
02487   { e_invlpg, t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE }, // 64-bit: swapgs also uses this encoding (w/ mod=11)
02488  },
02489 
02490  { /* group 8 - only opcode is defined here, 
02491      operands are defined in the one or two byte maps below */
02492   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02493   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02494   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02495   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02496   { e_bt,  t_done, 0, true, { Ev, Ib, Zz }, 0, s1R2R },
02497   { e_bts, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02498   { e_btr, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02499   { e_btc, t_done, 0, true, { Ev, Ib, Zz }, 0, s1RW2R },
02500  },
02501 
02502  { /* group 9 - operands are defined here */
02503   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02504   // see comments for cmpxch
02505   { e_cmpxch8b, t_done, 0, true, { EDXEAX, Mq, ECXEBX }, 0, s1RW2RW3R | (fCMPXCH8 << FPOS) },
02506   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02507   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02508   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02509   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02510   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02511   { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }
02512  },
02513 
02514  /* group 10 is all illegal */
02515 
02516  { /* group 11, opcodes defined in one byte map */
02517    { e_mov, t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02518    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02519    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02520    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02521    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02522    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02523    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02524    { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02525  }
02526 
02527 };
02528 
02529 
02530 // Groups 12-16 are split by mod={mem,11}. Some spill over into SSE groups!
02531 // Notation: G12SSE010B = group 12, SSE, reg=010; B means mod=11
02532 // Use A if Intel decides to put SSE instructions for mod=mem
02533 static ia32_entry groupMap2[][2][8] = {
02534   { /* group 12 */
02535     {
02536       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02537       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02538       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02539       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02540       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02541       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02542       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02543       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02544     },
02545     {
02546       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02547       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02548       { e_No_Entry, t_grpsse, G12SSE010B, true, { Zz, Zz, Zz }, 0, 0 },
02549       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02550       { e_No_Entry, t_grpsse, G12SSE100B, true, { Zz, Zz, Zz }, 0, 0 },
02551       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02552       { e_No_Entry, t_grpsse, G12SSE110B, true, { Zz, Zz, Zz }, 0, 0 },
02553       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02554     }
02555   },
02556   { /* group 13 */
02557     {
02558       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02559       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02560       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02561       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02562       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02563       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02564       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02565       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02566     },
02567     {
02568       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02569       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02570       { e_No_Entry, t_grpsse, G13SSE010B, true, { Zz, Zz, Zz }, 0, 0 },
02571       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02572       { e_No_Entry, t_grpsse, G13SSE100B, true, { Zz, Zz, Zz }, 0, 0 },
02573       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02574       { e_No_Entry, t_grpsse, G13SSE110B, true, { Zz, Zz, Zz }, 0, 0 },
02575       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02576     }
02577   },
02578   { /* group 14 */
02579     {
02580       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02581       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02582       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02583       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02584       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02585       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02586       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02587       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02588     },
02589     {
02590       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02591       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02592       { e_No_Entry, t_grpsse, G14SSE010B, true, { Zz, Zz, Zz }, 0, 0 },
02593       { e_No_Entry, t_grpsse, G14SSE011B, true, { Zz, Zz, Zz }, 0, 0 },
02594       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02595       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02596       { e_No_Entry, t_grpsse, G14SSE110B, true, { Zz, Zz, Zz }, 0, 0 },
02597       { e_No_Entry, t_grpsse, G14SSE111B, true, { Zz, Zz, Zz }, 0, 0 },
02598     }
02599   },
02600   { /* group 15 */
02601     {
02602       { e_fxsave,  t_done, 0, true, { M512, Zz, Zz }, 0, s1W | (fFXSAVE << FPOS) },
02603       { e_fxrstor, t_done, 0, true, { M512, Zz, Zz }, 0, s1R | (fFXRSTOR << FPOS) },
02604       { e_ldmxcsr, t_done, 0, true, { Md, Zz, Zz }, 0, s1R },
02605       { e_stmxcsr, t_done, 0, true, { Md, Zz, Zz }, 0, s1W },
02606       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02607       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02608       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02609       { e_clflush, t_done, 0, true, { Mb, Zz, Zz }, 0, s1W | (fCLFLUSH << FPOS) },
02610     },
02611     {
02612       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02613       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02614       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02615       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02616       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02617       { e_lfence, t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02618       { e_mfence, t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02619       { e_sfence, t_done, 0, true, { Zz, Zz, Zz }, 0, sNONE },
02620     }
02621   },
02622   { /* group 16 */
02623     {
02624       { e_prefetchNTA, t_done, 0, true, { Mb, Zz, Zz }, 0, s1R | (fPREFETCHNT << FPOS) },
02625       { e_prefetchT0,  t_done, 0, true, { Mb, Zz, Zz }, 0, s1R | (fPREFETCHT0 << FPOS) },
02626       { e_prefetchT1,  t_done, 0, true, { Mb, Zz, Zz }, 0, s1R | (fPREFETCHT1 << FPOS) },
02627       { e_prefetchT2,  t_done, 0, true, { Mb, Zz, Zz }, 0, s1R | (fPREFETCHT1 << FPOS) },
02628       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02629       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02630       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02631       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02632     },
02633     {
02634       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02635       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02636       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02637       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02638       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02639       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02640       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02641       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02642     }
02643   },
02644   { /* group 17 */
02645     {
02646       { e_extrq, t_done, 0, true, { Vdq, Ib, Ib }, 0, s1RW2R3R },
02647       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02648       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02649       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02650       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02651       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02652       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02653       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02654     },
02655     {
02656       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02657       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02658       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02659       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02660       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02661       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02662       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02663       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02664     }
02665   },
02666   { /* AMD prefetch group */
02667     {
02668       { e_prefetch,   t_done, 0, true, { Mb, Zz, Zz }, 0, s1R | (fPREFETCHAMDE << FPOS) },
02669       { e_prefetchw,  t_done, 0, true, { Mb, Zz, Zz }, 0, s1R | (fPREFETCHAMDW << FPOS) },
02670       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }, // this is reserved, not illegal, ugh...
02671       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }, // this is reserved, not illegal, ugh...
02672       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }, // this is reserved, not illegal, ugh...
02673       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }, // this is reserved, not illegal, ugh...
02674       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }, // this is reserved, not illegal, ugh...
02675       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 }, // this is reserved, not illegal, ugh...
02676     },
02677     {
02678       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02679       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02680       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02681       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02682       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02683       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02684       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02685       { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
02686     }
02687   }
02688 
02689 
02690 };
02691 
02692 /* rows are not, F3, 66, F2 prefixed in this order (see book) */
02693 static ia32_entry sseMap[][4] = {
02694   { /* SSE10 */
02695     { e_movups, t_done, 0, true, { Vps, Wps, Zz }, 0, s1W2R },
02696     { e_movss,  t_done, 0, true, { Vss, Wss, Zz }, 0, s1W2R },
02697     { e_movupd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1W2R },
02698     { e_movsd_sse,  t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1W2R },
02699   },
02700   { /* SSE11 */
02701     { e_movups, t_done, 0, true, { Wps, Vps, Zz }, 0, s1W2R },
02702     { e_movss,  t_done, 0, true, { Wss, Vss, Zz }, 0, s1W2R },
02703     { e_movupd, t_done, 0, true, { Wpd, Vpd, Zz }, 0, s1W2R },
02704     { e_movsd_sse,  t_done, 0, true, { Wsd, Vsd, Zz }, 0, s1W2R }, // Book is wrong, this is a W/V
02705   },
02706   { /* SSE12 */
02707     { e_movlps_movhlps, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R }, // FIXME: wierd 1st op
02708     { e_movsldup, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
02709     { e_movlpd, t_done, 0, true, { Vq, Ws, Zz }, 0, s1W2R },
02710     { e_movddup, t_done, 0, true, { Vdq, Wq, Zz }, 0, s1W2R },
02711   },
02712   { /* SSE13 */
02713     { e_movlps, t_done, 0, true, { Vq, Wq, Zz }, 0, s1W2R },
02714     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02715     { e_movlpd, t_done, 0, true, { Vq, Wq, Zz }, 0, s1W2R },
02716     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02717   },
02718   { /* SSE14 */
02719     { e_unpcklps, t_done, 0, true, { Vps, Wq, Zz }, 0, s1RW2R },
02720     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02721     { e_unpcklpd, t_done, 0, true, { Vpd, Wq, Zz }, 0, s1RW2R },
02722     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02723   },
02724   { /* SSE15 */
02725     { e_unpckhps, t_done, 0, true, { Vps, Wq, Zz }, 0, s1RW2R },
02726     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02727     { e_unpckhpd, t_done, 0, true, { Vpd, Wq, Zz }, 0, s1RW2R },
02728     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02729   },
02730   { /* SSE16 */
02731     { e_movhps_movlhps, t_done, 0, true, { Vq, Wq, Zz }, 0, s1W2R }, // FIXME: wierd 2nd op
02732     { e_movshdup, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
02733     { e_movhpd, t_done, 0, true, { Vq, Wq, Zz }, 0, s1W2R },
02734     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02735   },
02736   { /* SSE17 */
02737     { e_movhps, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R },
02738     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02739     { e_movhpd, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R },
02740     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02741   },
02742   { /* SSE28 */
02743     { e_movaps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1W2R },
02744     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02745     { e_movapd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1W2R },
02746     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02747   },
02748   { /* SSE29 */
02749     { e_movaps, t_done, 0, true, { Wps, Vps, Zz }, 0, s1W2R },
02750     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02751     { e_movapd, t_done, 0, true, { Wpd, Vpd, Zz }, 0, s1W2R },
02752     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02753   },
02754   { /* SSE2A */
02755     { e_cvtpi2ps, t_done, 0, true, { Vps, Qq, Zz }, 0, s1W2R },
02756     { e_cvtsi2ss, t_done, 0, true, { Vss, Ev, Zz }, 0, s1W2R },
02757     { e_cvtpi2pd, t_done, 0, true, { Vpd, Qdq, Zz }, 0, s1W2R },
02758     { e_cvtsi2sd, t_done, 0, true, { Vsd, Ev, Zz }, 0, s1W2R },
02759   },
02760   { /* SSE2B */
02761     { e_movntps, t_done, 0, true, { Wps, Vps, Zz }, 0, s1W2R | (fNT << FPOS) },
02762     { e_movntss, t_done, 0, true, { Md, Vd, Zz }, 0, s1W2R | (fNT << FPOS) },
02763     { e_movntpd, t_done, 0, true, { Wpd, Vpd, Zz }, 0, s1W2R | (fNT << FPOS) }, // bug in book
02764     { e_movntsd, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R | (fNT << FPOS) },
02765   },
02766   { /* SSE2C */
02767     { e_cvttps2pi, t_done, 0, true, { Qq, Wps, Zz }, 0, s1W2R },
02768     { e_cvttss2si, t_done, 0, true, { Gv, Wss, Zz }, 0, s1W2R },
02769     { e_cvttpd2pi, t_done, 0, true, { Qdq, Wpd, Zz }, 0, s1W2R },
02770     { e_cvttsd2si, t_done, 0, true, { Gv, Wsd, Zz }, 0, s1W2R },
02771   },
02772   { /* SSE2D */
02773     { e_cvtps2pi, t_done, 0, true, { Qq, Wps, Zz }, 0, s1W2R },
02774     { e_cvtss2si, t_done, 0, true, { Gv, Wss, Zz }, 0, s1W2R },
02775     { e_cvtpd2pi, t_done, 0, true, { Qdq, Wpd, Zz }, 0, s1W2R },
02776     { e_cvtsd2si, t_done, 0, true, { Gv, Wsd, Zz }, 0, s1W2R },
02777   },
02778   { /* SSE2E */
02779     { e_ucomiss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1R2R },
02780     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02781     { e_ucomisd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1R2R },
02782     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02783   },
02784   { /* SSE2F */
02785     { e_comiss, t_done, 0, true, { Vps, Wps, Zz }, 0, s1R2R },
02786     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02787     { e_comisd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1R2R },
02788     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02789   },
02790   { /* SSE50 */
02791     { e_movmskps, t_done, 0, true, { Gd, Wps, Zz }, 0, s1W2R },
02792     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02793     { e_movmskpd, t_done, 0, true, { Gd, Wpd, Zz }, 0, s1W2R },
02794     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02795   },
02796   { /* SSE51 */
02797     { e_sqrtps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1W2R },
02798     { e_sqrtss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1W2R },
02799     { e_sqrtpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1W2R },
02800     { e_sqrtsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1W2R },
02801   },
02802   { /* SSE52 */
02803     { e_rsqrtps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1W2R },
02804     { e_rsqrtss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1W2R },
02805     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02806     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02807   },
02808   { /* SSE53 */
02809     { e_rcpps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1W2R },
02810     { e_rcpss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1W2R },
02811     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02812     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02813   },
02814   { /* SSE54 */
02815     { e_andps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02816     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02817     { e_andpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02818     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02819   },
02820   { /* SSE55 */
02821     { e_andnps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02822     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02823     { e_andnpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02824     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02825   },
02826   { /* SSE56 */
02827     { e_orps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02828     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02829     { e_orpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02830     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02831   },
02832   { /* SSE57 */
02833     { e_xorps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02834     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02835     { e_xorpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02836     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02837   },
02838   { /* SSE58 */
02839     { e_addps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02840     { e_addss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1RW2R },
02841     { e_addpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02842     { e_addsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1RW2R },
02843   },
02844   { /* SSE59 */
02845     { e_mulps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02846     { e_mulss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1RW2R },
02847     { e_mulpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02848     { e_mulsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1RW2R },
02849   },
02850   { /* SSE5A */
02851     { e_cvtps2pd, t_done, 0, true, { Vpd, Wps, Zz }, 0, s1W2R },
02852     { e_cvtss2sd, t_done, 0, true, { Vss, Wss, Zz }, 0, s1W2R },
02853     { e_cvtpd2ps, t_done, 0, true, { Vps, Wpd, Zz }, 0, s1W2R }, // FIXME: book bug ???
02854     { e_cvtsd2ss, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1W2R },
02855   },
02856   { /* SSE5B */
02857     { e_cvtdq2ps, t_done, 0, true, { Vps, Wdq, Zz }, 0, s1W2R },
02858     { e_cvttps2dq, t_done, 0, true, { Vdq, Wps, Zz }, 0, s1W2R }, // book has this/next swapped!!! 
02859     { e_cvtps2dq, t_done, 0, true, { Vdq, Wps, Zz }, 0, s1W2R },  // FIXME: book bug ???
02860     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02861   },
02862   { /* SSE5C */
02863     { e_subps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02864     { e_subss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1RW2R },
02865     { e_subpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02866     { e_subsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1RW2R },
02867   },
02868   { /* SSE5D */
02869     { e_minps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02870     { e_minss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1RW2R },
02871     { e_minpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02872     { e_minsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1RW2R },
02873   },
02874   { /* SSE5E */
02875     { e_divps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02876     { e_divss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1RW2R },
02877     { e_divpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02878     { e_divsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1RW2R },
02879   },
02880   { /* SSE5F */
02881     { e_maxps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
02882     { e_maxss, t_done, 0, true, { Vss, Wss, Zz }, 0, s1RW2R },
02883     { e_maxpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
02884     { e_maxsd, t_done, 0, true, { Vsd, Wsd, Zz }, 0, s1RW2R },
02885   },
02886   { /* SSE60 */
02887     { e_punpcklbw, t_done, 0, true, { Pq, Qd, Zz }, 0, s1RW2R },
02888     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02889     { e_punpcklbw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02890     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02891   },
02892   { /* SSE61 */
02893     { e_punpcklwd, t_done, 0, true, { Pq, Qd, Zz }, 0, s1RW2R },
02894     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02895     { e_punpcklwd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02896     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02897   },
02898   { /* SSE62 */
02899     { e_punpcklqd, t_done, 0, true, { Pq, Qd, Zz }, 0, s1RW2R },
02900     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02901     { e_punpcklqd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02902     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02903   },
02904   { /* SSE63 */
02905     { e_packsswb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
02906     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02907     { e_packsswb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02908     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02909   },
02910   { /* SSE64 */
02911     { e_pcmpgtb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1R2R },
02912     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02913     { e_pcmpgtb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
02914     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02915   },
02916   { /* SSE65 */
02917     { e_pcmpgtw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1R2R },
02918     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02919     { e_pcmpgtw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
02920     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02921   },
02922   { /* SSE66 */
02923     { e_pcmpgdt, t_done, 0, true, { Pq, Qq, Zz }, 0, s1R2R },
02924     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02925     { e_pcmpgdt, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
02926     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02927   },
02928   { /* SSE67 */
02929     { e_packuswb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
02930     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02931     { e_packuswb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02932     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02933   },
02934   { /* SSE68 */
02935     { e_punpckhbw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
02936     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02937     { e_punpckhbw, t_done, 0, true, { Pdq, Qdq, Zz }, 0, s1RW2R },
02938     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02939   },
02940   { /* SSE69 */
02941     { e_punpckhwd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
02942     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02943     { e_punpckhwd, t_done, 0, true, { Pdq, Qdq, Zz }, 0, s1RW2R },
02944     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02945   },
02946   { /* SSE6A */
02947     { e_punpckhdq, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
02948     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02949     { e_punpckhdq, t_done, 0, true, { Pdq, Qdq, Zz }, 0, s1RW2R },
02950     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02951   },
02952   { /* SSE6B */
02953     { e_packssdw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
02954     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02955     { e_packssdw, t_done, 0, true, { Pdq, Qdq, Zz }, 0, s1RW2R },
02956     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02957   },
02958   { /* SSE6C */
02959     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02960     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02961     { e_punpcklqld, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02962     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02963   },
02964   { /* SSE6D */
02965     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02966     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02967     { e_punpckhqd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
02968     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02969   },
02970   { /* SSE6E */
02971     { e_movd, t_done, 0, true, { Pd, Ev, Zz }, 0, s1W2R },
02972     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02973     { e_movd, t_done, 0, true, { Vdq, Ev, Zz }, 0, s1W2R },
02974     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02975   },
02976   { /* SSE6F */
02977     { e_movq, t_done, 0, true, { Pq, Qq, Zz }, 0, s1W2R },
02978     { e_movdqu, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R }, // book has this/next swapped!!!
02979     { e_movdqa, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
02980     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02981   },
02982   { /* SSE70 */
02983     { e_pshufw, t_done, 0, true, { Pq, Qq, Ib }, 0, s1W2R3R },
02984     { e_pshufhw, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1W2R3R }, // book has this/next swapped!!!
02985     { e_pshufd, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1W2R3R },
02986     { e_pshuflw, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1W2R3R },
02987   },
02988   { /* SSE74 */
02989     { e_pcmpeqb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1R2R },
02990     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02991     { e_pcmpeqb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
02992     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02993   },
02994   { /* SSE75 */
02995     { e_pcmpeqw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1R2R },
02996     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02997     { e_pcmpeqw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
02998     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
02999   },
03000   { /* SSE76 */
03001     { e_pcmpeqd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1R2R },
03002     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03003     { e_pcmpeqd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
03004     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03005   },
03006   { /* SSE78 */
03007     { e_vmread, t_done, 0, true, { Ed, Gd, Zz }, 0, 0 },
03008     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03009     { e_No_Entry, t_grp, Grp17, false, { Zz, Zz, Zz }, 0, 0 },
03010     { e_insertq, t_done, 0, true, {Vdq, VRq, Iw}, 0, s1RW2R3R}, // This is actually 2 8-bit immediates, treat as 1 16-bit for decode
03011   },
03012   { /* SSE79 */
03013     { e_vmwrite, t_done, 0, true, { Ed, Gd, Zz }, 0, 0 },
03014     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03015     { e_extrq, t_done, 0, true, {Vdq, VRq, Zz}, 0, s1RW2R},
03016     { e_insertq, t_done, 0, true, {Vdq, VRdq, Zz}, 0, s1RW2R},
03017   },
03018   { /* SSE7C */
03019     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03020     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03021     { e_haddpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
03022     { e_haddps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
03023   },
03024   { /* SSE7D */
03025     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03026     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03027     { e_hsubpd, t_done, 0, true, { Vpd, Wpd, Zz }, 0, s1RW2R },
03028     { e_hsubps, t_done, 0, true, { Vps, Wps, Zz }, 0, s1RW2R },
03029   },
03030   { /* SSE7E */
03031     { e_movd, t_done, 0, true, { Ev, Pd, Zz }, 0, s1W2R },
03032     { e_movq, t_done, 0, true, { Vq, Wq, Zz }, 0, s1W2R }, // book has this and next swapped!!!
03033     { e_movd, t_done, 0, true, { Ev, Vdq, Zz }, 0, s1W2R },
03034     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03035   },
03036   { /* SSE7F */
03037     { e_movq, t_done, 0, true, { Qq, Pq, Zz }, 0, s1W2R },
03038     { e_movdqu, t_done, 0, true, { Wdq, Vdq, Zz }, 0, s1W2R }, // book has this and next swapped!!!
03039     { e_movdqa, t_done, 0, true, { Wdq, Vdq, Zz }, 0, s1W2R },
03040     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03041   },
03042   { /* SSEB8 */
03043     { e_jmpe, t_done, 0, false, { Jz, Zz, Zz }, 0, s1R },
03044     { e_popcnt, t_done, 0, true, { Gv, Ev, Zz }, 0, s1W2R },
03045     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03046     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03047   },
03048   { /* SSEC2 */
03049     { e_cmpps, t_done, 0, true, { Vps, Wps, Ib }, 0, s1RW2R3R }, // comparison writes to dest!
03050     { e_cmpss, t_done, 0, true, { Vss, Wss, Ib }, 0, s1RW2R3R },
03051     { e_cmppd, t_done, 0, true, { Vpd, Wpd, Ib }, 0, s1RW2R3R },
03052     { e_cmpsd, t_done, 0, true, { Vsd, Wsd, Ib }, 0, s1RW2R3R },
03053   },
03054   { /* SSEC4 */
03055     { e_pinsrw, t_done, 0, true, { Pq, Ed, Ib }, 0, s1RW2R3R },
03056     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03057     { e_pinsrw, t_done, 0, true, { Vdq, Ed, Ib }, 0, s1RW2R3R },
03058     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03059   },
03060   { /* SSEC5 */
03061     { e_pextrw, t_done, 0, true, { Gd, Pq, Ib }, 0, s1W2R3R },
03062     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03063     { e_pextrw, t_done, 0, true, { Gd, Vdq, Ib }, 0, s1W2R3R },
03064     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03065   },
03066   { /* SSEC6 */
03067     { e_shufps, t_done, 0, true, { Vps, Wps, Ib }, 0, s1RW2R3R },
03068     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03069     { e_shufpd, t_done, 0, true, { Vpd, Wpd, Ib }, 0, s1RW2R3R },
03070     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03071   },
03072   { /* SSED0 */
03073     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03074     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03075     { e_addsubpd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03076     { e_addsubps, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03077   },
03078   { /* SSED1 */
03079     { e_psrlw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03080     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03081     { e_psrlw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03082     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03083   },
03084   { /* SSED2 */
03085     { e_psrld, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03086     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03087     { e_psrld, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03088     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03089   },
03090   { /* SSED3 */
03091     { e_psrlq, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03092     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03093     { e_psrlq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03094     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03095   },
03096   { /* SSED4 */
03097     { e_paddq, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03098     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03099     { e_paddq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03100     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03101   },
03102   { /* SSED5 */
03103     { e_pmullw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03104     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03105     { e_pmullw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03106     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03107   },
03108   { /* SSED6 */
03109     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03110     { e_movq2dq, t_done, 0, true, { Vdq, Qq, Zz }, 0, s1W2R }, // lines jumbled in book
03111     { e_movq, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R },
03112     { e_movdq2q, t_done, 0, true, { Pq, Wq, Zz }, 0, s1W2R },
03113   },
03114   { /* SSED7 */
03115     { e_pmovmskb, t_done, 0, true, { Gd, Pq, Zz }, 0, s1W2R },
03116     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03117     { e_pmovmskb, t_done, 0, true, { Gd, Vdq, Zz }, 0, s1W2R },
03118     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03119   },
03120   { /* SSED8 */
03121     { e_psubusb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03122     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03123     { e_psubusb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03124     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03125   },
03126   { /* SSED9 */
03127     { e_psubusw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03128     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03129     { e_psubusw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03130     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03131   },
03132   { /* SSEDA */
03133     { e_pminub, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03134     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03135     { e_pminub, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03136     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03137   },
03138   { /* SSEDB */
03139     { e_pand, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03140     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03141     { e_pand, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03142     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03143   },
03144   { /* SSEDC */
03145     { e_paddusb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03146     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03147     { e_paddusb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03148     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03149   },
03150   { /* SSEDD */
03151     { e_paddusw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03152     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03153     { e_paddusw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03154     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03155   },
03156   { /* SSEDE */
03157     { e_pmaxub, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03158     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03159     { e_pmaxub, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03160     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03161   },
03162   { /* SSEDF */
03163     { e_pandn, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03164     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03165     { e_pandn, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03166     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03167   },
03168   { /* SSEE0 */
03169     { e_pavgb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03170     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03171     { e_pavgb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03172     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03173   },
03174   { /* SSEE1 */
03175     { e_psraw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03176     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03177     { e_psraw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03178     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03179   },
03180   { /* SSEE2 */
03181     { e_psrad, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03182     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03183     { e_psrad, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03184     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03185   },
03186   { /* SSEE3 */
03187     { e_pavgw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03188     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03189     { e_pavgw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03190     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03191   },
03192   { /* SSEE4 */
03193     { e_pmulhuw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03194     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03195     { e_pmulhuw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03196     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03197   },
03198   { /* SSEE5 */
03199     { e_pmulhw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03200     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03201     { e_pmulhw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03202     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03203   },
03204   { /* SSEE6 */
03205     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03206     { e_cvtdq2pd, t_done, 0, true, { Vpd, Wdq, Zz }, 0, s1W2R }, // lines jumbled in book
03207     { e_cvttpd2dq, t_done, 0, true, { Vdq, Wpd, Zz }, 0, s1W2R },
03208     { e_cvtpd2dq, t_done, 0, true, { Vdq, Wpd, Zz }, 0, s1W2R },
03209   },
03210   { /* SSEE7 */
03211     { e_movntq, t_done, 0, true, { Wq, Vq, Zz }, 0, s1W2R | (fNT << FPOS) },
03212     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03213     { e_movntdq, t_done, 0, true, { Wdq, Vdq, Zz }, 0, s1W2R | (fNT << FPOS) },
03214     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03215   },
03216   { /* SSEE8 */
03217     { e_psubsb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03218     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03219     { e_psubsb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03220     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03221   },
03222   { /* SSEE9 */
03223     { e_psubsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03224     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03225     { e_psubsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03226     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03227   },
03228   { /* SSEEA */
03229     { e_pminsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03230     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03231     { e_pminsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03232     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03233   },
03234   { /* SSEEB */
03235     { e_por, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03236     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03237     { e_por, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03238     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03239   },
03240   { /* SSEEC */
03241     { e_paddsb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03242     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03243     { e_paddsb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03244     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03245   },
03246   { /* SSEED */
03247     { e_paddsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03248     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03249     { e_paddsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03250     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03251   },
03252   { /* SSEEE */
03253     { e_pmaxsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03254     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03255     { e_pmaxsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03256     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03257   },
03258   { /* SSEEF */
03259     { e_pxor, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03260     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03261     { e_pxor, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03262     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03263   },
03264   { /* SSEF0 */
03265     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03266     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03267     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03268     { e_lddqu, t_done, 0, true, { Vdq, Mdq, Zz }, 0, s1W2R },
03269   },
03270   { /* SSEF1 */
03271     { e_psllw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03272     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03273     { e_psllw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03274     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03275   },
03276   { /* SSEF2 */
03277     { e_pslld, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03278     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03279     { e_pslld, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03280     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03281   },
03282   { /* SSEF3 */
03283     { e_psllq, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03284     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03285     { e_psllq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03286     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03287   },
03288   { /* SSEF4 */
03289     { e_pmuludq, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03290     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03291     { e_pmuludq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03292     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03293   },
03294   { /* SSEF5 */
03295     { e_pmaddwd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03296     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03297     { e_pmaddwd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03298     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03299   },
03300   { /* SSEF6 */
03301     { e_psadbw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03302     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03303     { e_psadbw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03304     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03305   },
03306   { /* SSEF7 */
03307     { e_maskmovq, t_done, 0, true, { Ppi, Qpi, Zz }, 0, s1W2R | (fNT << FPOS) },
03308     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03309     { e_maskmovdqu, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R | (fNT << FPOS) }, // bug in book
03310     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03311   },
03312   { /* SSEF8 */
03313     { e_psubb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03314     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03315     { e_psubb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03316     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03317   },
03318   { /* SSEF9 */
03319     { e_psubw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03320     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03321     { e_psubw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03322     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03323   },
03324   { /* SSEFA */
03325     { e_psubd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03326     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03327     { e_psubd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03328     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03329   },
03330   { /* SSEFB */ // FIXME: Same????
03331     { e_psubd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03332     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03333     { e_psubd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03334     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03335   },
03336   { /* SSEFC */
03337     { e_paddb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03338     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03339     { e_paddb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03340     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03341   },
03342   { /* SSEFD */
03343     { e_paddw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03344     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03345     { e_paddw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03346     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03347   },
03348   { /* SSEFE */
03349     { e_paddd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03350     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03351     { e_paddd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03352     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03353   },
03354   { /* SSEFF */
03355     { e_ud, t_done, 0, false, { Zz, Zz, Zz }, 0, 0 },
03356     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03357     { e_ud, t_done, 0, false, { Zz, Zz, Zz }, 0, 0 },
03358     { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03359   }
03360 };
03361 
03362 /* rows are not, F3, 66, F2, 66&F2 prefixed in this order (see book) */
03363 static ia32_entry sseMapBis[][5] = {
03364         { /* SSEB00 */
03365                 { e_pshufb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03366                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03367                 { e_pshufb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03368                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03369                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03370         },
03371         { /* SSEB01 */
03372                 { e_phaddw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03373                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03374                 { e_phaddw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03375                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03376                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03377         },
03378         { /* SSEB02 */
03379                 { e_phaddd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03380                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03381                 { e_phaddd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03382                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03383                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03384         },
03385         { /* SSEB03 */
03386                 { e_phaddsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03387                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03388                 { e_phaddsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03389                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03390                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03391         },
03392         { /* SSEB04 */
03393                 { e_pmaddubsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03394                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03395                 { e_pmaddubsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03396                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03397                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03398         },
03399         { /* SSEB05 */
03400                 { e_phsubw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03401                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03402                 { e_phsubw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03403                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03404                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03405         },
03406         { /* SSEB02 */
03407                 { e_phsubd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03408                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03409                 { e_phsubd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03410                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03411                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03412         },
03413         { /* SSEB07 */
03414                 { e_phsubsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03415                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03416                 { e_phsubsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03417                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03418                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03419         },
03420         { /* SSEB08 */
03421                 { e_psignb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03422                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03423                 { e_psignb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03424                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03425                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03426         },
03427         { /* SSEB09 */
03428                 { e_psignw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03429                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03430                 { e_psignw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03431                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03432                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03433         },
03434         { /* SSEB0A */
03435                 { e_psignd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03436                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03437                 { e_psignd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03438                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03439                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03440         },
03441         { /* SSEB0B */
03442                 { e_pmulhrsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1RW2R },
03443                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03444                 { e_pmulhrsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03445                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03446                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03447         },
03448         { /* SSEB10 */
03449                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03450                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03451                 { e_pblendvb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R3R },
03452                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03453                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03454         },
03455         { /* SSEB14 */
03456                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03457                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03458                 { e_blendvps, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R3R },
03459                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03460                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03461         },
03462         { /* SSEB15 */
03463                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03464                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03465                 { e_blendvpd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R3R },
03466                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03467                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03468         },
03469         { /* SSEB17 */
03470                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03471                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03472                 { e_ptest, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1R2R },
03473                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03474                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03475         },
03476         { /* SSEB1C */
03477                 { e_pabsb, t_done, 0, true, { Pq, Qq, Zz }, 0, s1W2R },
03478                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03479                 { e_pabsb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03480                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03481                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03482         },
03483         { /* SSEB1D */
03484                 { e_pabsw, t_done, 0, true, { Pq, Qq, Zz }, 0, s1W2R },
03485                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03486                 { e_pabsw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03487                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03488                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03489         },
03490         { /* SSEB1E */
03491                 { e_pabsd, t_done, 0, true, { Pq, Qq, Zz }, 0, s1W2R },
03492                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03493                 { e_pabsd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03494                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03495                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03496         },
03497         { /* SSEB20 */
03498                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03499                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03500                 { e_pmovsxbw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03501                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03502                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03503         },
03504         { /* SSEB21 */
03505                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03506                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03507                 { e_pmovsxbd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03508                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03509                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03510         },
03511         { /* SSEB22 */
03512                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03513                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03514                 { e_pmovsxbq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03515                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03516                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03517         },
03518         { /* SSEB23 */
03519                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03520                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03521                 { e_pmovsxwd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03522                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03523                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03524         },
03525         { /* SSEB24 */
03526                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03527                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03528                 { e_pmovsxwq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03529                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03530                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03531         },
03532         { /* SSEB25 */
03533                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03534                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03535                 { e_pmovsxdq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03536                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03537                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03538         },
03539         { /* SSEB28 */
03540                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03541                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03542                 { e_pmuldq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03543                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03544                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03545         },
03546         { /* SSEB29 */
03547                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03548                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03549                 { e_pcmpeqq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03550                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03551                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03552         },
03553         { /* SSEB2A */
03554                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03555                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03556                 { e_movntdqa, t_done, 0, true, { Mdq, Wdq, Zz }, 0, s1W2R },
03557                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03558                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03559         },
03560         { /* SSEB2B */
03561                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03562                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03563                 { e_packusdw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03564                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03565                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03566         },
03567         { /* SSEB30 */
03568                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03569                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03570                 { e_pmovzxbw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03571                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03572                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03573         },
03574         { /* SSEB31 */
03575                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03576                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03577                 { e_pmovzxbd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03578                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03579                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03580         },
03581         { /* SSEB32 */
03582                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03583                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03584                 { e_pmovzxbq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03585                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03586                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03587         },
03588         { /* SSEB33 */
03589                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03590                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03591                 { e_pmovzxwd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03592                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03593                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03594         },
03595         { /* SSEB34 */
03596                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03597                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03598                 { e_pmovzxwq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03599                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03600                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03601         },
03602         { /* SSEB35 */
03603                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03604                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03605                 { e_pmovzxdq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03606                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03607                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03608         },
03609         { /* SSEB37 */
03610                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03611                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03612                 { e_pcmpgtq, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03613                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03614                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03615         },
03616         { /* SSEB38 */
03617                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03618                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03619                 { e_pminsb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03620                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03621                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03622         },
03623         { /* SSEB39 */
03624                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03625                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03626                 { e_pminsd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03627                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03628                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03629         },
03630         { /* SSEB3A */
03631                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03632                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03633                 { e_pminuw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03634                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03635                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03636         },
03637         { /* SSEB3B */
03638                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03639                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03640                 { e_pminud, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03641                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03642                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03643         },
03644         { /* SSEB3C */
03645                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03646                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03647                 { e_pmaxsb, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03648                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03649                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03650         },
03651         { /* SSEB3D */
03652                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03653                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03654                 { e_pmaxsd, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03655                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03656                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03657         },
03658         { /* SSEB3E */
03659                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03660                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03661                 { e_pmaxuw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03662                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03663                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03664         },
03665         { /* SSEB3F */
03666                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03667                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03668                 { e_pmaxud, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03669                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03670                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03671         },
03672         { /* SSEB40 */
03673                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03674                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03675                 { e_pmulld, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1RW2R },
03676                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03677                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03678         },
03679         { /* SSEB41 */
03680                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03681                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03682                 { e_phminposuw, t_done, 0, true, { Vdq, Wdq, Zz }, 0, s1W2R },
03683                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03684                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03685         },
03686         { /* SSEBF0 */
03687                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03688                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03689                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03690                 { e_crc32, t_done, 0, true, { Gv, Eb, Zz }, 0, s1RW2R },
03691                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03692         },
03693         { /* SSEBF1 */
03694                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03695                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03696                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03697                 { e_crc32, t_done, 0, true, { Gv, Ev, Zz }, 0, s1RW2R },
03698                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 }
03699         }
03700         
03701 };
03702 
03703 /* rows are not, 66, F2 prefixed in this order (see book) */
03704 static ia32_entry sseMapTer[][3] = {
03705         { /* SSET08 */
03706                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03707                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03708                 { e_roundps, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1W2R3R },
03709         },
03710         { /* SSET09 */
03711                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03712                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03713                 { e_roundpd, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1W2R3R },
03714         },
03715         { /* SSET0A */
03716                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03717                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03718                 { e_roundss, t_done, 0, true, { Vss, Wss, Ib }, 0, s1W2R3R },
03719         },
03720         { /* SSET0B */
03721                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03722                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03723                 { e_roundsd, t_done, 0, true, { Vsd, Wsd, Ib }, 0, s1W2R3R },
03724         },
03725         { /* SSET0C */
03726                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03727                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03728                 { e_blendps, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R },
03729         },
03730         { /* SSET0D */
03731                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03732                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03733                 { e_blendps, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R },
03734         },
03735         { /* SSET0E */
03736                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03737                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03738                 { e_pblendw, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R },
03739         },      
03740         { /* SSET0F */
03741                 { e_palignr, t_done, 0, true, { Pq, Qq, Ib }, 0, s1RW2R3R },
03742                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03743                 { e_palignr, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R },
03744         },
03745         { /* SSET14 */
03746                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03747                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03748                 { e_pextrb, t_done, 0, true, { RMb, Vdq, Ib }, 0, s1W2R3R }, 
03749         },
03750         { /* SSET15 */
03751                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03752                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03753                 { e_pextrw, t_done, 0, true, { RMw, Vdq, Ib }, 0, s1W2R3R }, 
03754         },
03755         { /* SSET16 */
03756                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03757                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03758                 { e_pextrd_pextrq, t_done, 0, true, { Ey, Vdq, Ib }, 0, s1W2R3R },
03759         },
03760         { /* SSET17 */
03761                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03762                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03763                 { e_extractps, t_done, 0, true, { Ed, Vdq, Ib }, 0, s1W2R3R }, 
03764         },
03765         { /* SSET20 */
03766                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03767                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03768                 { e_pinsrb, t_done, 0, true, { Vdq, RMb, Ib }, 0, s1W2R3R }, 
03769         },
03770         { /* SSET21 */
03771                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03772                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03773                 { e_insertps, t_done, 0, true, { Vdq, UMd, Ib }, 0, s1W2R3R },
03774         },
03775         { /* SSET22 */
03776                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03777                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03778                 { e_pinsrd_pinsrq, t_done, 0, true, { Vdq, Ey, Ib }, 0, s1W2R3R },
03779         },
03780         { /* SSET40 */
03781                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03782                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03783                 { e_dpps, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R }, 
03784         },
03785         { /* SSET41 */
03786                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03787                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03788                 { e_dppd, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R }, 
03789         },
03790         { /* SSET42 */
03791                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03792                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03793                 { e_mpsadbw, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1RW2R3R }, 
03794         },
03795         { /* SSET60 */
03796                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03797                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03798                 { e_pcmpestrm, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1R2R3R }, 
03799         },
03800         { /* SSET61 */
03801                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03802                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03803                 { e_pcmpestri, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1R2R3R }, 
03804         },
03805         { /* SSET62 */
03806                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03807                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03808                 { e_pcmpistrm, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1R2R3R }, 
03809         },
03810         { /* SSET63 */
03811                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03812                 { e_No_Entry, t_ill, 0, false, { Zz, Zz, Zz }, 0, 0 },
03813                 { e_pcmpistri, t_done, 0, true, { Vdq, Wdq, Ib }, 0, s1R2R3R }, 
03814         }
03815         
03816 };
03817 
03818 /* rows are none or 66 prefixed in this order (see book) */
03819 static ia32_entry ssegrpMap[][2] = {
03820   /* G12SSE010B */
03821   {
03822     { e_psrlw, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03823     { e_psrlw, t_done, 0, true, { Pdq, Ib, Zz }, 0, s1RW2R }
03824   },
03825   /* G12SSE100B */
03826   {
03827     { e_psraw, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03828     { e_psraw, t_done, 0, true, { Pdq, Ib, Zz }, 0, s1RW2R }
03829   },
03830   /* G12SSE110B */
03831   {
03832     { e_psllw, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03833     { e_psllw, t_done, 0, true, { Pdq, Ib, Zz }, 0, s1RW2R }
03834   },
03835   /* G13SSE010B */
03836   {
03837     { e_psrld, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03838     { e_psrld, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03839   },
03840   /* G13SSE100B */
03841   {
03842     { e_psrad, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03843     { e_psrad, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03844   },
03845   /* G13SSE110B */
03846   {
03847     { e_pslld, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03848     { e_pslld, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03849   },
03850   /* G14SSE010B */
03851   {
03852     { e_psrlq, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03853     { e_psrlq, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03854   },
03855   /* G14SSE011B */
03856   {
03857     { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
03858     { e_psrldq, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03859   },
03860   /* G14SSE110B */
03861   {
03862     { e_psllq, t_done, 0, true, { Pq, Ib, Zz }, 0, s1RW2R },
03863     { e_psllq, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03864   },
03865   /* G14SSE111B */
03866   {
03867     { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 },
03868     { e_pslldq, t_done, 0, true, { Wdq, Ib, Zz }, 0, s1RW2R }
03869   }
03870 };
03871 
03872 static bool mode_64 = false;
03873 
03874 void ia32_set_mode_64(bool mode) {
03875   mode_64 = mode;
03876 }
03877 
03878 bool ia32_is_mode_64() {
03879   return mode_64;
03880 }
03881 
03882 ia32_entry movsxd = { e_movsxd, t_done, 0, true, { Gv, Ed, Zz }, 0, s1W2R };
03883 ia32_entry invalid = { e_No_Entry, t_ill, 0, true, { Zz, Zz, Zz }, 0, 0 };
03884                
03885 static void ia32_translate_for_64(ia32_entry** gotit_ptr)
03886 {
03887     if (*gotit_ptr == &oneByteMap[0x63]) // APRL redefined to MOVSXD
03888     *gotit_ptr = &movsxd;
03889     if (*gotit_ptr == &oneByteMap[0x06] || // Invalid instructions in 64-bit mode: push es
03890     *gotit_ptr == &oneByteMap[0x07] || // pop es
03891     *gotit_ptr == &oneByteMap[0x0E] || // push cs
03892     *gotit_ptr == &oneByteMap[0x16] || // push ss
03893     *gotit_ptr == &oneByteMap[0x17] || // pop ss
03894     *gotit_ptr == &oneByteMap[0x1E] || // push ds
03895     *gotit_ptr == &oneByteMap[0x1F] || // pop ds
03896     *gotit_ptr == &oneByteMap[0x27] || // daa
03897     *gotit_ptr == &oneByteMap[0x2F] || // das
03898     *gotit_ptr == &oneByteMap[0x37] || // aaa
03899     *gotit_ptr == &oneByteMap[0x3F] || // aas
03900     *gotit_ptr == &oneByteMap[0x60] || // pusha
03901     *gotit_ptr == &oneByteMap[0x61] || // popa
03902     *gotit_ptr == &oneByteMap[0x62] || // bound gv, ma
03903     *gotit_ptr == &oneByteMap[0x82] || // group 1 eb/ib
03904     *gotit_ptr == &oneByteMap[0x9A] || // call ap
03905     *gotit_ptr == &oneByteMap[0xC4] || // les gz, mp
03906     *gotit_ptr == &oneByteMap[0xC5] || // lds gz, mp
03907     *gotit_ptr == &oneByteMap[0xCE] || // into
03908     *gotit_ptr == &oneByteMap[0xD4] || // aam ib
03909     *gotit_ptr == &oneByteMap[0xD5] || // aad ib
03910     *gotit_ptr == &oneByteMap[0xD6] || // salc
03911     *gotit_ptr == &oneByteMap[0xEA]) { // jump ap
03912       *gotit_ptr = &invalid;
03913     }
03914     
03915 }
03916 
03917 /* full decoding version: supports memory access information */
03918 static unsigned int ia32_decode_modrm(const unsigned int addrSzAttr,
03919                                       const unsigned char* addr,
03920                                       ia32_memacc* macadr,
03921                                       const ia32_prefixes* pref,
03922                                       ia32_locations *pos);
03923 
03924 
03925 void ia32_memacc::print()
03926 {
03927     fprintf(stderr, "base: %d, index: %d, scale:%d, disp: %ld (%lx), size: %d, addr_size: %d\n",
03928         regs[0], regs[1], scale, imm, imm, size, addr_size);
03929 }
03930 
03931 int getOperSz(const ia32_prefixes &pref) 
03932 {
03933    if (pref.rexW()) return 4;
03934    else if (pref.getPrefix(2) == PREFIX_SZOPER) return 1;
03935    else return 2;
03936 }
03937 
03938 ia32_instruction& ia32_decode(unsigned int capa, const unsigned char* addr, ia32_instruction& instruct)
03939 {
03940   ia32_prefixes& pref = instruct.prf;
03941   unsigned int table, nxtab;
03942   unsigned int idx = 0, sseidx = 0;
03943   ia32_entry *gotit = NULL;
03944   int condbits = 0;
03945 
03946   if(capa & IA32_DECODE_MEMACCESS)
03947     assert(instruct.mac != NULL);
03948 
03949   if (!ia32_decode_prefixes(addr, pref, instruct.loc)) {
03950     instruct.size = 1;
03951     instruct.legacy_type = ILLEGAL;
03952     return instruct;
03953   }
03954 
03955   if((pref.getOpcodePrefix()) && pref.getCount())
03956   {
03957     idx = pref.getOpcodePrefix();
03958   }
03959 
03960   if (instruct.loc) instruct.loc->num_prefixes = pref.getCount();
03961   instruct.size = pref.getCount();
03962   addr += instruct.size;
03963 
03964   table = t_oneB;
03965   if(idx == 0) {
03966     // consume opcode
03967     idx = addr[0];
03968     instruct.size += 1;
03969     addr += 1;
03970   } else {
03971     // opcode already consumed (prefix opcode)
03972   }
03973 
03974   gotit = &oneByteMap[idx];
03975   nxtab = gotit->otable;
03976 
03977   if(capa & IA32_DECODE_CONDITION) {
03978     assert(instruct.cond != NULL);
03979     condbits = idx & 0x0F;
03980   }
03981 
03982   while(nxtab != t_done) {
03983     table = nxtab;
03984     switch(table) {
03985     case t_twoB:
03986       idx = addr[0];
03987       gotit = &twoByteMap[idx];
03988       nxtab = gotit->otable;
03989       instruct.size += 1;
03990       addr += 1;
03991       if(capa & IA32_DECODE_CONDITION)
03992         condbits = idx & 0x0F;
03993       break;
03994     case t_threeB:
03995       idx = addr[0];
03996       gotit = &threeByteMap[idx];
03997       nxtab = gotit->otable;
03998       instruct.size += 1;
03999       addr += 1;
04000       if(capa & IA32_DECODE_CONDITION)
04001         condbits = idx & 0x0F;
04002       break;
04003     case t_threeB2:
04004       idx = addr[0];
04005       gotit = &threeByteMap2[idx];
04006       nxtab = gotit->otable;
04007       instruct.size += 1;
04008       addr += 1;
04009       if(capa & IA32_DECODE_CONDITION)
04010         condbits = idx & 0x0F;
04011       break;
04012     case t_prefixedSSE:
04013       sseidx = gotit->tabidx;
04014       if(addr[0] != 0x0F)
04015       {
04016           // all valid SSE insns will have 0x0F as their first byte after prefix
04017           instruct.size += 1;
04018           addr += 1;
04019           instruct.entry = &invalid;
04020           return instruct;
04021       }
04022       idx = addr[1];
04023       gotit = &twoByteMap[idx];
04024       nxtab = gotit->otable;
04025       instruct.size += 2;
04026       addr += 2;
04027       break;
04028     case t_sse:
04029       idx = gotit->tabidx;
04030       gotit = &sseMap[idx][sseidx];
04031       nxtab = gotit->otable;
04032       break;
04033     case t_sse_bis:
04034       idx = gotit->tabidx;
04035       gotit = &sseMapBis[idx][sseidx];
04036       nxtab = gotit->otable;
04037       break;
04038     case t_sse_ter:
04039       idx = gotit->tabidx;      
04040       gotit = &sseMapTer[idx][sseidx];
04041       nxtab = gotit->otable;
04042       break;
04043     case t_grp: {
04044       idx = gotit->tabidx;
04045       unsigned int reg  = (addr[0] >> 3) & 7;
04046       if(idx < Grp12)
04047         switch(idx) {
04048         case Grp2:
04049         case Grp11:
04050           /* leave table unchanged because operands are in not 
04051              defined in group map, unless this is an invalid index
04052              into the group, in which case we need the instruction
04053              to reflect its illegal status */
04054           if(groupMap[idx][reg].id == e_No_Entry)
04055             gotit = &groupMap[idx][reg];
04056           nxtab = groupMap[idx][reg].otable;
04057           assert(nxtab==t_done || nxtab==t_ill);
04058           break;
04059         default:
04060           gotit = &groupMap[idx][reg];
04061           nxtab = gotit->otable;
04062         }
04063       else {
04064         unsigned int mod = addr[0] >> 6;
04065         gotit = &groupMap2[idx-Grp12][mod==3][reg];
04066         nxtab = gotit->otable;
04067       }
04068       break;
04069     }
04070     case t_grpsse:
04071       sseidx >>= 1;
04072       idx = gotit->tabidx;
04073       gotit = &ssegrpMap[idx][sseidx];
04074       nxtab = gotit->otable;
04075       break;
04076     case t_coprocEsc:
04077       {
04078         instruct.legacy_type = 0;
04079         unsigned int reg  = (addr[0] >> 3) & 7;
04080         unsigned int mod = addr[0] >> 6;
04081         gotit = &fpuMap[gotit->tabidx][mod==3][reg];
04082         ia32_decode_FP(idx, pref, addr, instruct, gotit, instruct.mac);
04083         return instruct;
04084       }
04085     case t_3dnow:
04086       // 3D now opcodes are given as suffix: ModRM [SIB] [displacement] opcode
04087       // Right now we don't care what the actual opcode is, so there's no table
04088       instruct.size += 1;
04089       nxtab = t_done;
04090       break;
04091     case t_ill:
04092       instruct.legacy_type = ILLEGAL;
04093       instruct.entry = gotit;
04094       return instruct;
04095     default:
04096       assert(!"wrong table");
04097     }
04098   }
04099 
04100   assert(gotit != NULL);
04101   instruct.legacy_type = gotit->legacyType;
04102 
04103   // addr points after the opcode, and the size has been adjusted accordingly
04104   if (instruct.loc) instruct.loc->opcode_size = instruct.size - pref.getCount();
04105   if (instruct.loc) instruct.loc->opcode_position = pref.getCount();
04106 
04107   // make adjustments for instruction redefined in 64-bit mode
04108   if (mode_64)
04109     ia32_translate_for_64(&gotit);
04110 
04111   ia32_decode_operands(pref, *gotit, addr, instruct, instruct.mac); // all but FP
04112 
04113   if(capa & IA32_DECODE_MEMACCESS) {
04114     int sema = gotit->opsema & ((1<<FPOS)-1);
04115     int hack = gotit->opsema >> FPOS;
04116     switch(sema) {
04117     case sNONE:
04118       break;
04119     case s1R:
04120       switch(hack) {
04121       case fPREFETCHNT:
04122         instruct.mac[0].prefetch = true;
04123         instruct.mac[0].prefetchlvl = 0;
04124         break;
04125       case fPREFETCHT0:
04126         instruct.mac[0].prefetch = true;
04127         instruct.mac[0].prefetchlvl = 1;
04128         break;
04129       case fPREFETCHT1:
04130         instruct.mac[0].prefetch = true;
04131         instruct.mac[0].prefetchlvl = 2;
04132         break;
04133       case fPREFETCHT2:
04134         instruct.mac[0].prefetch = true;
04135         instruct.mac[0].prefetchlvl = 3;
04136         break;
04137       case fPREFETCHAMDE:
04138         instruct.mac[0].prefetch = true;
04139         instruct.mac[0].prefetchstt = 0;
04140         break;
04141       case fPREFETCHAMDW:
04142         instruct.mac[0].prefetch = true;
04143         instruct.mac[0].prefetchstt = 1;
04144         break;
04145       default:
04146         instruct.mac[0].read = true;
04147       }
04148       break;
04149     case s1W:
04150       instruct.mac[0].write = true;
04151       break;
04152     case s1RW:
04153       instruct.mac[0].read = true;
04154       instruct.mac[0].write = true;
04155       instruct.mac[0].nt = hack == fNT;
04156       break;
04157     case s1R2R:
04158       instruct.mac[0].read = true;
04159       instruct.mac[1].read = true;
04160       break;
04161     case s1W2R:
04162       instruct.mac[0].write = true;
04163       instruct.mac[0].nt = hack == fNT; // all NTs are s1W2R
04164       instruct.mac[1].read = true;
04165       break;
04166     case s1RW2R:
04167       instruct.mac[0].read = true;
04168       instruct.mac[0].write = true;
04169       instruct.mac[1].read = true;
04170       break;
04171     case s1RW2RW:
04172       instruct.mac[0].read = true;
04173       instruct.mac[0].write = true;
04174       instruct.mac[1].read = true;
04175       instruct.mac[1].write = true;
04176       break;
04177     case s1W2R3R:
04178       instruct.mac[0].write = true;
04179       instruct.mac[1].read = true;
04180       instruct.mac[2].read = true;
04181       break;
04182     case s1W2W3R:
04183       instruct.mac[0].write = true;
04184       instruct.mac[1].write = true;
04185       instruct.mac[2].read = true;
04186       break;
04187     case s1W2RW3R:
04188       instruct.mac[0].write = true;
04189       instruct.mac[1].read = true;
04190       instruct.mac[1].write = true;
04191       instruct.mac[2].read = true;
04192       break;
04193     case s1W2R3RW:
04194       instruct.mac[0].write = true;
04195       instruct.mac[1].read = true;
04196       instruct.mac[2].read = true;
04197       instruct.mac[2].write = true;
04198       break;
04199     case s1RW2R3R:
04200       instruct.mac[0].read = true;
04201       instruct.mac[0].write = true;
04202       instruct.mac[1].read = true;
04203       instruct.mac[2].read = true;
04204       break;
04205     case s1RW2RW3R:
04206       instruct.mac[0].write = true;
04207       instruct.mac[0].read = true;
04208       instruct.mac[1].read = true;
04209       instruct.mac[1].write = true;
04210       instruct.mac[2].read = true;
04211       break;
04212     }
04213 
04214     switch(pref.getPrefix(0)) {
04215     case PREFIX_REPNZ:
04216       switch(hack) {
04217       case fSCAS:
04218         instruct.mac[1].sizehack = shREPNESCAS;
04219         break;
04220       case fCMPS:
04221         instruct.mac[0].sizehack = shREPNECMPS;
04222         instruct.mac[1].sizehack = shREPNECMPS;
04223         break;
04224       default:
04225       break;
04226       }
04227       break;
04228     case PREFIX_REP:
04229       switch(hack) {
04230       case fSCAS:
04231         instruct.mac[1].sizehack = shREPESCAS;
04232         break;
04233       case fCMPS:
04234         instruct.mac[0].sizehack = shREPECMPS;
04235         instruct.mac[1].sizehack = shREPECMPS;
04236         break;
04237       case fREP:
04238         instruct.mac[0].sizehack = shREP;
04239         instruct.mac[1].sizehack = shREP;
04240         break;
04241       default:
04242     break;
04243       }
04244       break;
04245     case 0:
04246     case PREFIX_LOCK:
04247       break;
04248     default:
04249       break;
04250     }
04251 
04252 #if 0
04253     // debug output for memory access decoding
04254     for (int i = 0; i < 3; i++) {
04255     if (instruct.mac[i].is) {
04256         fprintf(stderr, "%d)", i);
04257         if (instruct.mac[i].read)
04258         fprintf(stderr, " read");
04259         if (instruct.mac[i].write)
04260         fprintf(stderr, " write");
04261         if (instruct.mac[i].nt)
04262         fprintf(stderr, " nt");
04263         if (instruct.mac[i].sizehack)
04264         fprintf(stderr, " sizehack");
04265         fprintf(stderr, "\n");
04266         instruct.mac[i].print();
04267     }
04268     }
04269 #endif
04270 
04271   }
04272 
04273 
04274   if(capa & IA32_DECODE_CONDITION) {
04275     int hack = gotit->opsema >> FPOS;
04276     if(hack == fCOND)
04277       instruct.cond->set(condbits);
04278   }
04279 
04280   // flip id of opcodes overloaded on operand size prefix
04281   int operSzAttr = getOperSz(pref);
04282   if (1 == operSzAttr) {
04283     entryID newID = gotit->id;
04284     switch (gotit->id) {
04285     case e_cwde: newID = e_cbw; break;
04286     case e_cdq: newID = e_cwd; break;
04287     case e_insd: newID = e_insw; break;
04288     case e_lodsd: newID = e_lodsw; break;
04289     case e_movsd: newID = e_movsw; break;
04290     case e_outsd: newID = e_outsw; break;
04291     case e_popad: newID = e_popa; break;
04292     case e_popfd: newID = e_popf; break;
04293     case e_pushad: newID = e_pusha; break;
04294     case e_pushfd: newID = e_pushf; break;
04295     case e_scasd: newID = e_scasw; break;
04296     case e_stosd: newID = e_stosw; break;
04297     default: break;
04298     }
04299     gotit->id = newID;
04300   }
04301 
04302   instruct.entry = gotit;
04303   return instruct;
04304 }
04305 
04306 ia32_instruction& ia32_decode_FP(unsigned int opcode, const ia32_prefixes& pref,
04307                                  const unsigned char* addr, ia32_instruction& instruct,
04308                                  ia32_entry * entry, ia32_memacc *mac)
04309 {
04310   // addr points after the opcode, and the size has been adjusted accordingly
04311   if (instruct.loc) instruct.loc->opcode_size = instruct.size - pref.getCount();
04312   if (instruct.loc) instruct.loc->opcode_position = pref.getCount();
04313 
04314   unsigned int nib = byteSzB; // modRM
04315   unsigned int addrSzAttr = (pref.getPrefix(3) == PREFIX_SZADDR ? 1 : 2); // 32-bit mode implicit
04316   unsigned int operSzAttr = (pref.getPrefix(2) == PREFIX_SZOPER ? 1 : 2); // 32-bit mode implicit
04317 
04318   // There *will* be a mod r/m byte at least as far as locs are concerned, though the mod=3 case does not
04319   // consume extra bytes.  So pull this out of the conditional.
04320   if (instruct.loc) {
04321       instruct.loc->modrm_position = instruct.loc->opcode_position +
04322               instruct.loc->opcode_size;
04323       instruct.loc->modrm_operand = 0;
04324   }
04325   nib += ia32_decode_modrm(addrSzAttr, addr, mac, &pref, instruct.loc);
04326     // also need to check for AMD64 rip-relative data addressing
04327     // occurs when mod == 0 and r/m == 101
04328   if (mode_64)
04329       if ((addr[0] & 0xc7) == 0x05)
04330           instruct.rip_relative_data = true;
04331   if (addr[0] <= 0xBF) { // modrm
04332     // operand size has to be determined from opcode
04333     if(mac)
04334       {
04335     switch(opcode) {
04336     case 0xD8: // all single real
04337       mac->size = 4;
04338       mac->read = true;
04339       break;
04340     case 0xD9: {
04341       unsigned char modrm = addr[0];
04342       unsigned char reg = (modrm >> 3) & 7;
04343       switch(reg) {
04344       case 0:
04345         mac->size = 4;
04346         mac->read = true;
04347         break;
04348       case 2:
04349       case 3:
04350         mac->size = 4;
04351         mac->write = true;
04352         break;
04353       case 1:
04354         instruct.legacy_type = ILLEGAL;
04355         break;
04356       case 4:
04357         mac->size = 14 * operSzAttr;
04358         mac->read = true;
04359         break;
04360       case 5:
04361         mac->read = true;
04362         mac->size = 2;
04363         break;
04364       case 6:
04365         mac->size = 14 * operSzAttr;
04366         mac->write = true;
04367         break;
04368       case 7:
04369         mac->write = true;
04370         mac->size = 2;
04371         break;
04372       }
04373       break; }
04374     case 0xDA:  // all double real
04375       mac->size = 8;
04376       mac->read = true;
04377       break;
04378     case 0xDB: {
04379       unsigned char modrm = addr[0];
04380       unsigned char reg = (modrm >> 3) & 7;
04381       switch(reg) {
04382       case 0:
04383         mac->size = dwordSzB;
04384         mac->read = true;
04385         break;
04386       case 2:
04387       case 3:
04388         mac->size = dwordSzB;
04389         mac->write = true;
04390         break;
04391       case 1:
04392       case 4:
04393       case 6:
04394         instruct.legacy_type = ILLEGAL;
04395         break;
04396       case 5:
04397         mac->size = 10; // extended real
04398         mac->read = true;
04399         break;
04400       case 7:
04401         mac->size = 10; // extended real
04402         mac->write = true;
04403         break;
04404       }
04405       break; }
04406     case 0xDC:   // all double real
04407       mac->size = 8;
04408       mac->read = true;
04409       break;
04410     case 0xDD: {
04411       unsigned char modrm = addr[0];
04412       unsigned char reg = (modrm >> 3) & 7;
04413       switch(reg) {
04414       case 0:
04415         mac->size = 8;
04416         mac->read = true;
04417         break;
04418       case 2:
04419       case 3:
04420         mac->size = 8;
04421         mac->write = true;
04422         break;
04423       case 1:
04424       case 5:
04425         instruct.legacy_type = ILLEGAL;
04426         break;
04427       case 4:
04428         mac->size = operSzAttr == 2 ? 108 : 98;
04429         mac->read = true;
04430         break;
04431       case 6:
04432         mac->size = operSzAttr == 2 ? 108 : 98;
04433         mac->write = true;
04434         break;
04435       case 7:
04436         mac->size = 2;
04437         mac->write = true;
04438         break;    
04439       }
04440       break; }
04441     case 0xDE: // all word integer
04442       mac->size = wordSzB;
04443       mac->write = true;
04444       break;
04445     case 0xDF: {
04446       unsigned char modrm = addr[0];
04447       unsigned char reg = (modrm >> 3) & 7;
04448       switch(reg) {
04449       case 0:
04450         mac->size = wordSzB;
04451         mac->read = true;
04452         break;
04453       case 2:
04454       case 3:
04455         mac->size = wordSzB;
04456         mac->write = true;
04457         break;
04458       case 1:
04459         instruct.legacy_type = ILLEGAL;
04460         break;
04461       case 4:
04462         mac->size = 10;
04463         mac->read = true;
04464         break;
04465       case 5:
04466         mac->size = 8;
04467         mac->read = true;
04468         break;
04469       case 6:
04470         mac->size = 10;
04471         mac->write = true;
04472         break;
04473       case 7:
04474         mac->size = 8;
04475         mac->write = true; 
04476         break;
04477       }
04478       break; }
04479     } // switch(opcode) 
04480       } // if mac
04481   } // if modrm
04482   
04483   instruct.size += nib;
04484   instruct.entry = entry;
04485   
04486   return instruct;
04487 }
04488 
04489 #define MODRM_MOD(x) ((x) >> 6)
04490 #define MODRM_RM(x) ((x) & 7)
04491 #define MODRM_REG(x) (((x) & (7 << 3)) >> 3)
04492 #define MODRM_SET_MOD(x, y) ((x) |= ((y) << 6))
04493 #define MODRM_SET_RM(x, y) ((x) |= (y))
04494 #define MODRM_SET_REG(x, y) ((x) |= ((y) << 3))
04495 
04496 static unsigned int ia32_decode_modrm(const unsigned int addrSzAttr,
04497                                       const unsigned char* addr,
04498                                       ia32_memacc* macadr,
04499                                       const ia32_prefixes* pref,
04500                                       ia32_locations *loc)
04501 {
04502  
04503   unsigned char modrm = addr[0];
04504   unsigned char mod = MODRM_MOD(modrm);
04505   unsigned char rm  = MODRM_RM(modrm);
04506   unsigned char reg = MODRM_REG(modrm);
04507   if (loc) {
04508      loc->modrm_byte = modrm;
04509      loc->modrm_mod = mod;
04510      loc->modrm_rm = rm;
04511      loc->modrm_reg = reg;
04512      loc->address_size = addrSzAttr;
04513   }
04514   ++addr;
04515 
04516   if(addrSzAttr == 1) { // 16-bit, cannot have SIB
04517     //bperr( "16bit addr!\n");
04518     switch(mod) {
04519     case 0:
04520       //bperr( "16bit addr - case 0, rm = %d!\n", rm);
04521       if(macadr)
04522         switch (rm) {
04523         case 0: // [BX+SI]
04524           macadr->set16(mBX, mSI, 0);
04525           break;
04526         case 1:
04527           macadr->set16(mBX, mDI, 0);
04528           break;
04529         case 2:
04530           macadr->set16(mBP, mSI, 0);
04531           break;
04532         case 3:
04533           macadr->set16(mBP, mDI, 0);
04534           break;
04535         case 4:
04536           macadr->set16(mSI, -1, 0);
04537           break;
04538         case 5:
04539           macadr->set16(mDI, -1, 0);
04540           break;
04541         case 6: { 
04542            // disp16
04543            const short int *pdisp16 = (const short int*)addr;
04544            //bperr( "16bit addr - case6!\n");
04545            macadr->set16(-1, -1, *pdisp16);
04546            if (loc) { 
04547               loc->disp_position = loc->modrm_position + 1;
04548               loc->disp_size = 2;
04549            }
04550            break; 
04551         }
04552         case 7:
04553           macadr->set16(mBX, -1, 0);
04554           break;
04555         }
04556       return rm==6 ? wordSzB : 0;
04557     case 1:
04558       //bperr( "16bit addr - case1!\n");
04559       if(macadr) {
04560         const char *pdisp8 = (const char*)addr;
04561         if (loc) { 
04562            loc->disp_position = loc->modrm_position + 1;
04563            loc->disp_size = 1;
04564         }
04565         switch (rm) {
04566         case 0: 
04567           macadr->set16(mBX, mSI, *pdisp8);
04568           break;
04569         case 1:
04570           macadr->set16(mBX, mDI, *pdisp8);
04571           break;
04572         case 2:
04573           macadr->set16(mBP, mSI, *pdisp8);
04574           break;
04575         case 3:
04576           macadr->set16(mBP, mDI, *pdisp8);
04577           break;
04578         case 4:
04579           macadr->set16(mSI, -1, *pdisp8);
04580           break;
04581         case 5:
04582           macadr->set16(mDI, -1, *pdisp8);
04583           break;
04584         case 6:
04585           macadr->set16(mBP, -1, *pdisp8);
04586           break;
04587         case 7:
04588           macadr->set16(mBX, -1, *pdisp8);
04589           break;
04590         }
04591       }
04592       return byteSzB;
04593     case 2:
04594       //bperr( "16bit addr - case2!\n");
04595       if(macadr) {
04596         const short int *pdisp16 = (const short int*)addr;
04597         if (loc) { 
04598            loc->disp_position = loc->modrm_position + 1;
04599            loc->disp_size = 2;
04600         }
04601         switch (rm) {
04602         case 0: 
04603           macadr->set16(mBX, mSI, *pdisp16);
04604           break;
04605         case 1:
04606           macadr->set16(mBX, mDI, *pdisp16);
04607           break;
04608         case 2:
04609           macadr->set16(mBP, mSI, *pdisp16);
04610           break;
04611         case 3:
04612           macadr->set16(mBP, mDI, *pdisp16);
04613           break;
04614         case 4:
04615           macadr->set16(mSI, -1, *pdisp16);
04616           break;
04617         case 5:
04618           macadr->set16(mDI, -1, *pdisp16);
04619           break;
04620         case 6:
04621           macadr->set16(mBP, -1, *pdisp16);
04622           break;
04623         case 7:
04624           macadr->set16(mBX, -1, *pdisp16);
04625           break;
04626         }
04627       }
04628 
04629       return wordSzB;
04630     case 3:
04631       return 0; // register
04632     default:
04633       assert(0);
04634     }
04635   }
04636   else { // 32-bit or 64-bit, may have SIB
04637      if(mod == 3)
04638         return 0; // only registers, no SIB
04639     bool hassib = rm == 4;
04640     unsigned int nsib = 0;
04641     unsigned char sib;
04642     int base = 0, scale = -1, index = -1;  // prevent g++ from whining.
04643     if(hassib) {
04644       nsib = byteSzB;
04645       sib = addr[0];
04646       if (loc) { 
04647          loc->sib_position = loc->modrm_position + 1;
04648          loc->sib_byte = sib;
04649       }
04650       ++addr;
04651       base = sib & 7;
04652       if(macadr) {
04653         scale = sib >> 6;
04654         index = (sib >> 3) & 7;
04655 
04656     // stack pointer can't be used as an index - supports base-only addressing w/ SIB
04657         if(index == 4 && !pref->rexX())
04658           index = -1;
04659       }
04660     }
04661     switch(mod) {
04662     case 0: {
04663       /* this is tricky: there is a disp32 iff (1) rm == 5  or  (2) hassib && base == 5 */
04664       unsigned char check5 = hassib ? base : rm;
04665       if(macadr)
04666         switch (rm) {
04667         case 0:
04668           macadr->set(apply_rex_bit(mEAX, pref->rexB()), 0, addrSzAttr);
04669           break;
04670         case 1:
04671           macadr->set(apply_rex_bit(mECX, pref->rexB()), 0, addrSzAttr);
04672           break;
04673         case 2:
04674           macadr->set(apply_rex_bit(mEDX, pref->rexB()), 0, addrSzAttr);
04675           break;
04676         case 3:
04677           macadr->set(apply_rex_bit(mEBX, pref->rexB()), 0, addrSzAttr);
04678           break;
04679         case 4: // SIB
04680           if(base == 5) 
04681           { 
04682              // disp32[index<<scale]
04683              const int *pdisp32 = (const int*)addr;
04684              if (loc) { 
04685                 loc->disp_position = loc->sib_position + 1;
04686                 loc->disp_size = 4;
04687              }
04688              macadr->set_sib(-1, scale, apply_rex_bit(index, pref->rexX()), 
04689                              *pdisp32, addrSzAttr);
04690           }
04691           else
04692             macadr->set_sib(apply_rex_bit(base, pref->rexB()), scale, 
04693                             apply_rex_bit(index, pref->rexX()),
04694                             0, addrSzAttr);
04695           break;
04696         case 5: { 
04697            // disp32 (or [RIP + disp32] for 64-bit mode)
04698            if (loc) { 
04699               loc->disp_position = loc->modrm_position + 1;
04700               loc->disp_size = 4;
04701            }
04702            const int *pdisp32 = (const int*)addr;
04703            if (mode_64)
04704               macadr->set(mRIP, *pdisp32, addrSzAttr);
04705            else
04706               macadr->set(-1, *pdisp32, addrSzAttr);
04707            break; 
04708         }
04709         case 6:
04710            macadr->set(apply_rex_bit(mESI, pref->rexB()), 0, addrSzAttr);
04711            break;
04712         case 7:
04713            macadr->set(apply_rex_bit(mEDI, pref->rexB()), 0, addrSzAttr);
04714            break;
04715       }
04716       return nsib + ((check5 == 5) ? dwordSzB : 0);
04717     }
04718     case 1:
04719       if(macadr) {
04720          const char *pdisp8 = (const char*)addr;
04721          if (loc) { 
04722             loc->disp_position = loc->modrm_position + 1;
04723             loc->disp_size = 1;
04724          }
04725         switch (rm) {
04726         case 0:
04727            macadr->set(apply_rex_bit(mEAX, pref->rexB()), *pdisp8, addrSzAttr);
04728           break;
04729         case 1:
04730           macadr->set(apply_rex_bit(mECX, pref->rexB()), *pdisp8, addrSzAttr);
04731           break;
04732         case 2:
04733           macadr->set(apply_rex_bit(mEDX, pref->rexB()), *pdisp8, addrSzAttr);
04734           break;
04735         case 3:
04736           macadr->set(apply_rex_bit(mEBX, pref->rexB()), *pdisp8, addrSzAttr);
04737           break;
04738         case 4:
04739           // disp8[EBP + index<<scale] happens naturally here when base=5
04740            if (loc) { 
04741               loc->disp_position = loc->sib_position + 1;
04742               loc->disp_size = 1;
04743            }           
04744           macadr->set_sib(apply_rex_bit(base, pref->rexB()), scale, apply_rex_bit(index, pref->rexX()),
04745               *pdisp8, addrSzAttr);
04746           break;
04747         case 5:
04748           macadr->set(apply_rex_bit(mEBP, pref->rexB()), *pdisp8, addrSzAttr);
04749           break;
04750         case 6:
04751           macadr->set(apply_rex_bit(mESI, pref->rexB()), *pdisp8, addrSzAttr);
04752           break;
04753         case 7:
04754           macadr->set(apply_rex_bit(mEDI, pref->rexB()), *pdisp8, addrSzAttr);
04755           break;
04756         }
04757       }
04758       return nsib + byteSzB;
04759     case 2:
04760       if(macadr) {
04761         const int *pdisp32 = (const int*)addr;
04762         if (loc) { 
04763            loc->disp_position = loc->modrm_position + 1;
04764            loc->disp_size = 4;
04765         }
04766         switch (rm) {
04767         case 0:
04768           macadr->set(apply_rex_bit(mEAX, pref->rexB()), *pdisp32, addrSzAttr);
04769           break;
04770         case 1:
04771           macadr->set(apply_rex_bit(mECX, pref->rexB()), *pdisp32, addrSzAttr);
04772           break;
04773         case 2:
04774           macadr->set(apply_rex_bit(mEDX, pref->rexB()), *pdisp32, addrSzAttr);
04775           break;
04776         case 3:
04777           macadr->set(apply_rex_bit(mEBX, pref->rexB()), *pdisp32, addrSzAttr);
04778           break;
04779         case 4:
04780           // disp32[EBP + index<<scale] happens naturally here when base=5
04781            if (loc) { 
04782               loc->disp_position = loc->sib_position + 1;
04783               loc->disp_size = 4;
04784            }
04785           macadr->set_sib(apply_rex_bit(base, pref->rexB()), scale, apply_rex_bit(index, pref->rexX()),
04786               *pdisp32, addrSzAttr);
04787           break;
04788         case 5:
04789           macadr->set(apply_rex_bit(mEBP, pref->rexB()), *pdisp32, addrSzAttr);
04790           break;
04791         case 6:
04792           macadr->set(apply_rex_bit(mESI, pref->rexB()), *pdisp32, addrSzAttr);
04793           break;
04794         case 7:
04795           macadr->set(apply_rex_bit(mEDI, pref->rexB()), *pdisp32, addrSzAttr);
04796           break;
04797         }
04798       }
04799       return nsib + dwordSzB;
04800     default:
04801       assert(0);
04802     }
04803   }
04804   return 0; // MS compiler from VS 6.0 wants this
04805 }
04806 
04807 
04808 static inline int type2size(unsigned int optype, unsigned int operSzAttr)
04809 {
04810   switch(optype) {
04811   case op_a:
04812     return 2 * wordSzB * operSzAttr;
04813   case op_b:
04814     return byteSzB;
04815   case op_c:
04816     assert(!"Where is this used, Intel?");
04817     return byteSzB * operSzAttr;
04818   case op_d:
04819     return dwordSzB;
04820   case op_dq:
04821     return dqwordSzB;
04822   case op_p:
04823     return wordSzB + wordSzB * operSzAttr; // XXX book says operand size...
04824   case op_pd:  // Intel "forgot" to define this in book, but uses it
04825     return dqwordSzB;
04826   case op_pi:
04827     return qwordSzB;
04828   case op_ps:
04829     return dqwordSzB;
04830   case op_q:
04831     return qwordSzB;
04832   case op_s:
04833     return 6;
04834   case op_sd:  // another Intel amnesia case
04835     return qwordSzB;
04836   case op_ss:
04837     return dwordSzB;
04838   case op_si:
04839     assert(!"Where is this used, Intel?");
04840     return dwordSzB;
04841   case op_v:
04842     return wordSzB * operSzAttr;
04843   case op_w:
04844     return wordSzB;
04845   case op_y:
04846       return operSzAttr == 4 ? qwordSzB : dwordSzB;
04847   case op_z:
04848       return operSzAttr == 1 ? wordSzB : dwordSzB;
04849   case op_lea:
04850     //    assert(!"Should not be evaluated");
04851     // We might be called, if we don't know this is an lea ahead of time
04852     // It's okay to return 0 here, because we really don't load/store
04853     return 0;
04854   case op_allgprs:
04855     return 8 * wordSzB * operSzAttr;
04856   case op_512:
04857     return 512;
04858   default:
04859       assert(0);
04860       return 0;
04861 //    RegisterAST reg(optype);
04862 //    return reg.eval().size();
04863   }
04864 }
04865 
04866 unsigned int ia32_decode_operands (const ia32_prefixes& pref, 
04867                                    const ia32_entry& gotit, 
04868                                    const unsigned char* addr, 
04869                                    ia32_instruction& instruct,
04870                                    ia32_memacc *mac)
04871 {
04872   ia32_locations *loc = instruct.loc;
04873   if (loc) loc->imm_cnt = 0;
04874   unsigned int nib = 0 /* # of bytes in instruction */;
04875 
04876   int addrSzAttr = (pref.getPrefix(3) == PREFIX_SZADDR ? 1 : 2);
04877 
04878   if (mode_64)
04879     addrSzAttr *= 2;
04880 
04881   int operSzAttr = getOperSz(pref);
04882 
04883   if(gotit.hasModRM)
04884     nib += byteSzB;
04885 
04886   for(unsigned int i=0; i<3; ++i) {
04887     const ia32_operand& op = gotit.operands[i];
04888     if(op.admet) {
04889       // At most two operands can be memory, the third is register or immediate
04890       //assert(i<2 || op.admet == am_reg || op.admet == am_I);
04891       switch(op.admet) {
04892       case am_A: /* address = segment + offset (word or dword or qword) */
04893         nib += wordSzB; // segment
04894         nib += wordSzB * addrSzAttr;  // + offset (1 or 2 words, depending on prefix)
04895     break;
04896       case am_O: /* operand offset */
04897         nib += wordSzB * addrSzAttr;
04898         if(mac) {
04899           int offset;
04900           switch(addrSzAttr) {
04901           case 1: // 16-bit offset
04902               offset = *((const short int*)addr);
04903               break;
04904           case 2: // 32-bit offset
04905               offset = *((const int*)addr);
04906               break;
04907           case 4: // 64-bit
04908           offset = *((const long*)addr);
04909               break;
04910           default:
04911               assert(0);
04912               break;
04913           }
04914           mac[i].set(-1, offset, addrSzAttr);
04915           mac[i].size = type2size(op.optype, operSzAttr);
04916         }
04917         break;
04918       case am_C:   /* control register */
04919       case am_D:   /* debug register */
04920       case am_F:   /* flags register */
04921       case am_G:   /* general purpose register, selecteb by reg field */
04922       case am_P:   /* MMX register */
04923       case am_R:   /* general purpose register, selected by r/m field */
04924       case am_S:   /* segment register */
04925       case am_T:   /* test register */
04926       case am_V:   /* XMM register */
04927       case am_reg: /* register implicitely encoded in opcode */
04928       case am_allgprs:
04929         break;
04930       case am_E: /* register or memory location, so decoding needed */
04931       case am_M: /* memory operand, decoding needed; size includes modRM byte */
04932       case am_Q: /* MMX register or memory location */
04933       case am_RM:/* register or memory location, so decoding needed */
04934       case am_UM:/* XMM register or memory location */
04935       case am_W: /* XMM register or memory location */
04936          if (loc) {
04937             loc->modrm_position = loc->opcode_size + loc->opcode_position;
04938             loc->modrm_operand = i;
04939          }
04940          if(mac) {
04941             nib += ia32_decode_modrm(addrSzAttr, addr, &mac[i], &pref, loc);
04942             mac[i].size = type2size(op.optype, operSzAttr);
04943             if (loc) loc->address_size = mac[i].size;
04944          }
04945          else
04946             nib += ia32_decode_modrm(addrSzAttr, addr, NULL, &pref, loc);
04947          
04948          // also need to check for AMD64 rip-relative data addressing
04949          // occurs when mod == 0 and r/m == 101
04950          if (mode_64)
04951             if ((addr[0] & 0xc7) == 0x05)
04952                instruct.rip_relative_data = true;
04953          
04954          break;
04955       case am_I: /* immediate data */
04956       case am_J: { /* instruction pointer offset */
04957          int imm_size = type2size(op.optype, operSzAttr);
04958          if (loc) {
04959             // sanity
04960             if(loc->imm_cnt > 1) {
04961                 fprintf(stderr,"Oops, more than two immediate operands\n");
04962             } else {
04963                 loc->imm_position[loc->imm_cnt] = 
04964                     nib + loc->opcode_position + loc->opcode_size;
04965                 loc->imm_size[loc->imm_cnt] = imm_size;
04966                 ++loc->imm_cnt;
04967             }
04968          }
04969          nib += imm_size;
04970          break;
04971       }
04972       /* TODO: rep prefixes, deal with them here? */
04973       case am_X: /* memory at DS:(E)SI*/
04974         if(mac)
04975           mac[i].setXY(mESI, type2size(op.optype, operSzAttr), addrSzAttr);
04976         break;
04977       case am_Y: /* memory at ES:(E)DI*/
04978         if(mac)
04979           mac[i].setXY(mEDI, type2size(op.optype, operSzAttr), addrSzAttr);
04980         break;
04981       case am_stackH: /* stack push */
04982       case am_stackP: /* stack pop */
04983     assert(0 && "Wrong table!");
04984         break;
04985       case am_tworeghack:
04986       case am_ImplImm:
04987     // Don't do nuthin'
04988     break;
04989       default:
04990         assert(0 && "Bad addressing mode!");
04991       }
04992     }
04993     else
04994       break;
04995   }
04996   if((gotit.id == e_push) && mac)
04997   {
04998     // assuming 32-bit (64-bit for AMD64) stack segment
04999     // AMD64: push defaults to 64-bit operand size
05000     if (mode_64 && operSzAttr == 2)
05001       operSzAttr = 4;
05002     mac[1].set(mESP, -2 * operSzAttr, addrSzAttr);
05003     if(gotit.operands[0].admet == am_reg)
05004     {
05005         mac[1].size = type2size(op_v, operSzAttr);
05006     }
05007     else
05008     {
05009         mac[1].size = type2size(gotit.operands[0].optype, operSzAttr);
05010     }
05011     mac[1].write = true;
05012   }
05013   if((gotit.id == e_pop) && mac)
05014   {
05015     // assuming 32-bit (64-bit for AMD64) stack segment
05016     // AMD64: pop defaults to 64-bit operand size
05017     if (mode_64 && operSzAttr == 2)
05018       operSzAttr = 4;
05019     mac[1].set(mESP, 0, addrSzAttr);
05020     if(gotit.operands[0].admet == am_reg)
05021     {
05022         mac[1].size = type2size(op_v, operSzAttr);
05023     }
05024     else
05025     {
05026         mac[1].size = type2size(gotit.operands[0].optype, operSzAttr);
05027     }
05028     mac[1].read = true;
05029   }
05030   if((gotit.id == e_leave) && mac)
05031   {
05032     // assuming 32-bit (64-bit for AMD64) stack segment
05033     // AMD64: push defaults to 64-bit operand size
05034     if (mode_64 && operSzAttr == 2)
05035       operSzAttr = 4;
05036     mac[0].set(mESP, 0, addrSzAttr);
05037     mac[0].size = type2size(op_v, operSzAttr);
05038     mac[0].read = true;
05039   }
05040   if((gotit.id == e_ret_near || gotit.id == e_ret_far) && mac)
05041   {
05042     mac[0].set(mESP, 0, addrSzAttr);
05043     mac[0].size = type2size(op_v, addrSzAttr);
05044     mac[0].read = true;
05045   }
05046   if((gotit.id == e_call) && mac)
05047   {
05048     int index = 0;
05049     while((mac[index].regs[0] != -1) ||
05050           (mac[index].regs[1] != -1) ||
05051           (mac[index].scale != 0) ||
05052           (mac[index].imm != 0)) {
05053         index++;
05054         assert(index < 3);
05055     }
05056     mac[index].set(mESP, -2 * addrSzAttr, addrSzAttr);
05057       mac[index].size = type2size(op_v, addrSzAttr);
05058       mac[index].write = true;
05059             
05060   }
05061   
05062   instruct.size += nib;
05063   return nib;
05064 }
05065 
05066 
05067 static const unsigned char sse_prefix[256] = {
05068   /*       0 1 2 3 4 5 6 7 8 9 A B C D E F  */
05069   /* 0x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05070   /* 1x */ 1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,
05071   /* 2x */ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
05072   /* 3x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05073   /* 4x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05074   /* 5x */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
05075   /* 6x */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
05076   /* 7x */ 1,1,1,1,1,1,1,0,1,1,0,0,1,1,1,1, // Grp12-14 are SSE groups
05077   /* 8x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05078   /* 9x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05079   /* Ax */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05080   /* Bx */ 0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,
05081   /* Cx */ 0,0,1,0,1,1,1,0,0,0,0,0,0,0,0,0,
05082   /* Dx */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
05083   /* Ex */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
05084   /* Fx */ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
05085 };
05086 
05087 static const unsigned char sse_prefix_bis[256] = {
05088   /*       0 1 2 3 4 5 6 7 8 9 A B C D E F  */
05089   /* 0x */ 1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,
05090   /* 1x */ 1,0,0,0,1,1,0,1,0,0,0,0,1,1,1,0,
05091   /* 2x */ 1,1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,
05092   /* 3x */ 1,1,1,1,1,1,0,1,1,1,1,1,1,1,1,1,
05093   /* 4x */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05094   /* 5x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05095   /* 6x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05096   /* 7x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05097   /* 8x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05098   /* 9x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05099   /* Ax */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05100   /* Bx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05101   /* Cx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05102   /* Dx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05103   /* Ex */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05104   /* Fx */ 1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05105 };
05106 
05107 static const unsigned char sse_prefix_ter[256] = {
05108   /*       0 1 2 3 4 5 6 7 8 9 A B C D E F  */
05109   /* 0x */ 0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,
05110   /* 1x */ 0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,0,
05111   /* 2x */ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
05112   /* 3x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05113   /* 4x */ 1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,
05114   /* 5x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05115   /* 6x */ 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,
05116   /* 7x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05117   /* 8x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05118   /* 9x */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05119   /* Ax */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05120   /* Bx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05121   /* Cx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05122   /* Dx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05123   /* Ex */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05124   /* Fx */ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
05125 };
05126 
05127 #define REX_ISREX(x) (((x) >> 4) == 4)
05128 
05129 bool is_sse_opcode(unsigned char byte1, unsigned char byte2, unsigned char byte3) {
05130     if((byte1==0x0F && sse_prefix[byte2])
05131             || (byte1==0x0F && byte2==0x38 && sse_prefix_bis[byte3])
05132             || (byte1==0x0F && byte2==0x3A && sse_prefix_ter[byte3]))
05133         return true;
05134     
05135     return false;
05136 }
05137 
05138 // FIXME: lookahead might blow up...
05139 bool ia32_decode_prefixes(const unsigned char* addr, ia32_prefixes& pref,
05140                           ia32_locations *loc)
05141 {
05142   pref.count = 0;
05143   pref.prfx[0] = pref.prfx[1] = pref.prfx[2] = pref.prfx[3] = pref.prfx[4] = 0;
05144   pref.opcode_prefix = 0;
05145   bool in_prefix = true;
05146 
05147   while(in_prefix) {
05148     switch(addr[0]) {
05149     case PREFIX_REPNZ:
05150     case PREFIX_REP:
05151        if(mode_64 && REX_ISREX(addr[1]) && is_sse_opcode(addr[2],addr[3],addr[4])) {
05152           ++pref.count;
05153           pref.opcode_prefix = addr[0];
05154           break;
05155        }
05156        else if(is_sse_opcode(addr[1],addr[2],addr[3])) {
05157           ++pref.count;
05158           pref.opcode_prefix = addr[0];
05159           break;
05160        }
05161        
05162     case PREFIX_LOCK:
05163        ++pref.count;
05164        pref.prfx[0] = addr[0];
05165        break;
05166     case PREFIX_SEGCS:
05167     case PREFIX_SEGSS:
05168     case PREFIX_SEGDS:
05169     case PREFIX_SEGES:
05170     case PREFIX_SEGFS:
05171     case PREFIX_SEGGS:
05172        ++pref.count;
05173        pref.prfx[1] = addr[0];
05174        break;
05175     case PREFIX_SZOPER:
05176        if(is_sse_opcode(addr[1],addr[2],addr[3])) {
05177           pref.opcode_prefix = addr[0];
05178           break;
05179        }
05180        if(mode_64 && REX_ISREX(addr[1]) && is_sse_opcode(addr[2],addr[3],addr[4])) {
05181           ++pref.count;
05182           pref.opcode_prefix = addr[0];
05183           break;
05184        }
05185        ++pref.count;
05186        pref.prfx[2] = addr[0];
05187        break;
05188     case PREFIX_SZADDR:
05189        ++pref.count;
05190        pref.prfx[3] = addr[0];
05191        break;
05192     default:
05193        in_prefix=false;
05194     }
05195     
05196     ++addr;
05197   }
05198 
05199   bool result = true;
05200   if (mode_64)
05201      result = ia32_decode_rex(addr - 1, pref, loc);
05202   if (loc) loc->num_prefixes = pref.count;
05203 
05204   return result;
05205 }
05206 
05207 #define REX_W(x) ((x) & 0x8)
05208 #define REX_R(x) ((x) & 0x4)
05209 #define REX_X(x) ((x) & 0x2)
05210 #define REX_B(x) ((x) & 0x1)
05211 
05212 #define REX_INIT(x) ((x) = 0x40)
05213 #define REX_SET_W(x, v) ((x) |= ((v) ? 0x8 : 0))
05214 #define REX_SET_R(x, v) ((x) |= ((v) ? 0x4 : 0))
05215 #define REX_SET_X(x, v) ((x) |= ((v) ? 0x2 : 0))
05216 #define REX_SET_B(x, v) ((x) |= ((v) ? 0x1 : 0))
05217 
05218 bool ia32_decode_rex(const unsigned char* addr, ia32_prefixes& pref,
05219                      ia32_locations *loc)
05220 {
05221    if (REX_ISREX(addr[0])) {
05222      
05223       ++pref.count;
05224       pref.prfx[4] = addr[0];
05225 
05226       if (loc) {
05227          loc->rex_byte = addr[0];
05228          loc->rex_w = REX_W(addr[0]);
05229          loc->rex_r = REX_R(addr[0]);
05230          loc->rex_x = REX_X(addr[0]);
05231          loc->rex_b = REX_B(addr[0]);
05232          loc->rex_position = pref.count - 1;
05233       }
05234       
05235       // it is an error to have legacy prefixes after a REX prefix
05236       // in particular, ia32_decode will get confused if a prefix
05237       // that could be used as an SSE opcode extension follows our
05238       // REX
05239       if (addr[1] == PREFIX_SZOPER || addr[1] == PREFIX_REPNZ || addr[1] == PREFIX_REP)
05240       {
05241          return false;
05242       }
05243    }
05244 
05245    return true;
05246 }
05247 
05248 unsigned int ia32_emulate_old_type(ia32_instruction& instruct)
05249 {
05250   const ia32_prefixes& pref = instruct.prf;
05251   unsigned int& insnType = instruct.legacy_type;
05252 
05253   unsigned int operSzAttr = getOperSz(pref);
05254 
05255   if (pref.getPrefix(0)) // no distinction between these
05256     insnType |= PREFIX_INST;
05257   if (pref.getPrefix(3) == PREFIX_SZADDR)
05258     insnType |= PREFIX_ADDR;
05259   if (pref.getPrefix(2) == PREFIX_SZOPER)
05260     insnType |= PREFIX_OPR;
05261   if (pref.getPrefix(1))
05262     insnType |= PREFIX_SEG; // no distinction between segments
05263   if (mode_64 && pref.getPrefix(4))
05264     insnType |= PREFIX_REX;
05265   if (pref.getOpcodePrefix())
05266       insnType |= PREFIX_OPCODE;
05267 
05268   // this still works for AMD64, since there is no "REL_Q"
05269   // actually, it will break if there is both a REX.W and operand
05270   // size prefix, since REX.W takes precedence (FIXME)
05271   if (insnType & REL_X) {
05272     if (operSzAttr == 1)
05273       insnType |= REL_W;
05274     else
05275       insnType |= REL_D;
05276   }
05277   else if (insnType & PTR_WX) {
05278     if (operSzAttr == 1)
05279       insnType |= PTR_WW;
05280     else
05281       insnType |= PTR_WD;
05282   }
05283 
05284   // AMD64 rip-relative data
05285   if (instruct.hasRipRelativeData())
05286       insnType |= REL_D_DATA;
05287 
05288   return insnType;
05289 }
05290 
05291 /* decode instruction at address addr, return size of instruction */
05292 unsigned get_instruction(const unsigned char* addr, unsigned &insnType,
05293              const unsigned char** op_ptr)
05294 {
05295   int r1;
05296 
05297   ia32_instruction i;
05298   ia32_decode(0, addr, i);
05299 
05300   r1 = i.getSize();
05301   insnType = ia32_emulate_old_type(i);
05302   if (op_ptr)
05303       *op_ptr = addr + i.getPrefixCount();
05304 
05305   return r1;
05306 }
05307 
05308 // find the target of a jump or call
05309 Address get_target(const unsigned char *instr, unsigned type, unsigned size,
05310            Address addr) {
05311 #if defined(os_vxworks)
05312     Address ret;
05313     // FIXME requires vxworks in Dyninst
05314     if (relocationTarget(addr+1, &ret))
05315         return ret;
05316 #endif
05317   int disp = displacement(instr, type);
05318   return (Address)(addr + size + disp);
05319 }
05320 
05321 // get the displacement of a jump or call
05322 int displacement(const unsigned char *instr, unsigned type) {
05323 
05324   int disp = 0;
05325   //skip prefix
05326   instr = skip_headers( instr );
05327 
05328   if (type & REL_D_DATA) {
05329     // Some SIMD instructions have a mandatory 0xf2 prefix; the call to skip_headers
05330     // doesn't skip it and I don't feel confident in changing that - bernat, 22MAY06
05331       // 0xf3 as well...
05332       // Some 3-byte opcodes start with 0x66... skip
05333       if (*instr == 0x66) instr++;
05334       if (*instr == 0xf2) instr++;
05335       else if (*instr == 0xf3) instr++;
05336     // And the "0x0f is a 2-byte opcode" skip
05337     if (*instr == 0x0F) {
05338         instr++;
05339         // And the "0x38 or 0x3A is a 3-byte opcode" skip
05340         if(*instr == 0x38 || *instr == 0x3A)  instr++;
05341     }
05342     // Skip the instr opcode and the MOD/RM byte
05343     disp = *(const int *)(instr+2);
05344   } else if (type & IS_JUMP) {
05345     if (type & REL_B) {
05346       disp = *(const char *)(instr+1);
05347     } else if (type & REL_W) {
05348       disp = *(const short *)(instr+1); // skip opcode
05349     } else if (type & REL_D) {
05350       disp = *(const int *)(instr+1);
05351     }
05352   } else if (type & IS_JCC) {
05353     if (type & REL_B) {
05354       disp = *(const char *)(instr+1);
05355     } else if (type & REL_W) {
05356       disp = *(const short *)(instr+2); // skip two byte opcode
05357     } else if (type & REL_D) {
05358       disp = *(const int *)(instr+2);   // skip two byte opcode
05359     }
05360   } else if (type & IS_CALL) {
05361     if (type & REL_W) {
05362       disp = *(const short *)(instr+1); // skip opcode
05363     } else if (type & REL_D) {
05364       disp = *(const int *)(instr+1);
05365     }
05366   }  
05367 
05368   return disp;
05369 }
05370 
05371 int count_prefixes(unsigned insnType) {
05372   unsigned nPrefixes = 0;
05373   if (insnType & PREFIX_OPR)
05374     nPrefixes++;
05375   if (insnType & PREFIX_SEG)
05376     nPrefixes++;
05377   if (insnType & PREFIX_OPCODE)
05378     nPrefixes++;
05379   if (insnType & PREFIX_REX)
05380     nPrefixes++;
05381   if (insnType & PREFIX_INST)
05382     nPrefixes++;
05383   if (insnType & PREFIX_ADDR)
05384     nPrefixes++;
05385   return nPrefixes;
05386 }
05387 
05388 unsigned copy_prefixes(const unsigned char *&origInsn, unsigned char *&newInsn, unsigned insnType) {
05389   unsigned nPrefixes = count_prefixes(insnType);
05390 
05391   for (unsigned u = 0; u < nPrefixes; u++)
05392      *newInsn++ = *origInsn++;
05393   return nPrefixes;
05394 }
05395 
05396 //Copy all prefixes but the Operand-Size and Address-Size prefixes (0x66 and 0x67)
05397 unsigned copy_prefixes_nosize(const unsigned char *&origInsn, unsigned char *&newInsn, 
05398                               unsigned insnType) 
05399 {
05400   unsigned nPrefixes = count_prefixes(insnType);
05401 
05402   for (unsigned u = 0; u < nPrefixes; u++) {
05403      if (*origInsn == 0x66 || *origInsn == 0x67)
05404      {
05405         origInsn++;
05406         continue;
05407      }
05408      *newInsn++ = *origInsn++;
05409   }
05410   return nPrefixes;
05411 }
05412 
05413 bool convert_to_rel8(const unsigned char*&origInsn, unsigned char *&newInsn) {
05414   if (*origInsn == 0x0f)
05415     origInsn++;
05416 
05417   // We think that an opcode in the 0x8? range can be mapped to an equivalent
05418   // opcode in the 0x7? range...
05419 
05420   if ((*origInsn >= 0x70) &&
05421       (*origInsn < 0x80)) {
05422     *newInsn++ = *origInsn++;
05423     return true;
05424   }
05425 
05426   if ((*origInsn >= 0x80) &&
05427       (*origInsn < 0x90)) {
05428     *newInsn++ = *origInsn++ - 0x10;
05429     return true;
05430   }
05431 
05432   if (*origInsn == 0xE3) {
05433     *newInsn++ = *origInsn++;
05434     return true;
05435   }
05436 
05437   // Oops...
05438   fprintf(stderr, "Unhandled jump conversion case: opcode is 0x%x\n", *origInsn);
05439   assert(0 && "Unhandled jump conversion case!");
05440   return false;
05441 }
05442 
05443 bool convert_to_rel32(const unsigned char*&origInsn, unsigned char *&newInsn) {
05444   if (*origInsn == 0x0f)
05445     origInsn++;
05446   *newInsn++ = 0x0f;
05447 
05448   // We think that an opcode in the 0x7? range can be mapped to an equivalent
05449   // opcode in the 0x8? range...
05450 
05451   if ((*origInsn >= 0x70) &&
05452       (*origInsn < 0x80)) {
05453     *newInsn++ = *origInsn++ + 0x10;
05454     return true;
05455   }
05456 
05457   if ((*origInsn >= 0x80) &&
05458       (*origInsn < 0x90)) {
05459     *newInsn++ = *origInsn++;
05460     return true;
05461   }
05462 
05463   // Oops...
05464   fprintf(stderr, "Unhandled jump conversion case: opcode is 0x%x\n", *origInsn);
05465   assert(0 && "Unhandled jump conversion case!");
05466   return false;
05467 }
05468   
05469 
05470 
05471 //Determine appropriate scale, index, and base given SIB byte.
05472 void decode_SIB(unsigned sib, unsigned& scale, Register& index_reg, Register& base_reg){
05473   scale = sib >> 6;
05474   
05475   //scale = 2^scale
05476   if(scale == 0)
05477     scale = 1;
05478   else if(scale == 1)
05479     scale = 2;
05480   else if(scale == 2)
05481     scale = 4;
05482   else if(scale == 3)
05483     scale = 8;
05484 
05485   index_reg = (sib >> 3) & 0x07;
05486   base_reg = sib & 0x07;
05487 }
05488 
05489 const unsigned char*
05490 skip_headers(const unsigned char* addr, ia32_prefixes* prefs)
05491 {
05492   ia32_prefixes default_prefs;
05493   if (prefs == NULL)
05494       prefs = &default_prefs;
05495   ia32_decode_prefixes(addr, *prefs);
05496   return addr + prefs->getCount();
05497 }
05498 
05499 bool insn_hasSIB(unsigned ModRMbyte,unsigned& Mod,unsigned& Reg,unsigned& RM){
05500     Mod = (ModRMbyte >> 6) & 0x03;
05501     Reg = (ModRMbyte >> 3) & 0x07;
05502     RM = ModRMbyte & 0x07;
05503     return ((Mod != 3) && (RM == 4));
05504 }
05505 
05506 bool insn_hasDisp8(unsigned ModRMbyte){
05507     unsigned Mod = (ModRMbyte >> 6) & 0x03;
05508     return (Mod == 1);
05509 }
05510 
05511 bool insn_hasDisp32(unsigned ModRMbyte){
05512     unsigned Mod = (ModRMbyte >> 6) & 0x03;
05513     /* unsigned Reg = (ModRMbyte >> 3) & 0x07; */
05514     unsigned RM = ModRMbyte & 0x07;
05515     return (Mod == 0 && RM == 5) || (Mod == 2);
05516 }
05517 
05518 // We keep an array-let that represents various fixed
05519 // insns
05520 unsigned char illegalRep[2] = {0x0f, 0x0b};
05521 unsigned char trapRep[1] = {0xCC};
05522  
05523 
05524 const char* ia32_entry::name(ia32_locations* loc)
05525 {
05526   dyn_hash_map<entryID, string>::const_iterator found = entryNames_IAPI.find(id);
05527   if(found != entryNames_IAPI.end())
05528   {
05529     return found->second.c_str();
05530   }
05531   if(loc)
05532   {
05533     if(otable == t_grp && (tabidx == Grp2 || tabidx == Grp11))
05534     {
05535       int reg = loc->modrm_reg;
05536       found = entryNames_IAPI.find(groupMap[tabidx][reg].id);
05537       if(found != entryNames_IAPI.end())
05538       {
05539     return found->second.c_str();
05540       }
05541     }
05542   }
05543   return NULL;
05544 }
05545 
05546 entryID ia32_entry::getID(ia32_locations* l) const
05547 {
05548   if((id != e_No_Entry) || (tabidx == t_done) || (l == NULL))
05549   {
05550     return id;
05551   }
05552   int reg = l->modrm_reg;
05553   switch(otable)
05554   {
05555   case t_grp:
05556     switch(tabidx)
05557     {
05558     case Grp2:
05559     case Grp11:
05560       return groupMap[tabidx][reg].id;
05561       break;
05562     default:
05563       break;
05564     }
05565   case t_coprocEsc:
05566       return e_fp_generic;
05567       case t_3dnow:
05568           return e_3dnow_generic;
05569       default:
05570     break;
05571   }
05572   return id;
05573 }
05574 
05575 Address get_immediate_operand(instruction *instr)
05576 {
05577     ia32_memacc mac[3];
05578     ia32_condition cond;
05579     ia32_locations loc;
05580     ia32_instruction detail(mac,&cond,&loc);
05581 
05582     ia32_decode(IA32_FULL_DECODER,(const unsigned char *)(instr->ptr()),detail);
05583 
05584     // now find the immediate value in the locations
05585     Address immediate = 0;
05586 
05587     switch(loc.imm_size[0]) {
05588         case 8:
05589             immediate = *(const unsigned long*)(instr->ptr()+loc.imm_position[0]);
05590             break;
05591         case 4:
05592             immediate = *(const unsigned int*)(instr->ptr()+loc.imm_position[0]);
05593             break;
05594         case 2:
05595             immediate = *(const unsigned short*)(instr->ptr()+loc.imm_position[0]);
05596             break;
05597         case 1:
05598             immediate = *(const unsigned char*)(instr->ptr()+loc.imm_position[0]);
05599             break;
05600         default:
05601             fprintf(stderr,"%s[%u]:  invalid immediate size %d in insn\n",
05602                 FILE__,__LINE__,loc.imm_size[0]);
05603             break;
05604     }
05605 
05606     return immediate;
05607 }
05608 
05609 // get the displacement of a relative jump or call
05610 
05611 int get_disp(instruction *insn) {
05612   return displacement(insn->ptr(), insn->type());
05613 }
05614 
05615 bool isStackFramePrecheck_gcc( const unsigned char *buffer )
05616 {
05617    //Currently enabled entry bytes for gaps:
05618    //  0x55 - push %ebp
05619    static char gap_initial_bytes[] =
05620       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05621         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05622         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05623         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05624         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05625         0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05626         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05627         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05628         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05629         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05630         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05631         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05632         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05633         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05634         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05635         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
05636    return (gap_initial_bytes[*buffer] != 0);
05637 }  
05638 
05639 bool isStackFramePrecheck_msvs( const unsigned char *buffer )
05640 {
05641    //Currently enabled entry bytes for gaps:
05642    //  0x55 - push %ebp
05643    static char gap_initial_bytes[] =
05644       { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05645         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05646         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05647         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05648         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05649         0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05650         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05651         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05652         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05653         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05654         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05655         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05656         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05657         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05658         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
05659         0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
05660    return (gap_initial_bytes[*buffer] != 0);
05661 }  
05662 
05663 /*
05664 bool isStackFramePreamble( instruction& insn1 )
05665 {       
05666     instruction insn2, insn3;
05667     insn2.setInstruction( insn1.ptr() + insn1.size() );       
05668     insn3.setInstruction( insn2.ptr() + insn2.size() );
05669 
05670     const unsigned char* p = insn1.op_ptr();
05671     const unsigned char* q = insn2.op_ptr();
05672     const unsigned char* r = insn3.op_ptr();
05673     
05674     unsigned Mod1_1 =  ( q[ 1 ] >> 3 ) & 0x07;
05675     unsigned Mod1_2 =  q[ 1 ] & 0x07;
05676     unsigned Mod2_1 =  ( r[ 1 ] >> 3 ) & 0x07;
05677     unsigned Mod2_2 =  r[ 1 ] & 0x07;
05678 
05679     if( insn1.size() != 1 )
05680     {
05681         return false;  //shouldn't need this, but you never know
05682     }
05683     
05684     if( p[ 0 ] == PUSHEBP  )
05685     {   
05686         // Looking for mov %esp -> %ebp in one of the two
05687         // following instructions.  There are two ways to encode 
05688         // mov %esp -> %ebp: as '0x8b 0xec' or as '0x89 0xe5'.  
05689         if( insn2.isMoveRegMemToRegMem() && 
05690             ((Mod1_1 == 0x05 && Mod1_2 == 0x04) ||
05691              (Mod1_1 == 0x04 && Mod1_2 == 0x05)))
05692             return true;
05693 
05694         if( insn3.isMoveRegMemToRegMem() && 
05695             ((Mod2_1 == 0x05 && Mod2_2 == 0x04) ||
05696              (Mod2_1 == 0x04 && Mod2_2 == 0x05)))
05697             return true;
05698     }
05699     
05700     return false;
05701 }
05702 */
05703 
05704 instruction *instruction::copy() const {
05705     // Or should we copy? I guess it depends on who allocated
05706     // the memory...
05707     return new instruction(*this);
05708 }
05709 
05710 unsigned instruction::spaceToRelocate() const {
05711     // List of instructions that might be painful:
05712     // jumps (displacement will change)
05713     // call (displacement will change)
05714     // PC-relative ops
05715 
05716     // TODO: pc-relative ops
05717 
05718     // longJumpSize == size of code needed to get
05719     // anywhere in memory space.
05720 #if defined(arch_x86_64)
05721     const int longJumpSize = JUMP_ABS64_SZ;
05722 #else
05723     const int longJumpSize = JUMP_ABS32_SZ;
05724 #endif
05725 
05726 
05727     // Assumption: rewriting calls into immediates will
05728     // not be larger than rewriting a call into a call...
05729 
05730     if (!((type() & REL_B) ||
05731       (type() & REL_W) ||
05732       (type() & REL_D) ||
05733       (type() & REL_D_DATA))) {
05734       return size();
05735     }
05736     
05737     // Now that the easy case is out of the way...
05738     
05739     if (type() & IS_JUMP) {
05740       // Worst-case: prefixes + max-displacement branch
05741       return count_prefixes(type()) + longJumpSize;
05742     }
05743     if (type() & IS_JCC) {
05744       // Jump conditional; jump past jump; long jump
05745       return count_prefixes(type()) + 2 + 2 + longJumpSize;
05746     }
05747     if (type() & IS_CALL) {
05748       // Worst case is approximated by two long jumps (AMD64) or a REL32 (x86)
05749       unsigned size;
05750 #if defined(arch_x86_64)
05751       size = 2*JUMP_ABS64_SZ+count_prefixes(type());
05752 #else
05753       size = JUMP_SZ+count_prefixes(type());
05754 #endif
05755       size = (size > CALL_RELOC_THUNK) ? size : CALL_RELOC_THUNK;
05756       return size;
05757     }
05758 #if defined(arch_x86_64)
05759     if (type() & REL_D_DATA) {
05760       // Worst-case: replace RIP with push of IP, use, and cleanup
05761       // 8: unknown; previous constant
05762       return count_prefixes(type()) + size() + 8;
05763     }
05764 #endif
05765 
05766     assert(0);
05767     return 0;
05768 }
05769 
05770 #if defined(arch_x86_64)
05771 unsigned instruction::jumpSize(long disp, unsigned addr_width) 
05772 {
05773    if (addr_width == 8 && !is_disp32(disp))
05774       return JUMP_ABS64_SZ;
05775    return JUMP_SZ;
05776 }
05777 #else
05778 unsigned instruction::jumpSize(long /*disp*/, unsigned /*addr_width*/) 
05779 {
05780    return JUMP_SZ;
05781 }
05782 #endif
05783 
05784 unsigned instruction::jumpSize(Address from, Address to, unsigned addr_width) 
05785 {
05786     long disp = to - (from + JUMP_SZ);
05787     return jumpSize(disp, addr_width);
05788 }
05789 
05790 #if defined(arch_x86_64)
05791 unsigned instruction::maxJumpSize(unsigned addr_width) 
05792 {
05793    if (addr_width == 8)
05794       return JUMP_ABS64_SZ;
05795    return JUMP_SZ;
05796 }
05797 #else
05798 unsigned instruction::maxJumpSize(unsigned /*addr_width*/) 
05799 {
05800    return JUMP_SZ;
05801 }
05802 #endif
05803 
05804 bool instruction::isCmp() const {
05805     if(*op_ptr_ == CMP_EB_GB || *op_ptr_ == CMP_EV_GV ||
05806        *op_ptr_ == CMP_GB_EB || *op_ptr_ == CMP_GV_EV ||
05807        *op_ptr_ == CMP_AL_LB || *op_ptr_ == CMP_RAX_LZ)
05808     {
05809         return true;
05810     }
05811 
05812     if(*op_ptr_ == 0x80 || *op_ptr_ == 0x81 || *op_ptr_ == 0x83) 
05813     {
05814         // group 1 opcodes -- operation depends on reg (bits 3-5) of
05815         // modr/m byte
05816         const unsigned char *p = op_ptr_+1;
05817         if( (*p & (7<<3)) == (7<<3))
05818             return true;
05819     }
05820 
05821     return false;
05822 }
05823 
05824 #define SIB_SET_REG(x, y) ((x) |= ((y) & 7))
05825 #define SIB_SET_INDEX(x, y) ((x) |= (((y) & 7) << 3))
05826 #define SIB_SET_SS(x, y) ((x) | (((y) & 3) << 6))
05827 
05828 bool instruction::getUsedRegs(pdvector<int> &regs) {
05829    const unsigned char *insn_ptr = ptr();
05830 
05831    struct ia32_memacc memacc[3];
05832    struct ia32_condition cond;
05833    class ia32_locations loc;
05834    ia32_entry *entry;
05835    ia32_instruction orig_instr(memacc, &cond, &loc);
05836    ia32_decode(IA32_DECODE_MEMACCESS | IA32_DECODE_CONDITION,
05837                insn_ptr, orig_instr);
05838    entry = orig_instr.getEntry();
05839 
05840    if (orig_instr.getPrefix()->getPrefix(1) != 0)
05841       //The instruction accesses memory via segment registers.  Disallow.
05842       return false;
05843    
05844    if (loc.modrm_position == -1)
05845       //Only supporting MOD/RM instructions now
05846       return false; 
05847 
05848    if (loc.address_size == 1)
05849       //Don't support 16-bit instructions yet
05850       return false;
05851 
05852    if (loc.modrm_reg == 4 && !loc.rex_r)
05853       //The non-memory access register is %rsp/%esp, we can't work with
05854       // this register due to our register saving techniques.
05855       return false;
05856 
05857    if (loc.modrm_mod == 3)
05858       //This instruction doesn't use the MOD/RM to access memory
05859       return false;
05860 
05861    for (unsigned i=0; i<3; i++) {
05862       const ia32_operand& op = entry->operands[i];
05863       if (op.admet == am_O) {
05864          //The MOD/RM specifies a register that's used
05865          int regused = loc.modrm_reg;
05866          if (loc.address_size == 4) {
05867             regused |= loc.rex_r << 4;
05868          }
05869          regs.push_back(regused);
05870       }
05871       else if (op.admet == am_reg) {
05872     //using namespace Dyninst::InstructionAPI;
05873          //The instruction implicitely references a memory instruction
05874          switch (op.optype) {
05875              case x86::iah:   
05876              case x86::ial:
05877              case x86::iax:   
05878              case x86::ieax:
05879                regs.push_back(REGNUM_RAX);
05880                if (loc.rex_byte) regs.push_back(REGNUM_R8);
05881                break;
05882              case x86::ibh:
05883              case x86::ibl:
05884              case x86::ibx:
05885              case x86::iebx:
05886                regs.push_back(REGNUM_RBX);
05887                if (loc.rex_byte) regs.push_back(REGNUM_R11);
05888                break;
05889              case x86::ich:
05890              case x86::icl:
05891              case x86::icx:
05892              case x86::iecx:
05893                  regs.push_back(REGNUM_RCX);
05894                if (loc.rex_byte) regs.push_back(REGNUM_R9);
05895                break;
05896              case x86::idh:
05897              case x86::idl:
05898              case x86::idx:
05899              case x86::iedx:
05900                  regs.push_back(REGNUM_RDX);
05901                if (loc.rex_byte) regs.push_back(REGNUM_R10);
05902                break;
05903              case x86::isp:
05904              case x86::iesp:
05905                 regs.push_back(REGNUM_RSP);
05906                if (loc.rex_byte) regs.push_back(REGNUM_R12);
05907                break;
05908              case x86::ibp:
05909              case x86::iebp:
05910                regs.push_back(REGNUM_RBP);
05911                if (loc.rex_byte) regs.push_back(REGNUM_R13);
05912                break;
05913              case x86::isi:
05914              case x86::iesi:
05915                regs.push_back(REGNUM_RSI);
05916                if (loc.rex_byte) regs.push_back(REGNUM_R14);
05917                break;
05918              case x86::idi:
05919              case x86::iedi:
05920                regs.push_back(REGNUM_RDI);
05921                if (loc.rex_byte) regs.push_back(REGNUM_R15);
05922                break;
05923             case op_edxeax:
05924                regs.push_back(REGNUM_RAX);
05925                regs.push_back(REGNUM_RDX);
05926                break;
05927             case op_ecxebx:
05928                regs.push_back(REGNUM_RBX);
05929                regs.push_back(REGNUM_RCX);
05930                break;
05931          }
05932       }
05933    }
05934    return true;
05935 }
05936 
05937 int instruction::getStackDelta()
05938 {
05939    ia32_instruction instruc;
05940    const unsigned char *p = ptr();
05941    ia32_decode(0, ptr(), instruc);
05942 
05943    if (instruc.getEntry()->id == e_push)
05944       return -4;
05945    if (instruc.getEntry()->id == e_pop)
05946       return 4;
05947    if (instruc.getEntry()->id == e_pusha)
05948       return (-2 * 9);
05949    if (instruc.getEntry()->id == e_pushad)
05950       return (-4 * 9);
05951    if (instruc.getEntry()->id == e_popa)
05952       return (2 * 9);
05953    if (instruc.getEntry()->id == e_popad)
05954       return (4 * 9);
05955 
05956    if (p[0] == 0x83 && p[1] == 0xec) {
05957       //Subtract byte
05958       return -1 * (signed char) p[2];
05959    }
05960 
05961    if (p[0] == 0x83 && p[1] == 0xc4) {
05962       //Add byte
05963       return (signed char) p[2];
05964    }
05965    
05966    return 0;
05967 }
05968 
05969 bool instruction::isNop() const
05970 { 
05971 
05972    int displacement_location = 0;
05973    int displacement_size = 0;
05974    if (!(type_ & IS_NOP)) //NOP or LEA
05975       return false;
05976 
05977    if (*op_ptr_ == NOP) {
05978       return true;
05979    }
05980 
05981    ia32_memacc mac[3];
05982    ia32_condition cnd;
05983    ia32_locations loc;
05984 
05985    ia32_instruction instruc(mac, &cnd, &loc);
05986 
05987    ia32_decode(IA32_FULL_DECODER, ptr(), instruc);
05988 
05989 
05990    if (instruc.getEntry()->id == e_nop) {
05991       return true;
05992    }
05993 
05994    if (loc.modrm_mod == 3) {
05995       return false;
05996    }
05997    if (loc.modrm_mod == 0 && loc.modrm_rm == 5) {
05998       return false;
05999    }
06000 
06001    if (loc.rex_x) {
06002       return false;
06003    }
06004    if (loc.rex_r != loc.rex_b) {
06005       return false;
06006    }
06007 
06008    if (loc.disp_position != -1) {
06009       for (unsigned i=0; i<loc.disp_size; i++) {
06010          if (ptr_[i + loc.disp_position] != 0) {
06011             return false;
06012          }
06013       }
06014       displacement_location = loc.disp_position;
06015       displacement_size = loc.disp_size;
06016    }
06017    
06018    if (loc.modrm_rm == 4) {
06019       unsigned scale;
06020       Register index, base;
06021       decode_SIB(loc.sib_byte, scale, index, base);
06022       
06023       if (index != 4) {
06024          return false;
06025       }
06026 
06027       if (base != loc.modrm_reg) {
06028          return false;
06029       }
06030    }
06031    else if (loc.modrm_reg != loc.modrm_rm) {
06032       return false;
06033    }
06034 
06035 
06036    return true;
06037 }
06038 
06039 } // namespace arch_x86
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on 12 Jul 2013 for SymtabAPI by  doxygen 1.6.1