Back to index

plt-scheme  4.2.1
asm.h
Go to the documentation of this file.
00001 /******************************** -*- C -*- ****************************
00002  *
00003  *     Run-time assembler for the i386
00004  *
00005  ***********************************************************************/
00006 
00007 
00008 /***********************************************************************
00009  *
00010  * Copyright 1999, 2000, 2001, 2002 Ian Piumarta
00011  *
00012  * This file is part of GNU lightning.
00013  *
00014  * GNU lightning is free software; you can redistribute it and/or modify it
00015  * under the terms of the GNU Lesser General Public License as published
00016  * by the Free Software Foundation; either version 2.1, or (at your option)
00017  * any later version.
00018  * 
00019  * GNU lightning is distributed in the hope that it will be useful, but 
00020  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00021  * or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00022  * License for more details.
00023  * 
00024  * You should have received a copy of the GNU Lesser General Public License
00025  * along with GNU lightning; see the file COPYING.LESSER; if not, write to the
00026  * Free Software Foundation, 59 Temple Place - Suite 330, Boston,
00027  * MA 02111-1307, USA.
00028  *
00029  ***********************************************************************/
00030 
00031 
00032 
00033 
00034 #ifndef __lightning_asm_h
00035 #define __lightning_asm_h
00036 
00037 /*     OPCODE + i           = immediate operand
00038  *            + r           = register operand
00039  *            + m           = memory operand (disp,base,index,scale)
00040  *            + sr/sm              = a star preceding a register or memory
00041  */
00042 
00043 
00044 typedef _uc          jit_insn;
00045 
00046 #ifndef LIGHTNING_DEBUG
00047 #define _b00         0
00048 #define _b01         1
00049 #define _b10         2
00050 #define _b11         3
00051 
00052 #define _b000        0
00053 #define _b001        1
00054 #define _b010        2
00055 #define _b011        3
00056 #define _b100        4
00057 #define _b101        5
00058 #define _b110        6
00059 #define _b111        7
00060 
00061 /*** REGISTERS ***/  /* [size,,number] */
00062 
00063 
00064 #define _AL          0x10
00065 #define _CL          0x11
00066 #define _DL          0x12
00067 #define _BL          0x13
00068 #define _AH          0x14
00069 #define _CH          0x15
00070 #define _DH          0x16
00071 #define _BH          0x17
00072 
00073 #define _AX          0x20
00074 #define _CX          0x21
00075 #define _DX          0x22
00076 #define _BX          0x23
00077 #define _SP          0x24
00078 #define _BP          0x25
00079 #define _SI          0x26
00080 #define _DI          0x27
00081 
00082 #define _EAX         0x40
00083 #define _ECX         0x41
00084 #define _EDX         0x42
00085 #define _EBX         0x43
00086 #define _ESP         0x44
00087 #define _EBP         0x45
00088 #define _ESI         0x46
00089 #define _EDI         0x47
00090 
00091 #define _R12            0x4C
00092 #define _R13            0x4D
00093 #define JIT_CALLTMPSTART 0x48
00094 #define JIT_REXTMP       0x4B
00095 
00096 #define _ST0         0
00097 #define _ST1         1
00098 #define _ST2         2
00099 #define _ST3         3
00100 #define _ST4         4
00101 #define _ST5         5
00102 #define _ST6         6
00103 #define _ST7         7
00104 
00105 #define _rS(R)              ((R)>>4)
00106 #define _rN(R)              ((R)&0x7)
00107 #define _qrN(R)             ((R)&0xF)
00108 #define _r0P(R)             ((R)==0)
00109 
00110 #ifndef _ASM_SAFETY
00111 #define _r1(R)              _rN(R)
00112 #define _r2(R)              _rN(R)
00113 #define _r4(R)              _rN(R)
00114 #define _r8(R)              _qrN(R)
00115 #else
00116 #define _r1(R)              ((_rS(R)==1) ? _rN(R) : JITFAIL( "8-bit register required"))
00117 #define _r2(R)              ((_rS(R)==2) ? _rN(R) : JITFAIL("16-bit register required"))
00118 #define _r4(R)              ((_rS(R)==4) ? _rN(R) : JITFAIL("32-bit register required"))
00119 #define _r8(R)              ((_rS(R)==4) ? _rN(R) : JITFAIL("64-bit register required"))
00120 #endif
00121 
00122 /*** ASSEMBLER ***/
00123 
00124 #define _OFF4(D)        (_jit_UL(D) - _jit_UL(_jit.x.pc))
00125 #define _CKD8(D)        _ck_d(8, ((_uc) _OFF4(D)) )
00126 
00127 #define _D8(D)          (_jit_B(0), ((*(_PUC(_jit.x.pc)-1))= _CKD8(D)))
00128 #define _D32(D)         (_jit_I(0), ((*(_PUI(_jit.x.pc)-1))= _OFF4(D)))
00129 
00130 #ifndef _ASM_SAFETY
00131 # define _M(M)              (M)
00132 # define _r(R)              (R)
00133 # define _m(M)              (M)
00134 # define _s(S)              (S)
00135 # define _i(I)              (I)
00136 # define _b(B)              (B)
00137 # define _noESP(I,OK)       (OK)
00138 #else
00139 # define _M(M)              (((M)>3) ? JITFAIL("internal error: mod = " #M) : (M))
00140 # define _r(R)              (((R)>7) ? JITFAIL("internal error: reg = " #R) : (R))
00141 # define _m(M)              (((M)>7) ? JITFAIL("internal error: r/m = " #M) : (M))
00142 # define _s(S)              (((S)>3) ? JITFAIL("internal error: memory scale = " #S) : (S))
00143 # define _i(I)              (((I)>7) ? JITFAIL("internal error: memory index = " #I) : (I))
00144 # define _b(B)              (((B)>7) ? JITFAIL("internal error: memory base = "  #B) : (B))
00145 # define _noESP(I,OK)       (((I)==_ESP) ? JITFAIL("illegal index register: %esp") : (OK))
00146 #endif
00147 
00148 #define _Mrm(Md,R,M) _jit_B((_M(Md)<<6)|(_r(R)<<3)|_m(M))
00149 #ifdef JIT_X86_64
00150 # define _qMrm(Md,R,M)      _jit_B((_M(Md)<<6)|(_r((R & 0x7))<<3)|_m((M & 0x7)))
00151 #else
00152 # define _qMrm(Md,R,M)  _Mrm(Md,R,M)
00153 #endif
00154 
00155 #define _SIB(Sc,I, B)       _jit_B((_s(Sc)<<6)|(_i(I)<<3)|_b(B))
00156 
00157 #define _SCL(S)             ((((S)==1) ? _b00 : \
00158                       (((S)==2) ? _b01 : \
00159                       (((S)==4) ? _b10 : \
00160                       (((S)==8) ? _b11 : JITFAIL("illegal scale: " #S))))))
00161 
00162 /* memory subformats - urgh! */
00163 
00164 #ifdef JIT_X86_64
00165 # define _r_D(       R, D     )    (_Mrm(_b00,_rN(R),_b100 ),_SIB(0,_b100,_b101)         ,_jit_I((long)(D)))
00166 # define _r_Q(       R, D     )    (_qMrm(_b00,_rN(R),_b100 ),_SIB(0,_b100,_b101)        ,_jit_I((long)(D)))
00167 #else
00168 # define _r_D(       R, D     )    (_Mrm(_b00,_rN(R),_b101 )                       ,_jit_I((long)(D)))
00169 # define _r_Q(R, D) _r_D(R, D)
00170 #endif
00171 #define _r_0B(       R,   B    )   (_Mrm(_b00,_rN(R),_r4(B))                            )
00172 #define _r_0BIS(R,   B,I,S) (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_r4(B))      )
00173 #define _r_1B(       R, D,B    )   (_Mrm(_b01,_rN(R),_r4(B))                       ,_jit_B((long)(D)))
00174 #define _r_1BIS(R, D,B,I,S) (_Mrm(_b01,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_r4(B)),_jit_B((long)(D)))
00175 #define _r_4B(       R, D,B    )   (_Mrm(_b10,_rN(R),_r4(B))                       ,_jit_I((long)(D)))
00176 #define _r_4IS( R, D,I,S)   (_Mrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_b101 ),_jit_I((long)(D)))
00177 #define _r_4BIS(R, D,B,I,S) (_Mrm(_b10,_rN(R),_b100 ),_SIB(_SCL(S),_r4(I),_r4(B)),_jit_I((long)(D)))
00178 #define _r_8B(       R, D,B    )   (_qMrm(_b10,_rN(R),_r8(B))                      ,_jit_I((long)(D)))
00179 #define _r_8IS( R, D,I,S)   (_qMrm(_b00,_rN(R),_b100 ),_SIB(_SCL(S),_r8(I),_b101 ),_jit_I((long)(D)))
00180 #define _r_8BIS(R, D,B,I,S) (_qMrm(_b10,_rN(R),_b100 ),_SIB(_SCL(S),_r8(I),_r8(B)),_jit_I((long)(D)))
00181 
00182 #define _r_DB(  R, D,B    ) ((_s0P(D) && (B != _EBP) ? _r_0B  (R,  B    ) : (_s8P(D) ? _r_1B(  R,D,B    ) : _r_4B(  R,D,B    ))))
00183 #define _r_DBIS(R, D,B,I,S) ((_s0P(D)             ? _r_0BIS(R,  B,I,S) : (_s8P(D) ? _r_1BIS(R,D,B,I,S) : _r_4BIS(R,D,B,I,S))))
00184 #define _r_QB(  R, D,B    ) ((_s0P(D) && (B != _EBP) ? _r_0B  (R,  B    ) : (_s8P(D) ? _r_1B(  R,D,B    ) : _r_8B(  R,D,B    ))))
00185 #define _r_QBIS(R, D,B,I,S) ((_s0P(D)             ? _r_0BIS(R,  B,I,S) : (_s8P(D) ? _r_1BIS(R,D,B,I,S) : _r_8BIS(R,D,B,I,S))))
00186  
00187 #define _r_X(   R, D,B,I,S) (_r0P(I) ? (_r0P(B)   ? _r_D   (R,D            )   : \
00188                                        (_ESP==(B) ? _r_DBIS(R,D,_ESP,_ESP,1)   : \
00189                                                   _r_DB  (R,D,   B       ))) : \
00190                              (_r0P(B)           ? _r_4IS (R,D,     I,S)   : \
00191                              (((I)!=_ESP)         ? _r_DBIS(R,D,   B,   I,S)   : \
00192                                                   JITFAIL("illegal index register: %esp"))))
00193 #define _qr_X(   R, D,B,I,S)       (_r0P(I) ? (_r0P(B)   ? _r_Q   (R,D            )   : \
00194                                        (_ESP==(B) ? _r_QBIS(R,D,_ESP,_ESP,1)   : \
00195                                                   _r_QB  (R,D,   B       ))) : \
00196                              (_r0P(B)           ? _r_8IS (R,D,     I,S)   : \
00197                              (((I)!=_ESP)         ? _r_QBIS(R,D,   B,   I,S)   : \
00198                                                   JITFAIL("illegal index register: %esp"))))
00199 
00200 
00201 /* instruction formats */
00202 
00203 /*      _format                                              Opcd       ModR/M dN(rB,rI,Sc)         imm... */
00204 
00205 #define        _d16()                                      (            _jit_B(0x66 )                             )
00206 #define         _O(       OP                            )  (            _jit_B(  OP )                             )
00207 #ifdef JIT_X86_64
00208 # define  _REX(R,X,B)                              ( _jit_B(0x48|((R&0x8)>>1)|((X&0x8)>>2)|((B&0x8)>>3)) )
00209 # define  _qO(            OP, R,X,B                     )  ( _REX(R,X,B), _jit_B(  OP      ) )
00210 #else
00211 # define  _qO(            OP, R,X,B              )  _O(OP)
00212 #endif
00213 #define         _Or(      OP,R                   )  (            _jit_B( (OP)|_r(R))                              )
00214 #ifdef JIT_X86_64
00215 # define  _qOr(           OP,R                   )  ( _REX(0,0,R), _jit_B( (OP)|_r(R&0x7))                        )
00216 #else
00217 # define _qOr(       OP,R                       ) _Or(OP,R) 
00218 #endif
00219 #define        _OO(       OP                            )  ( _jit_B((OP)>>8), _jit_B( (OP) )                             )
00220 #ifdef JIT_X86_64
00221 # define _qOO(OP)  ( _REX(0,0,0), _OO(OP))
00222 #else
00223 # define _qOO(OP) _OO(OP)
00224 #endif
00225 #define        _OOr(      OP,R                   )  ( _jit_B((OP)>>8), _jit_B( (OP)|_r(R))                        )
00226 #define         _Os(      OP,B                   )  (   _s8P(B) ? _jit_B(((OP)|_b10)) : _jit_B(OP)                       )
00227 #ifdef JIT_X86_64
00228 # define  _qOs(           OP, B, R, M                   )  ( _REX(0, M, R), _Os(OP, B) )
00229 #else
00230 # define  _qOs(           OP, B, R, M                   )  _Os(OP, B)
00231 #endif
00232 #define           _sW(                         W )  (                               _s8P(W) ? _jit_B(W):_jit_W(W)        )
00233 #define           _sL(                         L )  (                               _s8P(L) ? _jit_B(L):_jit_I(L)        )
00234 #define         _O_W(            OP                         ,W )  (       _O     (  OP  )                      ,_jit_W(W)       )
00235 #define         _O_D8(     OP                        ,D )  (       _O     (  OP  )                     ,_D8(D)    )
00236 #define         _O_D32(     OP                ,D )  (       _O     (  OP  )                     ,_D32(D)   )
00237 #define        _OO_D32(     OP                ,D )  (      _OO     (  OP  )                     ,_D32(D)   )
00238 #define         _Os_sW(    OP                        ,W )  (       _Os           (  OP,W)                     ,_sW(W)    )
00239 #define         _Os_sL(    OP                        ,L )  (       _Os           (  OP,L)                     ,_sL(L)    )
00240 #define         _O_W_B(    OP                        ,W,B)  (      _O     (  OP  )                      ,_jit_W(W),_jit_B(B))
00241 #define         _Or_B(     OP,R               ,B )  (       _Or           (  OP,R)                      ,_jit_B(B)       )
00242 #define         _Or_W(     OP,R               ,W )  (       _Or           (  OP,R)                      ,_jit_W(W)       )
00243 #define         _Or_L(     OP,R               ,L )  (       _Or           (  OP,R)                      ,_jit_I(L)       )
00244 #define         _qOr_Q(     OP,R              ,Q )  (      _qOr           (  OP,R)                      ,_jit_L(Q)       )
00245 #define         _O_Mrm(    OP       ,MO,R,M             )  (       _O     (  OP  ),_Mrm(MO,R,M        )           )
00246 #define        _qO_Mrm(    OP       ,MO,R,M             )  (       _qO           (  OP,R,0,M),_qMrm(MO,R,M          )           )
00247 #define        _OO_Mrm(    OP       ,MO,R,M             )  (      _OO     (  OP  ),_Mrm(MO,R,M        )           )
00248 #define        _qOO_Mrm(   OP       ,MO,R,M             )  (      _qOO           (  OP  ),_Mrm(MO,R,M        )           )
00249 #define         _O_Mrm_B(  OP       ,MO,R,M          ,B )  (       _O     (  OP  ),_Mrm(MO,R,M        ) ,_jit_B(B)       )
00250 #define        _qO_Mrm_B(  OP       ,MO,R,M          ,B )  (       _qO           (  OP,R,0,M),_qMrm(MO,R,M          ) ,_jit_B(B)       )
00251 #define         _O_Mrm_W(  OP       ,MO,R,M          ,W )  (       _O     (  OP  ),_Mrm(MO,R,M        ) ,_jit_W(W)       )
00252 #define         _O_Mrm_L(  OP       ,MO,R,M          ,L )  (       _O     (  OP  ),_Mrm(MO,R,M        ) ,_jit_I(L)       )
00253 #define        _qO_Mrm_L(  OP       ,MO,R,M          ,L )  (      _qO     (  OP,R,0,M),_qMrm(MO,R,M          ) ,_jit_I(L)       )
00254 #define        _qO_Mrm_Q(  OP       ,MO,R,M          ,Q )  (      _qO     (  OP,0,0,R),_qMrm(MO,R,M          ) ,_jit_L(Q)       )
00255 #define        _OO_Mrm_B(  OP       ,MO,R,M          ,B )  (      _OO     (  OP  ),_Mrm(MO,R,M        ) ,_jit_B(B)       )
00256 #define         _Os_Mrm_sW(OP       ,MO,R,M          ,W )  (       _Os           (  OP,W),_Mrm(MO,R,M        ),_sW(W)    )
00257 #define         _Os_Mrm_sL(OP       ,MO,R,M          ,L )  (       _Os           (  OP,L),_Mrm(MO,R,M        ),_sL(L)    )
00258 #define        _qOs_Mrm_sL(OP       ,MO,R,M          ,L )  (      _qOs           (  OP,L,R,M),_qMrm(MO,R,M          ),_sL(L)    )
00259 #define         _O_r_X(    OP          ,R ,MD,MB,MI,MS  )  (       _O     (  OP  ),_r_X(   R      ,MD,MB,MI,MS)          )
00260 #define        _qO_r_X(    OP          ,R ,MD,MB,MI,MS  )  (      _qO     (  OP,R,0,MS),_qr_X(R,MD,MB,MI,MS)             )
00261 #define        _qO_r_XB(   OP          ,R ,MD,MB,MI,MS  )  (      _qO     (  OP,R,0,MB),_qr_X(R,MD,MB,MI,MS)             )
00262 #define        _OO_r_X(    OP          ,R ,MD,MB,MI,MS  )  (      _OO     (  OP  ),_r_X(   R      ,MD,MB,MI,MS)          )
00263 #define         _O_r_X_B(  OP          ,R ,MD,MB,MI,MS,B       )  (       _O     (  OP  ),_r_X(   R      ,MD,MB,MI,MS) ,_jit_B(B)      )
00264 #define         _O_r_X_W(  OP          ,R ,MD,MB,MI,MS,W       )  (       _O     (  OP  ),_r_X(   R      ,MD,MB,MI,MS) ,_jit_W(W)      )
00265 #define         _O_r_X_L(  OP          ,R ,MD,MB,MI,MS,L       )  (       _O     (  OP  ),_r_X(   R      ,MD,MB,MI,MS) ,_jit_I(L)      )
00266 #define        _OO_r_X_B(  OP          ,R ,MD,MB,MI,MS,B       )  (      _OO     (  OP  ),_r_X(   R      ,MD,MB,MI,MS) ,_jit_B(B)      )
00267 #define         _Os_r_X_sW(OP          ,R ,MD,MB,MI,MS,W       )  (       _Os           (  OP,W),_r_X(   R      ,MD,MB,MI,MS),_sW(W)   )
00268 #define         _Os_r_X_sL(OP          ,R ,MD,MB,MI,MS,L       )  (       _Os           (  OP,L),_r_X(   R      ,MD,MB,MI,MS),_sL(L)   )
00269 #define         _O_X_B(    OP             ,MD,MB,MI,MS,B       )  (       _O_r_X_B(  OP        ,0 ,MD,MB,MI,MS   ,B)     )
00270 #define         _O_X_W(    OP             ,MD,MB,MI,MS,W       )  (       _O_r_X_W(  OP        ,0 ,MD,MB,MI,MS   ,W)     )
00271 #define         _O_X_L(    OP             ,MD,MB,MI,MS,L       )  (       _O_r_X_L(  OP        ,0 ,MD,MB,MI,MS   ,L)     )
00272 #define        _wO(       OP                            )  (_d16(), _O(             OP                             )     )
00273 #define        _wOr(      OP,R                   )  (_d16(), _Or(       OP,R                         )     )
00274 #define        _wOr_W(     OP,R               ,W )  (_d16(), _Or_W(     OP,R                       ,W)     )
00275 #define        _wOs_sW(    OP                        ,W )  (_d16(), _Os_sW(    OP                         ,W)     )
00276 #define        _wO_Mrm(    OP       ,MO,R,M             )  (_d16(), _O_Mrm(    OP    ,MO,R,M                )     )
00277 #define _wOO_Mrm(    OP      ,MO,R,M             )  (_d16(),_OO_Mrm(    OP    ,MO,R,M                )     )
00278 #define        _wO_Mrm_B(  OP       ,MO,R,M          ,B )  (_d16(), _O_Mrm_B(  OP    ,MO,R,M              ,B)     )
00279 #define _wOO_Mrm_B(  OP      ,MO,R,M          ,B )  (_d16(),_OO_Mrm_B(  OP    ,MO,R,M              ,B)     )
00280 #define        _wO_Mrm_W(  OP       ,MO,R,M          ,W )  (_d16(), _O_Mrm_W(  OP    ,MO,R,M              ,W)     )
00281 #define        _wOs_Mrm_sW(OP       ,MO,R,M          ,W )  (_d16(), _Os_Mrm_sW(OP    ,MO,R,M              ,W)     )
00282 #define        _wO_X_W(    OP             ,MD,MB,MI,MS,W       )  (_d16(), _O_X_W(    OP          ,MD,MB,MI,MS   ,W)     )
00283 #define        _wO_r_X(    OP          ,R ,MD,MB,MI,MS  )  (_d16(), _O_r_X(    OP       ,R ,MD,MB,MI,MS     )     )
00284 #define _wOO_r_X(    OP         ,R ,MD,MB,MI,MS  )  (_d16(),_OO_r_X(    OP       ,R ,MD,MB,MI,MS     )     )
00285 #define        _wO_r_X_B(  OP          ,R ,MD,MB,MI,MS,B       )  (_d16(), _O_r_X_B(  OP       ,R ,MD,MB,MI,MS   ,B)     )
00286 #define _wOO_r_X_B(  OP         ,R ,MD,MB,MI,MS,B       )  (_d16(),_OO_r_X_B(  OP       ,R ,MD,MB,MI,MS   ,B)     )
00287 #define        _wO_r_X_W(  OP          ,R ,MD,MB,MI,MS,W       )  (_d16(), _O_r_X_W(  OP       ,R ,MD,MB,MI,MS   ,W)     )
00288 #define        _wOs_r_X_sW(OP          ,R ,MD,MB,MI,MS,W       )  (_d16(), _Os_r_X_sW(OP       ,R ,MD,MB,MI,MS   ,W)     )
00289 
00290 /* +++ fully-qualified intrinsic instructions */
00291 
00292 /*                                 _format               Opcd         ,Mod ,r           ,m        ,mem=dsp+sib  ,imm... */
00293 
00294 #define ADCBrr(RS, RD)                    _O_Mrm        (0x10         ,_b11,_r1(RS),_r1(RD)                            )
00295 #define ADCBmr(MD, MB, MI, MS, RD) _O_r_X        (0x12              ,_r1(RD)        ,MD,MB,MI,MS         )
00296 #define ADCBrm(RS, MD, MB, MI, MS) _O_r_X        (0x10              ,_r1(RS)        ,MD,MB,MI,MS         )
00297 #define ADCBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b010  ,_r1(RD)                     ,_su8(IM))
00298 #define ADCBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b010          ,MD,MB,MI,MS  ,_su8(IM))
00299 
00300 #define ADCWrr(RS, RD)                    _wO_Mrm              (0x11         ,_b11,_r2(RS),_r2(RD)                            )
00301 #define ADCWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x13              ,_r2(RD)        ,MD,MB,MI,MS         )
00302 #define ADCWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x11              ,_r2(RS)        ,MD,MB,MI,MS         )
00303 #define ADCWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b010  ,_r2(RD)                     ,_su16(IM))
00304 #define ADCWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b010          ,MD,MB,MI,MS  ,_su16(IM))
00305 
00306 #define ADCLrr(RS, RD)                    _O_Mrm        (0x11         ,_b11,_r4(RS),_r4(RD)                            )
00307 #define ADCLmr(MD, MB, MI, MS, RD) _O_r_X        (0x13              ,_r4(RD)        ,MD,MB,MI,MS         )
00308 #define ADCLrm(RS, MD, MB, MI, MS) _O_r_X        (0x11              ,_r4(RS)        ,MD,MB,MI,MS         )
00309 #define ADCLir(IM, RD)                    _Os_Mrm_sL    (0x81         ,_b11,_b010  ,_r4(RD)                     ,IM    )
00310 #define ADCLim(IM, MD, MB, MI, MS) _Os_r_X_sL    (0x81              ,_b010          ,MD,MB,MI,MS  ,IM    )
00311 
00312 
00313 #define ADDBrr(RS, RD)                    _O_Mrm        (0x00         ,_b11,_r1(RS),_r1(RD)                            )
00314 #define ADDBmr(MD, MB, MI, MS, RD) _O_r_X        (0x02              ,_r1(RD)        ,MD,MB,MI,MS         )
00315 #define ADDBrm(RS, MD, MB, MI, MS) _O_r_X        (0x00              ,_r1(RS)        ,MD,MB,MI,MS         )
00316 #define ADDBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b000  ,_r1(RD)                     ,_su8(IM))
00317 #define ADDBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b000          ,MD,MB,MI,MS  ,_su8(IM))
00318 
00319 #define ADDWrr(RS, RD)                    _wO_Mrm              (0x01         ,_b11,_r2(RS),_r2(RD)                            )
00320 #define ADDWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x03              ,_r2(RD)        ,MD,MB,MI,MS         )
00321 #define ADDWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x01              ,_r2(RS)        ,MD,MB,MI,MS         )
00322 #define ADDWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b000  ,_r2(RD)                     ,_su16(IM))
00323 #define ADDWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b000          ,MD,MB,MI,MS  ,_su16(IM))
00324 
00325 #define ADDLrr(RS, RD)                    _O_Mrm        (0x01         ,_b11,_r4(RS),_r4(RD)                            )
00326 #define ADDLmr(MD, MB, MI, MS, RD) _O_r_X        (0x03              ,_r4(RD)        ,MD,MB,MI,MS         )
00327 #define ADDLrm(RS, MD, MB, MI, MS) _O_r_X        (0x01              ,_r4(RS)        ,MD,MB,MI,MS         )
00328 #define ADDLir(IM, RD)                    _Os_Mrm_sL    (0x81         ,_b11,_b000  ,_r4(RD)                     ,IM    )
00329 #define ADDLim(IM, MD, MB, MI, MS) _Os_r_X_sL    (0x81              ,_b000          ,MD,MB,MI,MS  ,IM    )
00330 
00331 #define ADDQrr(RS, RD)                    _qO_Mrm              (0x01         ,_b11,_r8(RS),_r8(RD)                            )
00332 #define ADDQir(IM, RD)                    _qOs_Mrm_sL   (0x81         ,_b11,_b000  ,_r8(RD)                     ,IM    )
00333 
00334 #define ADDQiBr(IM, RD)                   _qO_Mrm_B     (0x83         ,_b11,_b000  ,_r1(RD)                     ,_su8(IM))
00335 
00336 #define ANDBrr(RS, RD)                    _O_Mrm        (0x20         ,_b11,_r1(RS),_r1(RD)                            )
00337 #define ANDBmr(MD, MB, MI, MS, RD) _O_r_X        (0x22              ,_r1(RD)        ,MD,MB,MI,MS         )
00338 #define ANDBrm(RS, MD, MB, MI, MS) _O_r_X        (0x20              ,_r1(RS)        ,MD,MB,MI,MS         )
00339 #define ANDBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b100  ,_r1(RD)                     ,_su8(IM))
00340 #define ANDBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b100          ,MD,MB,MI,MS  ,_su8(IM))
00341 
00342 #define ANDWrr(RS, RD)                    _wO_Mrm              (0x21         ,_b11,_r2(RS),_r2(RD)                            )
00343 #define ANDWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x23              ,_r2(RD)        ,MD,MB,MI,MS         )
00344 #define ANDWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x21              ,_r2(RS)        ,MD,MB,MI,MS         )
00345 #define ANDWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b100  ,_r2(RD)                     ,_su16(IM))
00346 #define ANDWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b100          ,MD,MB,MI,MS  ,_su16(IM))
00347 
00348 #define ANDLrr(RS, RD)                    _O_Mrm        (0x21         ,_b11,_r4(RS),_r4(RD)                            )
00349 #define ANDLmr(MD, MB, MI, MS, RD) _O_r_X        (0x23              ,_r4(RD)        ,MD,MB,MI,MS         )
00350 #define ANDLrm(RS, MD, MB, MI, MS) _O_r_X        (0x21              ,_r4(RS)        ,MD,MB,MI,MS         )
00351 #define ANDLir(IM, RD)                    _Os_Mrm_sL    (0x81         ,_b11,_b100  ,_r4(RD)                     ,IM    )
00352 #define ANDLim(IM, MD, MB, MI, MS) _Os_r_X_sL    (0x81              ,_b100          ,MD,MB,MI,MS  ,IM    )
00353 
00354 #define ANDQrr(RS, RD)                    _qO_Mrm              (0x21         ,_b11,_r8(RS),_r8(RD)                            )
00355 #define ANDQir(IM, RD)                    _qOs_Mrm_sL   (0x81         ,_b11,_b100  ,_r8(RD)                     ,IM    )
00356 
00357 #define BSWAPLr(R)                 _OOr          (0x0fc8,_r4(R)                                                 )
00358 
00359 
00360 #define BTWir(IM,RD)               _wOO_Mrm_B    (0x0fba              ,_b11,_b100  ,_r2(RD)                     ,_u8(IM))
00361 #define BTWim(IM,MD,MB,MI,MS)             _wOO_r_X_B    (0x0fba                   ,_b100          ,MD,MB,MI,MS  ,_u8(IM))
00362 #define BTWrr(RS,RD)               _wOO_Mrm      (0x0fa3              ,_b11,_r2(RS),_r2(RD)                            )
00363 #define BTWrm(RS,MD,MB,MI,MS)             _wOO_r_X      (0x0fa3                   ,_r2(RS)        ,MD,MB,MI,MS         )
00364 
00365 #define BTLir(IM,RD)               _OO_Mrm_B     (0x0fba              ,_b11,_b100  ,_r4(RD)                     ,_u8(IM))
00366 #define BTLim(IM,MD,MB,MI,MS)             _OO_r_X_B     (0x0fba                   ,_b100          ,MD,MB,MI,MS  ,_u8(IM))
00367 #define BTLrr(RS,RD)               _OO_Mrm              (0x0fa3              ,_b11,_r4(RS),_r4(RD)                            )
00368 #define BTLrm(RS,MD,MB,MI,MS)             _OO_r_X              (0x0fa3                   ,_r4(RS)        ,MD,MB,MI,MS         )
00369 
00370 
00371 #define BTCWir(IM,RD)                     _wOO_Mrm_B    (0x0fba              ,_b11,_b111  ,_r2(RD)                     ,_u8(IM))
00372 #define BTCWim(IM,MD,MB,MI,MS)            _wOO_r_X_B    (0x0fba                   ,_b111          ,MD,MB,MI,MS  ,_u8(IM))
00373 #define BTCWrr(RS,RD)                     _wOO_Mrm      (0x0fbb              ,_b11,_r2(RS),_r2(RD)                            )
00374 #define BTCWrm(RS,MD,MB,MI,MS)            _wOO_r_X      (0x0fbb                   ,_r2(RS)        ,MD,MB,MI,MS         )
00375 
00376 #define BTCLir(IM,RD)                     _OO_Mrm_B     (0x0fba              ,_b11,_b111  ,_r4(RD)                     ,_u8(IM))
00377 #define BTCLim(IM,MD,MB,MI,MS)            _OO_r_X_B     (0x0fba                   ,_b111          ,MD,MB,MI,MS  ,_u8(IM))
00378 #define BTCLrr(RS,RD)                     _OO_Mrm              (0x0fbb              ,_b11,_r4(RS),_r4(RD)                            )
00379 #define BTCLrm(RS,MD,MB,MI,MS)            _OO_r_X              (0x0fbb                   ,_r4(RS)        ,MD,MB,MI,MS         )
00380 
00381 
00382 #define BTRWir(IM,RD)                     _wOO_Mrm_B    (0x0fba              ,_b11,_b110  ,_r2(RD)                     ,_u8(IM))
00383 #define BTRWim(IM,MD,MB,MI,MS)            _wOO_r_X_B    (0x0fba                   ,_b110          ,MD,MB,MI,MS  ,_u8(IM))
00384 #define BTRWrr(RS,RD)                     _wOO_Mrm      (0x0fb3              ,_b11,_r2(RS),_r2(RD)                            )
00385 #define BTRWrm(RS,MD,MB,MI,MS)            _wOO_r_X      (0x0fb3                   ,_r2(RS)        ,MD,MB,MI,MS         )
00386 
00387 #define BTRLir(IM,RD)                     _OO_Mrm_B     (0x0fba              ,_b11,_b110  ,_r4(RD)                     ,_u8(IM))
00388 #define BTRLim(IM,MD,MB,MI,MS)            _OO_r_X_B     (0x0fba                   ,_b110          ,MD,MB,MI,MS  ,_u8(IM))
00389 #define BTRLrr(RS,RD)                     _OO_Mrm              (0x0fb3              ,_b11,_r4(RS),_r4(RD)                            )
00390 #define BTRLrm(RS,MD,MB,MI,MS)            _OO_r_X              (0x0fb3                   ,_r4(RS)        ,MD,MB,MI,MS         )
00391 
00392 
00393 #define BTSWir(IM,RD)                     _wOO_Mrm_B    (0x0fba              ,_b11,_b101  ,_r2(RD)                     ,_u8(IM))
00394 #define BTSWim(IM,MD,MB,MI,MS)            _wOO_r_X_B    (0x0fba                   ,_b101          ,MD,MB,MI,MS  ,_u8(IM))
00395 #define BTSWrr(RS,RD)                     _wOO_Mrm      (0x0fab              ,_b11,_r2(RS),_r2(RD)                            )
00396 #define BTSWrm(RS,MD,MB,MI,MS)            _wOO_r_X      (0x0fab                   ,_r2(RS)        ,MD,MB,MI,MS         )
00397 
00398 #define BTSLir(IM,RD)                     _OO_Mrm_B     (0x0fba              ,_b11,_b101  ,_r4(RD)                     ,_u8(IM))
00399 #define BTSLim(IM,MD,MB,MI,MS)            _OO_r_X_B     (0x0fba                   ,_b101          ,MD,MB,MI,MS  ,_u8(IM))
00400 #define BTSLrr(RS,RD)                     _OO_Mrm              (0x0fab              ,_b11,_r4(RS),_r4(RD)                            )
00401 #define BTSLrm(RS,MD,MB,MI,MS)            _OO_r_X              (0x0fab                   ,_r4(RS)        ,MD,MB,MI,MS         )
00402 
00403 #ifdef JIT_X86_64
00404 # define CALLm(D,B,I,S)                     (MOVQir((D), JIT_REXTMP), CALQsr(JIT_REXTMP))
00405 #else
00406 # define CALLm(D,B,I,S)                   ((_r0P(B) && _r0P(I)) ? _O_D32     (0xe8                ,(long)(D)           ) : \
00407                                                         JITFAIL("illegal mode in direct jump"))
00408 #endif
00409 
00410 #define CALLsr(R)                  _O_Mrm (0xff  ,_b11,_b010,_r4(R)                 )
00411 #define CALQsr(R)                       _qO_Mrm (0xff   ,_b11,_b010,_r8(R))
00412 
00413 #define CALLsm(D,B,I,S)                   _O_r_X (0xff       ,_b010   ,(long)(D),B,I,S            )
00414 
00415 #define CBW_()                            _O            (0x98                                                   )
00416 #define CLC_()                            _O            (0xf8                                                   )
00417 #define CLTD_()                           _O            (0x99                                                   )
00418 #define CMC_()                            _O            (0xf5                                                   )
00419 
00420 
00421 #define CMPBrr(RS, RD)                    _O_Mrm        (0x38         ,_b11,_r1(RS),_r1(RD)                            )
00422 #define CMPBmr(MD, MB, MI, MS, RD) _O_r_X        (0x3a              ,_r1(RD)        ,MD,MB,MI,MS         )
00423 #define CMPBrm(RS, MD, MB, MI, MS) _O_r_X        (0x38              ,_r1(RS)        ,MD,MB,MI,MS         )
00424 #define CMPBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b111  ,_r1(RD)                     ,_su8(IM))
00425 #define CMPBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b111          ,MD,MB,MI,MS  ,_su8(IM))
00426 
00427 #define CMPWrr(RS, RD)                    _wO_Mrm              (0x39         ,_b11,_r2(RS),_r2(RD)                            )
00428 #define CMPWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x3b              ,_r2(RD)        ,MD,MB,MI,MS         )
00429 #define CMPWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x39              ,_r2(RS)        ,MD,MB,MI,MS         )
00430 #define CMPWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b111  ,_r2(RD)                     ,_su16(IM))
00431 #define CMPWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b111          ,MD,MB,MI,MS  ,_su16(IM))
00432 
00433 #define CMPLrr(RS, RD)                    _O_Mrm        (0x39         ,_b11,_r4(RS),_r4(RD)                            )
00434 #define CMPLmr(MD, MB, MI, MS, RD) _O_r_X        (0x3b              ,_r4(RD)        ,MD,MB,MI,MS         )
00435 #define CMPLrm(RS, MD, MB, MI, MS) _O_r_X        (0x39              ,_r4(RS)        ,MD,MB,MI,MS         )
00436 #define CMPLir(IM, RD)                    _O_Mrm_L      (0x81         ,_b11,_b111  ,_r4(RD)                     ,IM    )
00437 #define CMPLim(IM, MD, MB, MI, MS) _O_r_X_L      (0x81              ,_b111          ,MD,MB,MI,MS  ,IM    )
00438 
00439 #define CMPQrr(RS, RD)                    _qO_Mrm              (0x39         ,_b11,_r8(RS),_r8(RD)                            )
00440 #define CMPQir(IM, RD)                    _qO_Mrm_L     (0x81         ,_b11,_b111  ,_r8(RD)                     ,IM    )
00441 
00442 #define CWD_()                            _O            (0x99                                                   )
00443 
00444 
00445 #define CMPXCHGBrr(RS,RD)          _OO_Mrm              (0x0fb0              ,_b11,_r1(RS),_r1(RD)                            )
00446 #define CMPXCHGBrm(RS,MD,MB,MI,MS) _OO_r_X              (0x0fb0                   ,_r1(RS)        ,MD,MB,MI,MS         )
00447 
00448 #define CMPXCHGWrr(RS,RD)          _wOO_Mrm      (0x0fb1              ,_b11,_r2(RS),_r2(RD)                            )
00449 #define CMPXCHGWrm(RS,MD,MB,MI,MS) _wOO_r_X      (0x0fb1                   ,_r2(RS)        ,MD,MB,MI,MS         )
00450 
00451 #define CMPXCHGLrr(RS,RD)          _OO_Mrm              (0x0fb1              ,_b11,_r4(RS),_r4(RD)                            )
00452 #define CMPXCHGLrm(RS,MD,MB,MI,MS) _OO_r_X              (0x0fb1                   ,_r4(RS)        ,MD,MB,MI,MS         )
00453 
00454 
00455 #define DECBr(RD)                  _O_Mrm        (0xfe         ,_b11,_b001  ,_r1(RD)                            )
00456 #define DECBm(MD,MB,MI,MS)         _O_r_X        (0xfe              ,_b001          ,MD,MB,MI,MS         )
00457 
00458 #define DECWr(RD)                  _wOr          (0x48,_r2(RD)                                           )
00459 #define DECWm(MD,MB,MI,MS)         _wO_r_X              (0xff              ,_b001          ,MD,MB,MI,MS         )
00460 
00461 #define DECLr(RD)                  _Or           (0x48,_r4(RD)                                           )
00462 #define DECLm(MD,MB,MI,MS)         _O_r_X        (0xff              ,_b001          ,MD,MB,MI,MS         )
00463 
00464 
00465 #define DIVBr(RS)                  _O_Mrm        (0xf6         ,_b11,_b110  ,_r1(RS)                            )
00466 #define DIVBm(MD,MB,MI,MS)         _O_r_X        (0xf6              ,_b110          ,MD,MB,MI,MS         )
00467 
00468 #define DIVWr(RS)                  _wO_Mrm              (0xf7         ,_b11,_b110  ,_r2(RS)                            )
00469 #define DIVWm(MD,MB,MI,MS)         _wO_r_X              (0xf7              ,_b110          ,MD,MB,MI,MS         )
00470 
00471 #define DIVLr(RS)                  _O_Mrm        (0xf7         ,_b11,_b110  ,_r4(RS)                            )
00472 #define DIVLm(MD,MB,MI,MS)         _O_r_X        (0xf7              ,_b110          ,MD,MB,MI,MS         )
00473 
00474 
00475 #define ENTERii(W, B)                     _O_W_B        (0xc8                                       ,_su16(W),_su8(B))
00476 #define HLT_()                            _O            (0xf4                                                   )
00477 
00478 
00479 #define IDIVBr(RS)                 _O_Mrm        (0xf6         ,_b11,_b111  ,_r1(RS)                            )
00480 #define IDIVBm(MD,MB,MI,MS)        _O_r_X        (0xf6              ,_b111          ,MD,MB,MI,MS         )
00481 
00482 #define IDIVWr(RS)                 _wO_Mrm       (0xf7         ,_b11,_b111  ,_r2(RS)                            )
00483 #define IDIVWm(MD,MB,MI,MS)        _wO_r_X       (0xf7              ,_b111          ,MD,MB,MI,MS         )
00484 
00485 #define IDIVLr(RS)                 _O_Mrm        (0xf7         ,_b11,_b111  ,_r4(RS)                            )
00486 #define IDIVLm(MD,MB,MI,MS)        _O_r_X        (0xf7              ,_b111          ,MD,MB,MI,MS         )
00487 
00488 #define IMULBr(RS)                 _O_Mrm        (0xf6         ,_b11,_b101  ,_r1(RS)                            )
00489 #define IMULBm(MD,MB,MI,MS)        _O_r_X        (0xf6              ,_b101          ,MD,MB,MI,MS         )
00490 
00491 #define IMULWr(RS)                 _wO_Mrm       (0xf7         ,_b11,_b101  ,_r2(RS)                            )
00492 #define IMULWm(MD,MB,MI,MS)        _wO_r_X       (0xf7              ,_b101          ,MD,MB,MI,MS         )
00493 
00494 #define IMULLr(RS)                 _O_Mrm        (0xf7         ,_b11,_b101  ,_r4(RS)                            )
00495 #define IMULLm(MD,MB,MI,MS)        _O_r_X        (0xf7              ,_b101          ,MD,MB,MI,MS         )
00496 
00497 
00498 #define IMULWrr(RS,RD)                    _wOO_Mrm      (0x0faf              ,_b11,_r2(RS),_r2(RD)                            )
00499 #define IMULWmr(MD,MB,MI,MS,RD)           _wOO_r_X      (0x0faf                   ,_r2(RD)        ,MD,MB,MI,MS         )
00500 #define IMULWirr(IM,RS,RD)         _wOs_Mrm_sW   (0x69         ,_b11,_r2(RS),_r2(RD)                     ,_su16(IM)    )
00501 #define IMULWimr(IM,MD,MB,MI,MS,RD)       _wOs_r_X_sW   (0x69              ,_r2(RD)        ,MD,MB,MI,MS  ,_su16(IM)    )
00502 
00503 #define IMULLir(IM,RD)                    _Os_Mrm_sL    (0x69         ,_b11,_r4(RD),_r4(RD)                     ,IM    )
00504 #define IMULLrr(RS,RD)                    _OO_Mrm              (0x0faf              ,_b11,_r4(RD),_r4(RS)                            )
00505 #define IMULLmr(MD,MB,MI,MS,RD)           _OO_r_X              (0x0faf                   ,_r4(RD)        ,MD,MB,MI,MS         )
00506 #define IMULLirr(IM,RS,RD)         _Os_Mrm_sL    (0x69         ,_b11,_r4(RS),_r4(RD)                     ,IM    )
00507 #define IMULLimr(IM,MD,MB,MI,MS,RD)       _Os_r_X_sL    (0x69              ,_r4(RD)        ,MD,MB,MI,MS  ,IM    )
00508 
00509 #define IMULQrr(RS,RD)                    _qOO_Mrm      (0x0faf              ,_b11,_r4(RD),_r4(RS)                            )
00510 
00511 #define INCBr(RD)                  _O_Mrm        (0xfe         ,_b11,_b000  ,_r1(RD)                            )
00512 #define INCBm(MD,MB,MI,MS)         _O_r_X        (0xfe              ,_b000          ,MD,MB,MI,MS         )
00513 
00514 #define INCWr(RD)                  _wOr          (0x40,_r2(RD)                                           )
00515 #define INCWm(MD,MB,MI,MS)         _wO_r_X              (0xff              ,_b000          ,MD,MB,MI,MS         )
00516 
00517 #define INCLr(RD)                  _Or           (0x40,_r4(RD)                                           )
00518 #define INCLm(MD,MB,MI,MS)         _O_r_X        (0xff              ,_b000          ,MD,MB,MI,MS         )
00519 
00520 
00521 #define INVD_()                           _OO           (0x0f08                                                        )
00522 #define INVLPGm(MD, MB, MI, MS)           _OO_r_X              (0x0f01                   ,_b111          ,MD,MB,MI,MS         )
00523 
00524 
00525 #define JCCSim(CC,D,B,I,S)         ((_r0P(B) && _r0P(I)) ? _O_D8      (0x70|(CC)           ,(long)(D)           ) : \
00526                                                         JITFAIL("illegal mode in conditional jump"))
00527 
00528 #define JOSm(D,B,I,S)                     JCCSim(0x0,D,B,I,S)
00529 #define JNOSm(D,B,I,S)                    JCCSim(0x1,D,B,I,S)
00530 #define JBSm(D,B,I,S)                     JCCSim(0x2,D,B,I,S)
00531 #define JNAESm(D,B,I,S)                   JCCSim(0x2,D,B,I,S)
00532 #define JNBSm(D,B,I,S)                    JCCSim(0x3,D,B,I,S)
00533 #define JAESm(D,B,I,S)                    JCCSim(0x3,D,B,I,S)
00534 #define JESm(D,B,I,S)                     JCCSim(0x4,D,B,I,S)
00535 #define JZSm(D,B,I,S)                     JCCSim(0x4,D,B,I,S)
00536 #define JNESm(D,B,I,S)                    JCCSim(0x5,D,B,I,S)
00537 #define JNZSm(D,B,I,S)                    JCCSim(0x5,D,B,I,S)
00538 #define JBESm(D,B,I,S)                    JCCSim(0x6,D,B,I,S)
00539 #define JNASm(D,B,I,S)                    JCCSim(0x6,D,B,I,S)
00540 #define JNBESm(D,B,I,S)                   JCCSim(0x7,D,B,I,S)
00541 #define JASm(D,B,I,S)                     JCCSim(0x7,D,B,I,S)
00542 #define JSSm(D,B,I,S)                     JCCSim(0x8,D,B,I,S)
00543 #define JNSSm(D,B,I,S)                    JCCSim(0x9,D,B,I,S)
00544 #define JPSm(D,B,I,S)                     JCCSim(0xa,D,B,I,S)
00545 #define JPESm(D,B,I,S)                    JCCSim(0xa,D,B,I,S)
00546 #define JNPSm(D,B,I,S)                    JCCSim(0xb,D,B,I,S)
00547 #define JPOSm(D,B,I,S)                    JCCSim(0xb,D,B,I,S)
00548 #define JLSm(D,B,I,S)                     JCCSim(0xc,D,B,I,S)
00549 #define JNGESm(D,B,I,S)                   JCCSim(0xc,D,B,I,S)
00550 #define JNLSm(D,B,I,S)                    JCCSim(0xd,D,B,I,S)
00551 #define JGESm(D,B,I,S)                    JCCSim(0xd,D,B,I,S)
00552 #define JLESm(D,B,I,S)                    JCCSim(0xe,D,B,I,S)
00553 #define JNGSm(D,B,I,S)                    JCCSim(0xe,D,B,I,S)
00554 #define JNLESm(D,B,I,S)                   JCCSim(0xf,D,B,I,S)
00555 #define JGSm(D,B,I,S)                     JCCSim(0xf,D,B,I,S)
00556 
00557 #ifdef JIT_X86_64
00558 # define JCCim(CC,nCC,D,B,I,S) (!_jitl.long_jumps \
00559                                 ? _OO_D32(0x0f80|(CC), (long)(D) ) \
00560                                 : (_O_D8(0x70|(nCC), _jit_UL(_jit.x.pc) + 13), JMPm((long)D, 0, 0, 0)))
00561 #else
00562 # define JCCim(CC,nCC,D,B,I,S)            ((_r0P(B) && _r0P(I)) ? (_jitl.tiny_jumps \
00563                                                                  ? _O_D8(0x70|(CC), D) \
00564                                                                  : _OO_D32   (0x0f80|(CC)         ,(long)(D)           )) : \
00565                                                         JITFAIL("illegal mode in conditional jump"))
00566 #endif
00567 
00568 #define JOm(D,B,I,S)               JCCim(0x0,0x1,D,B,I,S)
00569 #define JNOm(D,B,I,S)                     JCCim(0x1,0x0,D,B,I,S)
00570 #define JBm(D,B,I,S)               JCCim(0x2,0x3,D,B,I,S)
00571 #define JNAEm(D,B,I,S)                    JCCim(0x2,0x3,D,B,I,S)
00572 #define JNBm(D,B,I,S)                     JCCim(0x3,0x2,D,B,I,S)
00573 #define JAEm(D,B,I,S)                     JCCim(0x3,0x2,D,B,I,S)
00574 #define JEm(D,B,I,S)               JCCim(0x4,0x5,D,B,I,S)
00575 #define JZm(D,B,I,S)               JCCim(0x4,0x5,D,B,I,S)
00576 #define JNEm(D,B,I,S)                     JCCim(0x5,0x4,D,B,I,S)
00577 #define JNZm(D,B,I,S)                     JCCim(0x5,0x4,D,B,I,S)
00578 #define JBEm(D,B,I,S)                     JCCim(0x6,0x7,D,B,I,S)
00579 #define JNAm(D,B,I,S)                     JCCim(0x6,0x7,D,B,I,S)
00580 #define JNBEm(D,B,I,S)                    JCCim(0x7,0x6,D,B,I,S)
00581 #define JAm(D,B,I,S)               JCCim(0x7,0x6,D,B,I,S)
00582 #define JSm(D,B,I,S)               JCCim(0x8,0x9,D,B,I,S)
00583 #define JNSm(D,B,I,S)                     JCCim(0x9,0x8,D,B,I,S)
00584 #define JPm(D,B,I,S)               JCCim(0xa,0xb,D,B,I,S)
00585 #define JPEm(D,B,I,S)                     JCCim(0xa,0xb,D,B,I,S)
00586 #define JNPm(D,B,I,S)                     JCCim(0xb,0xa,D,B,I,S)
00587 #define JPOm(D,B,I,S)                     JCCim(0xb,0xa,D,B,I,S)
00588 #define JLm(D,B,I,S)               JCCim(0xc,0xd,D,B,I,S)
00589 #define JNGEm(D,B,I,S)                    JCCim(0xc,0xd,D,B,I,S)
00590 #define JNLm(D,B,I,S)                     JCCim(0xd,0xc,D,B,I,S)
00591 #define JGEm(D,B,I,S)                     JCCim(0xd,0xc,D,B,I,S)
00592 #define JLEm(D,B,I,S)                     JCCim(0xe,0xf,D,B,I,S)
00593 #define JNGm(D,B,I,S)                     JCCim(0xe,0xf,D,B,I,S)
00594 #define JNLEm(D,B,I,S)                    JCCim(0xf,0xe,D,B,I,S)
00595 #define JGm(D,B,I,S)               JCCim(0xf,0xe,D,B,I,S)
00596 
00597 #define JCm(D,B,I,S) JBm(D,B,I,S)
00598 #define JNCm(D,B,I,S) JNBm(D,B,I,S)
00599 
00600 #define JMPSm(D,B,I,S)                    ((_r0P(B) && _r0P(I)) ? _O_D8      (0xeb                ,(long)(D)           ) : \
00601                                                         JITFAIL("illegal mode in short jump"))
00602 
00603 #ifdef JIT_X86_64
00604 # define JMPm(D,B,I,S) (!_jitl.long_jumps \
00605                         ? _O_D32(0xe9, (long)(D)) \
00606                         : (MOVQir((D), JIT_REXTMP), _qO_Mrm(0xff,_b11,_b100,_r8(JIT_REXTMP))))
00607 #else
00608 # define JMPm(D,B,I,S)                    ((_r0P(B) && _r0P(I)) ? (_jitl.tiny_jumps \
00609                                                                  ? _O_D8(0xeB, D) \
00610                                                                  : _O_D32    (0xe9                ,(long)(D)           )) : \
00611                                                         JITFAIL("illegal mode in direct jump"))
00612 #endif
00613 
00614 #define JMPsr(R)                   _O_Mrm (0xff  ,_b11,_b100,_r4(R)                 )
00615 
00616 #define JMPsm(D,B,I,S)                    _O_r_X (0xff       ,_b100   ,(long)(D),B,I,S            )
00617 
00618 
00619 #define LAHF_()                           _O            (0x9f                                                   )
00620 #define LEALmr(MD, MB, MI, MS, RD) _O_r_X        (0x8d              ,_r4(RD)        ,MD,MB,MI,MS         )
00621 #define LEAQmr(MD, MB, MI, MS, RD) _qO_r_X              (0x8d              ,_r8(RD)        ,MD,MB,MI,MS         )
00622 #define LEAVE_()                   _O            (0xc9                                                   )
00623 
00624 
00625 #define LMSWr(RS)                  _OO_Mrm              (0x0f01              ,_b11,_b110,_r4(RS)                       )
00626 #define LMSWm(MD,MB,MI,MS)         _OO_r_X              (0x0f01                   ,_b110          ,MD,MB,MI,MS         )
00627 
00628 #define LOOPm(MD,MB,MI,MS)         ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe2                   ,MD                  ) : \
00629                                                           JITFAIL("illegal mode in loop"))
00630 
00631 #define LOOPEm(MD,MB,MI,MS)        ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe1                   ,MD                  ) : \
00632                                                           JITFAIL("illegal mode in loope"))
00633 
00634 #define LOOPZm(MD,MB,MI,MS)        ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe1                   ,MD                  ) : \
00635                                                           JITFAIL("illegal mode in loopz"))
00636 
00637 #define LOOPNEm(MD,MB,MI,MS)              ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe0                   ,MD                  ) : \
00638                                                           JITFAIL("illegal mode in loopne"))
00639 
00640 #define LOOPNZm(MD,MB,MI,MS)              ((_r0P(MB) && _r0P(MI)) ? _O_D8 (0xe0                   ,MD                  ) : \
00641                                                           JITFAIL("illegal mode in loopnz"))
00642 
00643 
00644 #define MOVBrr(RS, RD)                    _O_Mrm        (0x80         ,_b11,_r1(RS),_r1(RD)                            )
00645 #define MOVBmr(MD, MB, MI, MS, RD) _O_r_X        (0x8a              ,_r1(RD)        ,MD,MB,MI,MS         )
00646 #define MOVBrm(RS, MD, MB, MI, MS) _O_r_X        (0x88              ,_r1(RS)        ,MD,MB,MI,MS         )
00647 #define MOVBir(IM,  R)                    _Or_B         (0xb0,_r1(R)                                     ,_su8(IM))
00648 #define MOVBim(IM, MD, MB, MI, MS) _O_X_B        (0xc6                              ,MD,MB,MI,MS  ,_su8(IM))
00649 
00650 #define MOVWrr(RS, RD)                    _wO_Mrm              (0x89         ,_b11,_r2(RS),_r2(RD)                            )
00651 #define MOVWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x8b              ,_r2(RD)        ,MD,MB,MI,MS         )
00652 #define MOVWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x89              ,_r2(RS)        ,MD,MB,MI,MS         )
00653 #define MOVWir(IM,  R)                    _wOr_W        (0xb8,_r2(R)                                     ,_su16(IM))
00654 #define MOVWim(IM, MD, MB, MI, MS) _wO_X_W              (0xc7                              ,MD,MB,MI,MS  ,_su16(IM))
00655 
00656 #define MOVLrr(RS, RD)                    _O_Mrm        (0x89         ,_b11,_r4(RS),_r4(RD)                            )
00657 #define MOVLmr(MD, MB, MI, MS, RD) _O_r_X        (0x8b              ,_r4(RD)        ,MD,MB,MI,MS         )
00658 #define MOVLrm(RS, MD, MB, MI, MS) _O_r_X        (0x89              ,_r4(RS)        ,MD,MB,MI,MS         )
00659 #define MOVLir(IM,  R)                    _Or_L         (0xb8,_r4(R)                                     ,IM    )
00660 #define MOVLim(IM, MD, MB, MI, MS) _O_X_L        (0xc7                              ,MD,MB,MI,MS  ,IM    )
00661 
00662 #define MOVQmr(MD, MB, MI, MS, RD) _qO_r_X              (0x8b              ,_r8(RD)        ,MD,MB,MI,MS         )
00663 #define MOVQrm(RS, MD, MB, MI, MS) _qO_r_X              (0x89              ,_r8(RS)        ,MD,MB,MI,MS         )
00664 #define MOVQrQm(RS, MD, MB, MI, MS)       _qO_r_XB             (0x89              ,_r8(RS)        ,MD,MB,MI,MS         )
00665 #define MOVQir(IM,  R)                    _qOr_Q         (0xb8,_r8(R)               ,IM    )
00666 
00667 #define MOVQrr(RS, RD)                    _qO_Mrm              (0x89         ,_b11,_r8(RS),_r8(RD)                            )
00668 
00669 #define MOVZBLrr(RS, RD)           _OO_Mrm              (0x0fb6              ,_b11,_r1(RD),_r1(RS)                            )
00670 #define MOVZBLmr(MD, MB, MI, MS, RD)      _OO_r_X              (0x0fb6                   ,_r1(RD)        ,MD,MB,MI,MS         )
00671 #define MOVZBWrr(RS, RD)           _wOO_Mrm      (0x0fb6              ,_b11,_r2(RD),_r2(RS)                            )
00672 #define MOVZBWmr(MD, MB, MI, MS, RD)      _wOO_r_X      (0x0fb6                   ,_r2(RD)        ,MD,MB,MI,MS         )
00673 #define MOVZWLrr(RS, RD)           _OO_Mrm              (0x0fb7              ,_b11,_r1(RD),_r1(RS)                            )
00674 #define MOVZWLmr(MD, MB, MI, MS, RD)      _OO_r_X              (0x0fb7                   ,_r1(RD)        ,MD,MB,MI,MS         )
00675 
00676 #define MOVSBLrr(RS, RD)           _OO_Mrm              (0x0fbe              ,_b11,_r1(RD),_r1(RS)                            )
00677 #define MOVSBLmr(MD, MB, MI, MS, RD)      _OO_r_X              (0x0fbe                   ,_r1(RD)        ,MD,MB,MI,MS         )
00678 #define MOVSBWrr(RS, RD)           _wOO_Mrm      (0x0fbe              ,_b11,_r2(RD),_r2(RS)                            )
00679 #define MOVSBWmr(MD, MB, MI, MS, RD)      _wOO_r_X      (0x0fbe                   ,_r2(RD)        ,MD,MB,MI,MS         )
00680 #define MOVSWLrr(RS, RD)           _OO_Mrm              (0x0fbf              ,_b11,_r1(RD),_r1(RS)                            )
00681 #define MOVSWLmr(MD, MB, MI, MS, RD)      _OO_r_X              (0x0fbf                   ,_r1(RD)        ,MD,MB,MI,MS         )
00682 
00683 
00684 #define MULBr(RS)                  _O_Mrm        (0xf6         ,_b11,_b100  ,_r1(RS)                            )
00685 #define MULBm(MD,MB,MI,MS)         _O_r_X        (0xf6              ,_b100          ,MD,MB,MI,MS         )
00686 
00687 #define MULWr(RS)                  _wO_Mrm       (0xf7         ,_b11,_b100  ,_r2(RS)                            )
00688 #define MULWm(MD,MB,MI,MS)         _wO_r_X       (0xf7              ,_b100          ,MD,MB,MI,MS         )
00689 
00690 #define MULLr(RS)                  _O_Mrm        (0xf7         ,_b11,_b100  ,_r4(RS)                            )
00691 #define MULLm(MD,MB,MI,MS)         _O_r_X        (0xf7              ,_b100          ,MD,MB,MI,MS         )
00692 
00693 
00694 #define NEGBr(RD)                  _O_Mrm        (0xf6         ,_b11,_b011  ,_r1(RD)                            )
00695 #define NEGBm(MD,MB,MI,MS)         _O_r_X        (0xf6              ,_b011          ,MD,MB,MI,MS         )
00696 
00697 #define NEGWr(RD)                  _wO_Mrm              (0xf7         ,_b11,_b011  ,_r2(RD)                            )
00698 #define NEGWm(MD,MB,MI,MS)         _wO_r_X              (0xf7              ,_b011          ,MD,MB,MI,MS         )
00699 
00700 #define NEGLr(RD)                  _O_Mrm        (0xf7         ,_b11,_b011  ,_r4(RD)                            )
00701 #define NEGLm(MD,MB,MI,MS)         _O_r_X        (0xf7              ,_b011          ,MD,MB,MI,MS         )
00702 
00703 #define NEGQr(RD)                  _qO_Mrm              (0xf7         ,_b11,_b011  ,_r8(RD)                            )
00704 
00705 #define NOP_()                            _O            (0x90                                                   )
00706 
00707 
00708 #define NOTBr(RD)                  _O_Mrm        (0xf6         ,_b11,_b010  ,_r1(RD)                            )
00709 #define NOTBm(MD,MB,MI,MS)         _O_r_X        (0xf6              ,_b010          ,MD,MB,MI,MS         )
00710 
00711 #define NOTWr(RD)                  _wO_Mrm              (0xf7         ,_b11,_b010  ,_r2(RD)                            )
00712 #define NOTWm(MD,MB,MI,MS)         _wO_r_X              (0xf7              ,_b010          ,MD,MB,MI,MS         )
00713 
00714 #define NOTLr(RD)                  _O_Mrm        (0xf7         ,_b11,_b010  ,_r4(RD)                            )
00715 #define NOTLm(MD,MB,MI,MS)         _O_r_X        (0xf7              ,_b010          ,MD,MB,MI,MS         )
00716 
00717 
00718 #define ORBrr(RS, RD)                     _O_Mrm        (0x08         ,_b11,_r1(RS),_r1(RD)                            )
00719 #define ORBmr(MD, MB, MI, MS, RD)  _O_r_X        (0x0a              ,_r1(RD)        ,MD,MB,MI,MS         )
00720 #define ORBrm(RS, MD, MB, MI, MS)  _O_r_X        (0x08              ,_r1(RS)        ,MD,MB,MI,MS         )
00721 #define ORBir(IM, RD)                     _O_Mrm_B      (0x80         ,_b11,_b001  ,_r1(RD)                     ,_su8(IM))
00722 #define ORBim(IM, MD, MB, MI, MS)  _O_r_X_B      (0x80              ,_b001          ,MD,MB,MI,MS  ,_su8(IM))
00723 
00724 #define ORWrr(RS, RD)                     _wO_Mrm              (0x09         ,_b11,_r2(RS),_r2(RD)                            )
00725 #define ORWmr(MD, MB, MI, MS, RD)  _wO_r_X              (0x0b              ,_r2(RD)        ,MD,MB,MI,MS         )
00726 #define ORWrm(RS, MD, MB, MI, MS)  _wO_r_X              (0x09              ,_r2(RS)        ,MD,MB,MI,MS         )
00727 #define ORWir(IM, RD)                     _wOs_Mrm_sW   (0x81         ,_b11,_b001  ,_r2(RD)                     ,_su16(IM))
00728 #define ORWim(IM, MD, MB, MI, MS)  _wOs_r_X_sW   (0x81              ,_b001          ,MD,MB,MI,MS  ,_su16(IM))
00729 
00730 #define ORLrr(RS, RD)                     _O_Mrm        (0x09         ,_b11,_r4(RS),_r4(RD)                            )
00731 #define ORLmr(MD, MB, MI, MS, RD)  _O_r_X        (0x0b              ,_r4(RD)        ,MD,MB,MI,MS         )
00732 #define ORLrm(RS, MD, MB, MI, MS)  _O_r_X        (0x09              ,_r4(RS)        ,MD,MB,MI,MS         )
00733 #define ORLir(IM, RD)                     _Os_Mrm_sL    (0x81         ,_b11,_b001  ,_r4(RD)                     ,IM    )
00734 #define ORLim(IM, MD, MB, MI, MS)  _Os_r_X_sL    (0x81              ,_b001          ,MD,MB,MI,MS  ,IM    )
00735 
00736 #define ORQrr(RS, RD)                     _qO_Mrm              (0x09         ,_b11,_r8(RS),_r8(RD)                            )
00737 #define ORQir(IM, RD)                     _qOs_Mrm_sL   (0x81         ,_b11,_b001  ,_r8(RD)                     ,IM    )
00738 
00739 #define POPWr(RD)                  _wOr          (0x58,_r2(RD)                                           )
00740 #define POPWm(MD,MB,MI,MS)         _wO_r_X              (0x8f              ,_b000          ,MD,MB,MI,MS         )
00741 
00742 #define POPLr(RD)                  _Or           (0x58,_r4(RD)                                           )
00743 #define POPLm(MD,MB,MI,MS)         _O_r_X        (0x8f              ,_b000          ,MD,MB,MI,MS         )
00744 
00745 #define POPQr(RD)                  _qOr          (0x58,_r8(RD)                                           )
00746 
00747 
00748 #define POPA_()                           _wO           (0x61                                                   )
00749 #define POPAD_()                   _O            (0x61                                                   )
00750 
00751 #define POPF_()                           _wO           (0x9d                                                   )
00752 #define POPFD_()                   _O            (0x9d                                                   )
00753 
00754 
00755 #define PUSHWr(R)                  _wOr          (0x50,_r2(R)                                            )
00756 #define PUSHWm(MD,MB,MI,MS)        _wO_r_X              (0xff,             ,_b110          ,MD,MB,MI,MS         )
00757 #define PUSHWi(IM)                 _wOs_sW              (0x68                                            ,IM    )
00758 
00759 #define PUSHLr(R)                  _Or           (0x50,_r4(R)                                            )
00760 #define PUSHLm(MD,MB,MI,MS)        _O_r_X        (0xff              ,_b110          ,MD,MB,MI,MS         )
00761 #define PUSHLi(IM)                 _Os_sL        (0x68                                            ,IM    )
00762 
00763 #define PUSHQr(R)                  _qOr          (0x50,_r8(R)                                            )
00764 
00765 #define PUSHA_()                   _wO           (0x60                                                   )
00766 #define PUSHAD_()                  _O            (0x60                                                   )
00767 
00768 #define PUSHF_()                   _O            (0x9c                                                   )
00769 #define PUSHFD_()                  _wO           (0x9c                                                   )
00770 
00771 #define RET_()                            _O            (0xc3                                                   )
00772 #define RETi(IM)                   _O_W          (0xc2                                            ,_su16(IM))
00773 
00774 
00775 #define ROLBir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd0  ,_b11,_b000,_r1(RD)                       ) : \
00776                                           _O_Mrm_B      (0xc0  ,_b11,_b000,_r1(RD)                ,_u8(IM) ) )
00777 #define ROLBim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd0       ,_b000          ,MD,MB,MI,MS         ) : \
00778                                           _O_r_X_B      (0xc0       ,_b000          ,MD,MB,MI,MS  ,_u8(IM) ) )
00779 #define ROLBrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd2  ,_b11,_b000,_r1(RD)                       ) : \
00780                                           JITFAIL              ("source register must be CL"                           ) )
00781 #define ROLBrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd2       ,_b000          ,MD,MB,MI,MS         ) : \
00782                                           JITFAIL              ("source register must be CL"                           ) )
00783 
00784 #define ROLWir(IM,RD)              (((IM)==1) ?  _wO_Mrm (0xd1 ,_b11,_b000,_r2(RD)                       ) : \
00785                                           _wO_Mrm_B     (0xc1  ,_b11,_b000,_r2(RD)                ,_u8(IM) ) )
00786 #define ROLWim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _wO_r_X (0xd1      ,_b000          ,MD,MB,MI,MS         ) : \
00787                                           _wO_r_X_B     (0xc1       ,_b000          ,MD,MB,MI,MS  ,_u8(IM) ) )
00788 #define ROLWrr(RS,RD)              (((RS)==_CL) ?       _wO_Mrm (0xd3 ,_b11,_b000,_r2(RD)                       ) : \
00789                                           JITFAIL ("source register must be CL"                                 ) )
00790 #define ROLWrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _wO_r_X (0xd3      ,_b000          ,MD,MB,MI,MS         ) : \
00791                                           JITFAIL ("source register must be CL"                                 ) )
00792 
00793 #define ROLLir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd1  ,_b11,_b000,_r4(RD)                       ) : \
00794                                           _O_Mrm_B      (0xc1  ,_b11,_b000,_r4(RD)                ,_u8(IM) ) )
00795 #define ROLLim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd1       ,_b000          ,MD,MB,MI,MS         ) : \
00796                                           _O_r_X_B      (0xc1       ,_b000          ,MD,MB,MI,MS  ,_u8(IM) ) )
00797 #define ROLLrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd3  ,_b11,_b000,_r4(RD)                       ) : \
00798                                           JITFAIL              ("source register must be CL"                           ) )
00799 #define ROLLrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd3       ,_b000          ,MD,MB,MI,MS         ) : \
00800                                           JITFAIL              ("source register must be CL"                           ) )
00801 
00802 
00803 #define RORBir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd0  ,_b11,_b001,_r1(RD)                       ) : \
00804                                           _O_Mrm_B      (0xc0  ,_b11,_b001,_r1(RD)                ,_u8(IM) ) )
00805 #define RORBim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd0       ,_b001          ,MD,MB,MI,MS         ) : \
00806                                           _O_r_X_B      (0xc0       ,_b001          ,MD,MB,MI,MS  ,_u8(IM) ) )
00807 #define RORBrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd2  ,_b11,_b001,_r1(RD)                       ) : \
00808                                           JITFAIL              ("source register must be CL"                           ) )
00809 #define RORBrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd2       ,_b001          ,MD,MB,MI,MS         ) : \
00810                                           JITFAIL              ("source register must be CL"                           ) )
00811 
00812 #define RORWir(IM,RD)              (((IM)==1) ?  _wO_Mrm (0xd1 ,_b11,_b001,_r2(RD)                       ) : \
00813                                           _wO_Mrm_B     (0xc1  ,_b11,_b001,_r2(RD)                ,_u8(IM) ) )
00814 #define RORWim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _wO_r_X (0xd1      ,_b001          ,MD,MB,MI,MS         ) : \
00815                                           _wO_r_X_B     (0xc1       ,_b001          ,MD,MB,MI,MS  ,_u8(IM) ) )
00816 #define RORWrr(RS,RD)              (((RS)==_CL) ?       _wO_Mrm (0xd3 ,_b11,_b001,_r2(RD)                       ) : \
00817                                           JITFAIL ("source register must be CL"                                 ) )
00818 #define RORWrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _wO_r_X (0xd3      ,_b001          ,MD,MB,MI,MS         ) : \
00819                                           JITFAIL ("source register must be CL"                                 ) )
00820 
00821 #define RORLir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd1  ,_b11,_b001,_r4(RD)                       ) : \
00822                                           _O_Mrm_B      (0xc1  ,_b11,_b001,_r4(RD)                ,_u8(IM) ) )
00823 #define RORLim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd1       ,_b001          ,MD,MB,MI,MS         ) : \
00824                                           _O_r_X_B      (0xc1       ,_b001          ,MD,MB,MI,MS  ,_u8(IM) ) )
00825 #define RORLrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd3  ,_b11,_b001,_r4(RD)                       ) : \
00826                                           JITFAIL              ("source register must be CL"                           ) )
00827 #define RORLrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd3       ,_b001          ,MD,MB,MI,MS         ) : \
00828                                           JITFAIL              ("source register must be CL"                           ) )
00829 
00830 
00831 #define SAHF_()                                  _O     (0x9e                                                   )
00832 
00833 
00834 #define SALBir       SHLBir
00835 #define SALBim       SHLBim
00836 #define SALBrr       SHLBrr
00837 #define SALBrm       SHLBrm
00838 #define SALWir       SHLWir
00839 #define SALWim       SHLWim
00840 #define SALWrr       SHLWrr
00841 #define SALWrm       SHLWrm
00842 #define SALLir       SHLLir
00843 #define SALLim       SHLLim
00844 #define SALLrr       SHLLrr
00845 #define SALLrm       SHLLrm
00846 #define SALQir       SHLQir
00847 #define SALQim       SHLQim
00848 #define SALQrr       SHLQrr
00849 #define SALQrm       SHLQrm
00850 
00851 
00852 #define SARBir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd0  ,_b11,_b111,_r1(RD)                       ) : \
00853                                           _O_Mrm_B      (0xc0  ,_b11,_b111,_r1(RD)                ,_u8(IM) ) )
00854 #define SARBim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd0       ,_b111          ,MD,MB,MI,MS         ) : \
00855                                           _O_r_X_B      (0xc0       ,_b111          ,MD,MB,MI,MS  ,_u8(IM) ) )
00856 #define SARBrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd2  ,_b11,_b111,_r1(RD)                       ) : \
00857                                           JITFAIL              ("source register must be CL"                           ) )
00858 #define SARBrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd2       ,_b111          ,MD,MB,MI,MS         ) : \
00859                                           JITFAIL              ("source register must be CL"                           ) )
00860 
00861 #define SARWir(IM,RD)              (((IM)==1) ?  _wO_Mrm (0xd1 ,_b11,_b111,_r2(RD)                       ) : \
00862                                           _wO_Mrm_B     (0xc1  ,_b11,_b111,_r2(RD)                ,_u8(IM) ) )
00863 #define SARWim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _wO_r_X (0xd1      ,_b111          ,MD,MB,MI,MS         ) : \
00864                                           _wO_r_X_B     (0xc1       ,_b111          ,MD,MB,MI,MS  ,_u8(IM) ) )
00865 #define SARWrr(RS,RD)              (((RS)==_CL) ?       _wO_Mrm (0xd3 ,_b11,_b111,_r2(RD)                       ) : \
00866                                           JITFAIL ("source register must be CL"                                 ) )
00867 #define SARWrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _wO_r_X (0xd3      ,_b111          ,MD,MB,MI,MS         ) : \
00868                                           JITFAIL ("source register must be CL"                                 ) )
00869 
00870 #define SARLir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd1  ,_b11,_b111,_r4(RD)                       ) : \
00871                                           _O_Mrm_B      (0xc1  ,_b11,_b111,_r4(RD)                ,_u8(IM) ) )
00872 #define SARLim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd1       ,_b111          ,MD,MB,MI,MS         ) : \
00873                                           _O_r_X_B      (0xc1       ,_b111          ,MD,MB,MI,MS  ,_u8(IM) ) )
00874 #define SARLrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd3  ,_b11,_b111,_r4(RD)                       ) : \
00875                                           JITFAIL              ("source register must be CL"                           ) )
00876 #define SARLrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd3       ,_b111          ,MD,MB,MI,MS         ) : \
00877                                           JITFAIL              ("source register must be CL"                           ) )
00878 
00879 #define SARQir(IM,RD)              (((IM)==1) ?  _qO_Mrm              (0xd1  ,_b11,_b111,_r8(RD)                       ) : \
00880                                           _qO_Mrm_B     (0xc1  ,_b11,_b111,_r4(RD)                ,_u8(IM) ) )
00881 #define SARQrr(RS,RD)              (((RS)==_CL) ?       _qO_Mrm              (0xd3  ,_b11,_b111,_r8(RD)                       ) : \
00882                                           JITFAIL              ("source register must be CL"                           ) )
00883 
00884 
00885 #define SBBBrr(RS, RD)                    _O_Mrm        (0x18         ,_b11,_r1(RS),_r1(RD)                            )
00886 #define SBBBmr(MD, MB, MI, MS, RD) _O_r_X        (0x1a              ,_r1(RD)        ,MD,MB,MI,MS         )
00887 #define SBBBrm(RS, MD, MB, MI, MS) _O_r_X        (0x18              ,_r1(RS)        ,MD,MB,MI,MS         )
00888 #define SBBBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b011  ,_r1(RD)                     ,_su8(IM))
00889 #define SBBBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b011          ,MD,MB,MI,MS  ,_su8(IM))
00890 
00891 #define SBBWrr(RS, RD)                    _wO_Mrm       (0x19         ,_b11,_r2(RS),_r2(RD)                            )
00892 #define SBBWmr(MD, MB, MI, MS, RD) _wO_r_X       (0x1b              ,_r2(RD)        ,MD,MB,MI,MS         )
00893 #define SBBWrm(RS, MD, MB, MI, MS) _wO_r_X       (0x19              ,_r2(RS)        ,MD,MB,MI,MS         )
00894 #define SBBWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b011  ,_r2(RD)                     ,_su16(IM))
00895 #define SBBWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b011          ,MD,MB,MI,MS  ,_su16(IM))
00896 
00897 #define SBBLrr(RS, RD)                    _O_Mrm        (0x19         ,_b11,_r4(RS),_r4(RD)                            )
00898 #define SBBLmr(MD, MB, MI, MS, RD) _O_r_X        (0x1b              ,_r4(RD)        ,MD,MB,MI,MS         )
00899 #define SBBLrm(RS, MD, MB, MI, MS) _O_r_X        (0x19              ,_r4(RS)        ,MD,MB,MI,MS         )
00900 #define SBBLir(IM, RD)                    _Os_Mrm_sL    (0x81         ,_b11,_b011  ,_r4(RD)                     ,IM    )
00901 #define SBBLim(IM, MD, MB, MI, MS) _Os_r_X_sL    (0x81              ,_b011          ,MD,MB,MI,MS  ,IM    )
00902 
00903 
00904 #define SETCCir(CC,RD)                    _OO_Mrm              (0x0f90|(CC)  ,_b11,_b000,_r1(RD)                       )
00905 
00906 #define SETOr(RD)                  SETCCir(0x0,RD)
00907 #define SETNOr(RD)                 SETCCir(0x1,RD)
00908 #define SETBr(RD)                  SETCCir(0x2,RD)
00909 #define SETNAEr(RD)                SETCCir(0x2,RD)
00910 #define SETNBr(RD)                 SETCCir(0x3,RD)
00911 #define SETAEr(RD)                 SETCCir(0x3,RD)
00912 #define SETEr(RD)                  SETCCir(0x4,RD)
00913 #define SETZr(RD)                  SETCCir(0x4,RD)
00914 #define SETNEr(RD)                 SETCCir(0x5,RD)
00915 #define SETNZr(RD)                 SETCCir(0x5,RD)
00916 #define SETBEr(RD)                 SETCCir(0x6,RD)
00917 #define SETNAr(RD)                 SETCCir(0x6,RD)
00918 #define SETNBEr(RD)                SETCCir(0x7,RD)
00919 #define SETAr(RD)                  SETCCir(0x7,RD)
00920 #define SETSr(RD)                  SETCCir(0x8,RD)
00921 #define SETNSr(RD)                 SETCCir(0x9,RD)
00922 #define SETPr(RD)                  SETCCir(0xa,RD)
00923 #define SETPEr(RD)                 SETCCir(0xa,RD)
00924 #define SETNPr(RD)                 SETCCir(0xb,RD)
00925 #define SETPOr(RD)                 SETCCir(0xb,RD)
00926 #define SETLr(RD)                  SETCCir(0xc,RD)
00927 #define SETNGEr(RD)                SETCCir(0xc,RD)
00928 #define SETNLr(RD)                 SETCCir(0xd,RD)
00929 #define SETGEr(RD)                 SETCCir(0xd,RD)
00930 #define SETLEr(RD)                 SETCCir(0xe,RD)
00931 #define SETNGr(RD)                 SETCCir(0xe,RD)
00932 #define SETNLEr(RD)                SETCCir(0xf,RD)
00933 #define SETGr(RD)                  SETCCir(0xf,RD)
00934 
00935 #define SETCCim(CC,MD,MB,MI,MS)           _OO_r_X              (0x0f90|(CC)       ,_b000          ,MD,MB,MI,MS         )
00936 
00937 #define SETOm(D,B,I,S)                    SETCCim(0x0,D,B,I,S)
00938 #define SETNOm(D,B,I,S)                   SETCCim(0x1,D,B,I,S)
00939 #define SETBm(D,B,I,S)                    SETCCim(0x2,D,B,I,S)
00940 #define SETNAEm(D,B,I,S)           SETCCim(0x2,D,B,I,S)
00941 #define SETNBm(D,B,I,S)                   SETCCim(0x3,D,B,I,S)
00942 #define SETAEm(D,B,I,S)                   SETCCim(0x3,D,B,I,S)
00943 #define SETEm(D,B,I,S)                    SETCCim(0x4,D,B,I,S)
00944 #define SETZm(D,B,I,S)                    SETCCim(0x4,D,B,I,S)
00945 #define SETNEm(D,B,I,S)                   SETCCim(0x5,D,B,I,S)
00946 #define SETNZm(D,B,I,S)                   SETCCim(0x5,D,B,I,S)
00947 #define SETBEm(D,B,I,S)                   SETCCim(0x6,D,B,I,S)
00948 #define SETNAm(D,B,I,S)                   SETCCim(0x6,D,B,I,S)
00949 #define SETNBEm(D,B,I,S)           SETCCim(0x7,D,B,I,S)
00950 #define SETAm(D,B,I,S)                    SETCCim(0x7,D,B,I,S)
00951 #define SETSm(D,B,I,S)                    SETCCim(0x8,D,B,I,S)
00952 #define SETNSm(D,B,I,S)                   SETCCim(0x9,D,B,I,S)
00953 #define SETPm(D,B,I,S)                    SETCCim(0xa,D,B,I,S)
00954 #define SETPEm(D,B,I,S)                   SETCCim(0xa,D,B,I,S)
00955 #define SETNPm(D,B,I,S)                   SETCCim(0xb,D,B,I,S)
00956 #define SETPOm(D,B,I,S)                   SETCCim(0xb,D,B,I,S)
00957 #define SETLm(D,B,I,S)                    SETCCim(0xc,D,B,I,S)
00958 #define SETNGEm(D,B,I,S)           SETCCim(0xc,D,B,I,S)
00959 #define SETNLm(D,B,I,S)                   SETCCim(0xd,D,B,I,S)
00960 #define SETGEm(D,B,I,S)                   SETCCim(0xd,D,B,I,S)
00961 #define SETLEm(D,B,I,S)                   SETCCim(0xe,D,B,I,S)
00962 #define SETNGm(D,B,I,S)                   SETCCim(0xe,D,B,I,S)
00963 #define SETNLEm(D,B,I,S)           SETCCim(0xf,D,B,I,S)
00964 #define SETGm(D,B,I,S)                    SETCCim(0xf,D,B,I,S)
00965 
00966 
00967 #define SHLBir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd0  ,_b11,_b100,_r1(RD)                       ) : \
00968                                           _O_Mrm_B      (0xc0  ,_b11,_b100,_r1(RD)                ,_u8(IM) ) )
00969 #define SHLBim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd0       ,_b100          ,MD,MB,MI,MS         ) : \
00970                                           _O_r_X_B      (0xc0       ,_b100          ,MD,MB,MI,MS  ,_u8(IM) ) )
00971 #define SHLBrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd2  ,_b11,_b100,_r1(RD)                       ) : \
00972                                           JITFAIL              ("source register must be CL"                           ) )
00973 #define SHLBrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd2       ,_b100          ,MD,MB,MI,MS         ) : \
00974                                           JITFAIL              ("source register must be CL"                           ) )
00975 
00976 #define SHLWir(IM,RD)              (((IM)==1) ?  _wO_Mrm              (0xd1  ,_b11,_b100,_r2(RD)                       ) : \
00977                                           _wO_Mrm_B     (0xc1  ,_b11,_b100,_r2(RD)                ,_u8(IM) ) )
00978 #define SHLWim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _wO_r_X              (0xd1       ,_b100          ,MD,MB,MI,MS         ) : \
00979                                           _wO_r_X_B     (0xc1       ,_b100          ,MD,MB,MI,MS  ,_u8(IM) ) )
00980 #define SHLWrr(RS,RD)              (((RS)==_CL) ?       _wO_Mrm              (0xd3  ,_b11,_b100,_r2(RD)                       ) : \
00981                                           JITFAIL              ("source register must be CL"                           ) )
00982 #define SHLWrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _wO_r_X              (0xd3       ,_b100          ,MD,MB,MI,MS         ) : \
00983                                           JITFAIL              ("source register must be CL"                                  ) )
00984 
00985 #define SHLLir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd1  ,_b11,_b100,_r4(RD)                       ) : \
00986                                           _O_Mrm_B      (0xc1  ,_b11,_b100,_r4(RD)                ,_u8(IM) ) )
00987 #define SHLLim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd1       ,_b100          ,MD,MB,MI,MS         ) : \
00988                                           _O_r_X_B      (0xc1       ,_b100          ,MD,MB,MI,MS  ,_u8(IM) ) )
00989 #define SHLLrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd3  ,_b11,_b100,_r4(RD)                       ) : \
00990                                           JITFAIL              ("source register must be CL"                           ) )
00991 #define SHLLrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd3       ,_b100          ,MD,MB,MI,MS         ) : \
00992                                           JITFAIL              ("source register must be CL"                           ) )
00993 
00994 #define SHLQir(IM,RD)              (((IM)==1) ?  _qO_Mrm              (0xd1  ,_b11,_b100,_r8(RD)                       ) : \
00995                                           _qO_Mrm_B     (0xc1  ,_b11,_b100,_r8(RD)                ,_u8(IM) ) )
00996 #define SHLQrr(RS,RD)              (((RS)==_CL) ?       _qO_Mrm              (0xd3  ,_b11,_b100,_r8(RD)                       ) : \
00997                                           JITFAIL              ("source register must be CL"                           ) )
00998 
00999 
01000 #define SHRBir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd0  ,_b11,_b101,_r1(RD)                       ) : \
01001                                           _O_Mrm_B      (0xc0  ,_b11,_b101,_r1(RD)                ,_u8(IM) ) )
01002 #define SHRBim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd0       ,_b101          ,MD,MB,MI,MS         ) : \
01003                                           _O_r_X_B      (0xc0       ,_b101          ,MD,MB,MI,MS  ,_u8(IM) ) )
01004 #define SHRBrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd2  ,_b11,_b101,_r1(RD)                       ) : \
01005                                           JITFAIL              ("source register must be CL"                           ) )
01006 #define SHRBrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd2       ,_b101          ,MD,MB,MI,MS         ) : \
01007                                           JITFAIL              ("source register must be CL"                           ) )
01008 
01009 #define SHRWir(IM,RD)              (((IM)==1) ?  _wO_Mrm              (0xd1  ,_b11,_b101,_r2(RD)                       ) : \
01010                                           _wO_Mrm_B     (0xc1  ,_b11,_b101,_r2(RD)                ,_u8(IM) ) )
01011 #define SHRWim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _wO_r_X              (0xd1       ,_b101          ,MD,MB,MI,MS         ) : \
01012                                           _wO_r_X_B     (0xc1       ,_b101          ,MD,MB,MI,MS  ,_u8(IM) ) )
01013 #define SHRWrr(RS,RD)              (((RS)==_CL) ?       _wO_Mrm              (0xd3  ,_b11,_b101,_r2(RD)                       ) : \
01014                                           JITFAIL              ("source register must be CL"                           ) )
01015 #define SHRWrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _wO_r_X              (0xd3       ,_b101          ,MD,MB,MI,MS         ) : \
01016                                           JITFAIL              ("source register must be CL"                           ) )
01017 
01018 #define SHRLir(IM,RD)              (((IM)==1) ?  _O_Mrm        (0xd1  ,_b11,_b101,_r4(RD)                       ) : \
01019                                           _O_Mrm_B      (0xc1  ,_b11,_b101,_r4(RD)                ,_u8(IM) ) )
01020 #define SHRLim(IM,MD,MB,MS,MI)     (((IM)==1) ?  _O_r_X        (0xd1       ,_b101          ,MD,MB,MI,MS         ) : \
01021                                           _O_r_X_B      (0xc1       ,_b101          ,MD,MB,MI,MS  ,_u8(IM) ) )
01022 #define SHRLrr(RS,RD)              (((RS)==_CL) ?       _O_Mrm        (0xd3  ,_b11,_b101,_r4(RD)                       ) : \
01023                                           JITFAIL              ("source register must be CL"                           ) )
01024 #define SHRLrm(RS,MD,MB,MS,MI)     (((RS)==_CL) ?       _O_r_X        (0xd3       ,_b101          ,MD,MB,MI,MS         ) : \
01025                                           JITFAIL              ("source register must be CL"                           ) )
01026 
01027 #define SHRQir(IM,RD)              (((IM)==1) ?  _qO_Mrm              (0xd1  ,_b11,_b101,_r8(RD)                       ) : \
01028                                           _qO_Mrm_B     (0xc1  ,_b11,_b101,_r8(RD)                ,_u8(IM) ) )
01029 #define SHRQrr(RS,RD)              (((RS)==_CL) ?       _qO_Mrm              (0xd3  ,_b11,_b101,_r8(RD)                       ) : \
01030                                           JITFAIL              ("source register must be CL"                           ) )
01031 
01032 
01033 #define STC_()                            _O            (0xf9                                                   )
01034 
01035 
01036 #define SUBBrr(RS, RD)                    _O_Mrm        (0x28         ,_b11,_r1(RS),_r1(RD)                            )
01037 #define SUBBmr(MD, MB, MI, MS, RD) _O_r_X        (0x2a              ,_r1(RD)        ,MD,MB,MI,MS         )
01038 #define SUBBrm(RS, MD, MB, MI, MS) _O_r_X        (0x28              ,_r1(RS)        ,MD,MB,MI,MS         )
01039 #define SUBBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b101  ,_r1(RD)                     ,_su8(IM))
01040 #define SUBBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b101          ,MD,MB,MI,MS  ,_su8(IM))
01041 
01042 #define SUBWrr(RS, RD)                    _wO_Mrm              (0x29         ,_b11,_r2(RS),_r2(RD)                            )
01043 #define SUBWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x2b              ,_r2(RD)        ,MD,MB,MI,MS         )
01044 #define SUBWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x29              ,_r2(RS)        ,MD,MB,MI,MS         )
01045 #define SUBWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b101  ,_r2(RD)                     ,_su16(IM))
01046 #define SUBWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b101          ,MD,MB,MI,MS  ,_su16(IM))
01047 
01048 #define SUBLrr(RS, RD)                    _O_Mrm        (0x29         ,_b11,_r4(RS),_r4(RD)                            )
01049 #define SUBLmr(MD, MB, MI, MS, RD) _O_r_X        (0x2b              ,_r4(RD)        ,MD,MB,MI,MS         )
01050 #define SUBLrm(RS, MD, MB, MI, MS) _O_r_X        (0x29              ,_r4(RS)        ,MD,MB,MI,MS         )
01051 #define SUBLir(IM, RD)                    _Os_Mrm_sL    (0x81         ,_b11,_b101  ,_r4(RD)                     ,IM    )
01052 #define SUBLim(IM, MD, MB, MI, MS) _Os_r_X_sL    (0x81              ,_b101          ,MD,MB,MI,MS  ,IM    )
01053 
01054 #define SUBQrr(RS, RD)                    _qO_Mrm              (0x29         ,_b11,_r8(RS),_r8(RD)                            )
01055 #define SUBQir(IM, RD)                    _qOs_Mrm_sL   (0x81         ,_b11,_b101  ,_r8(RD)                     ,IM    )
01056 
01057 #define TESTBrr(RS, RD)                   _O_Mrm        (0x84         ,_b11,_r1(RS),_r1(RD)                            )
01058 #define TESTBrm(RS, MD, MB, MI, MS)       _O_r_X        (0x84              ,_r1(RS)        ,MD,MB,MI,MS         )
01059 #define TESTBir(IM, RD)                   _O_Mrm_B      (0xf6         ,_b11,_b000  ,_r1(RD)                     ,_u8(IM))
01060 #define TESTBim(IM, MD, MB, MI, MS)       _O_r_X_B      (0xf6              ,_b000          ,MD,MB,MI,MS  ,_u8(IM))
01061 
01062 #define TESTWrr(RS, RD)                   _wO_Mrm              (0x85         ,_b11,_r2(RS),_r2(RD)                            )
01063 #define TESTWrm(RS, MD, MB, MI, MS)       _wO_r_X              (0x85              ,_r2(RS)        ,MD,MB,MI,MS         )
01064 #define TESTWir(IM, RD)                   _wO_Mrm_W     (0xf7         ,_b11,_b000  ,_r2(RD)                     ,_u16(IM))
01065 #define TESTWim(IM, MD, MB, MI, MS)       _wO_r_X_W     (0xf7              ,_b000          ,MD,MB,MI,MS  ,_u16(IM))
01066 
01067 #define TESTLrr(RS, RD)                   _O_Mrm        (0x85         ,_b11,_r4(RS),_r4(RD)                            )
01068 #define TESTLrm(RS, MD, MB, MI, MS)       _O_r_X        (0x85              ,_r4(RS)        ,MD,MB,MI,MS         )
01069 #define TESTLir(IM, RD)                   _O_Mrm_L      (0xf7         ,_b11,_b000  ,_r4(RD)                     ,IM    )
01070 #define TESTLim(IM, MD, MB, MI, MS)       _O_r_X_L      (0xf7              ,_b000          ,MD,MB,MI,MS  ,IM    )
01071 
01072 #define TESTQrr(RS, RD)                   _qO_Mrm              (0x85         ,_b11,_r8(RS),_r8(RD)                            )
01073 #define TESTQir(IM, RD)                   _qO_Mrm_L     (0xf7         ,_b11,_b000  ,_r8(RD)                     ,IM    )
01074 
01075 
01076 #define XADDBrr(RS,RD)                    _OO_Mrm              (0x0fc0              ,_b11,_r1(RS),_r1(RD)                            )
01077 #define XADDBrm(RS,MD,MB,MI,MS)           _OO_r_X              (0x0fc0                   ,_r1(RS)        ,MD,MB,MI,MS         )
01078 
01079 #define XADDWrr(RS,RD)                    _wOO_Mrm      (0x0fc1              ,_b11,_r2(RS),_r2(RD)                            )
01080 #define XADDWrm(RS,MD,MB,MI,MS)           _wOO_r_X      (0x0fc1                   ,_r2(RS)        ,MD,MB,MI,MS         )
01081 
01082 #define XADDLrr(RS,RD)                    _OO_Mrm              (0x0fc1              ,_b11,_r4(RS),_r4(RD)                            )
01083 #define XADDLrm(RS,MD,MB,MI,MS)           _OO_r_X              (0x0fc1                   ,_r4(RS)        ,MD,MB,MI,MS         )
01084 
01085 
01086 #define XCHGBrr(RS,RD)                    _O_Mrm        (0x86         ,_b11,_r1(RS),_r1(RD)                            )
01087 #define XCHGBrm(RS,MD,MB,MI,MS)           _O_r_X        (0x86              ,_r1(RS)        ,MD,MB,MI,MS         )
01088 
01089 #define XCHGWrr(RS,RD)                    _wO_Mrm              (0x87         ,_b11,_r2(RS),_r2(RD)                            )
01090 #define XCHGWrm(RS,MD,MB,MI,MS)           _wO_r_X              (0x87              ,_r2(RS)        ,MD,MB,MI,MS         )
01091 
01092 #define XCHGLrr(RS,RD)                    _O_Mrm        (0x87         ,_b11,_r4(RS),_r4(RD)                            )
01093 #define XCHGLrm(RS,MD,MB,MI,MS)           _O_r_X        (0x87              ,_r4(RS)        ,MD,MB,MI,MS         )
01094 
01095 
01096 #define XORBrr(RS, RD)                    _O_Mrm        (0x30         ,_b11,_r1(RS),_r1(RD)                            )
01097 #define XORBmr(MD, MB, MI, MS, RD) _O_r_X        (0x32              ,_r1(RD)        ,MD,MB,MI,MS         )
01098 #define XORBrm(RS, MD, MB, MI, MS) _O_r_X        (0x30              ,_r1(RS)        ,MD,MB,MI,MS         )
01099 #define XORBir(IM, RD)                    _O_Mrm_B      (0x80         ,_b11,_b110  ,_r1(RD)                     ,_su8(IM))
01100 #define XORBim(IM, MD, MB, MI, MS) _O_r_X_B      (0x80              ,_b110          ,MD,MB,MI,MS  ,_su8(IM))
01101 
01102 #define XORWrr(RS, RD)                    _wO_Mrm              (0x31         ,_b11,_r2(RS),_r2(RD)                            )
01103 #define XORWmr(MD, MB, MI, MS, RD) _wO_r_X              (0x33              ,_r2(RD)        ,MD,MB,MI,MS         )
01104 #define XORWrm(RS, MD, MB, MI, MS) _wO_r_X              (0x31              ,_r2(RS)        ,MD,MB,MI,MS         )
01105 #define XORWir(IM, RD)                    _wOs_Mrm_sW   (0x81         ,_b11,_b110  ,_r2(RD)                     ,_su16(IM))
01106 #define XORWim(IM, MD, MB, MI, MS) _wOs_r_X_sW   (0x81              ,_b110          ,MD,MB,MI,MS  ,_su16(IM))
01107 
01108 #define XORLrr(RS, RD)                    _O_Mrm        (0x31         ,_b11,_r4(RS),_r4(RD)                            )
01109 #define XORLmr(MD, MB, MI, MS, RD) _O_r_X        (0x33              ,_r4(RD)        ,MD,MB,MI,MS         )
01110 #define XORLrm(RS, MD, MB, MI, MS) _O_r_X        (0x31              ,_r4(RS)        ,MD,MB,MI,MS         )
01111 #define XORLir(IM, RD)                    _Os_Mrm_sL    (0x81         ,_b11,_b110  ,_r4(RD)                     ,IM    )
01112 #define XORLim(IM, MD, MB, MI, MS) _Os_r_X_sL    (0x81              ,_b110          ,MD,MB,MI,MS  ,IM    )
01113 
01114 #define XORQrr(RS, RD)                    _qO_Mrm              (0x31         ,_b11,_r8(RS),_r8(RD)                            )
01115 #define XORQir(IM, RD)                    _qOs_Mrm_sL   (0x81         ,_b11,_b110  ,_r8(RD)                     ,IM    )
01116 
01117 /* x87 instructions -- yay, we found a use for octal constants :-) */
01118 
01119 #define ESCmi(D,B,I,S,OP)   _O_r_X(0xd8|(OP >> 3), (OP & 7), D,B,I,S)
01120 #define ESCri(RD,OP)        _O_Mrm(0xd8|(OP >> 3), _b11, (OP & 7), RD)
01121 
01122 #define ESCrri(RS,RD,OP)    ((RS) == _ST0 ? ESCri(RD,(OP|040))               \
01123                              : (RD) == _ST0 ? ESCri(RS,OP)                          \
01124                              : JITFAIL ("coprocessor instruction without st0"))
01125 
01126 #define FLDSm(D,B,I,S)             ESCmi(D,B,I,S,010)     /* fld m32real  */
01127 #define FILDLm(D,B,I,S)            ESCmi(D,B,I,S,030)     /* fild m32int  */
01128 #define FLDLm(D,B,I,S)             ESCmi(D,B,I,S,050)     /* fld m64real  */
01129 #define FILDWm(D,B,I,S)            ESCmi(D,B,I,S,070)     /* fild m16int  */
01130 #define FSTSm(D,B,I,S)             ESCmi(D,B,I,S,012)     /* fst m32real  */
01131 #define FISTLm(D,B,I,S)            ESCmi(D,B,I,S,032)     /* fist m32int  */
01132 #define FSTLm(D,B,I,S)             ESCmi(D,B,I,S,052)     /* fst m64real  */
01133 #define FISTWm(D,B,I,S)            ESCmi(D,B,I,S,072)     /* fist m16int  */
01134 #define FSTPSm(D,B,I,S)            ESCmi(D,B,I,S,013)     /* fstp m32real */
01135 #define FISTPLm(D,B,I,S)    ESCmi(D,B,I,S,033)     /* fistp m32int */
01136 #define FSTPLm(D,B,I,S)            ESCmi(D,B,I,S,053)     /* fstp m64real */
01137 #define FISTPWm(D,B,I,S)    ESCmi(D,B,I,S,073)     /* fistp m16int */
01138 #define FLDTm(D,B,I,S)             ESCmi(D,B,I,S,035)     /* fld m80real  */
01139 #define FILDQm(D,B,I,S)            ESCmi(D,B,I,S,075)     /* fild m64int  */
01140 #define FSTPTm(D,B,I,S)            ESCmi(D,B,I,S,037)     /* fstp m80real */
01141 #define FISTPQm(D,B,I,S)    ESCmi(D,B,I,S,077)     /* fistp m64int */
01142 
01143 #define FADDrr(RS,RD)              ESCrri(RS,RD,000)
01144 #define FMULrr(RS,RD)              ESCrri(RS,RD,001)
01145 #define FSUBrr(RS,RD)              ESCrri(RS,RD,004)
01146 #define FSUBRrr(RS,RD)             ESCrri(RS,RD,005)
01147 #define FDIVrr(RS,RD)              ESCrri(RS,RD,006)
01148 #define FDIVRrr(RS,RD)             ESCrri(RS,RD,007)
01149 
01150 #define FLDr(RD)            ESCri(RD,010)
01151 #define FXCHr(RD)           ESCri(RD,011)
01152 #define FFREEr(RD)          ESCri(RD,050)
01153 #define FSTr(RD)            ESCri(RD,052)
01154 #define FSTPr(RD)           ESCri(RD,053)
01155 #define FCOMr(RD)           ESCri(RD,002)
01156 #define FCOMPr(RD)          ESCri(RD,003)
01157 #define FCOMPPr(RD)         ESCri(RD,073)
01158 #define FCOMIr(RD)          ESCri(RD,036)
01159 #define FCOMIPr(RD)         ESCri(RD,076)
01160 #define FUCOMr(RD)          ESCri(RD,054)
01161 #define FUCOMPr(RD)         ESCri(RD,055)
01162 #define FUCOMPPr(RD)        ESCri(RD,025)
01163 #define FUCOMIr(RD)         ESCri(RD,035)
01164 #define FUCOMIPr(RD)        ESCri(RD,075)
01165 #define FADDPr(RD)          ESCri(RD,060)
01166 #define FMULPr(RD)          ESCri(RD,061)
01167 #define FSUBPr(RD)          ESCri(RD,064)
01168 #define FSUBRPr(RD)         ESCri(RD,065)
01169 #define FDIVPr(RD)          ESCri(RD,066)
01170 #define FDIVRPr(RD)         ESCri(RD,067)
01171 
01172 #define FNSTSWr(RD)         ((RD == _AX || RD == _EAX) ? _OO (0xdfe0)        \
01173                              : JITFAIL ("AX or EAX expected"))
01174 /* N byte NOPs */
01175 #define NOPi(N)             (((  (N)    >= 8) ? (_jit_B(0x8d),_jit_B(0xb4),_jit_B(0x26),_jit_I(0x00),_jit_B(0x90)) : (void) 0), \
01176                       (( ((N)&7) == 7) ? (_jit_B(0x8d),_jit_B(0xb4),_jit_B(0x26),_jit_I(0x00)) : \
01177                        ( ((N)&7) == 6) ? (_jit_B(0x8d),_jit_B(0xb6),_jit_I(0x00)) : \
01178                        ( ((N)&7) == 5) ? (_jit_B(0x90),_jit_B(0x8d),_jit_B(0x74),_jit_B(0x26),_jit_B(0x00)) : \
01179 /* leal 0(,%esi), %esi */ ( ((N)&7) == 4) ? (_jit_B(0x8d),_jit_B(0x74),_jit_B(0x26),_jit_B(0x00)) : \
01180 /* leal (,%esi), %esi */  ( ((N)&7) == 3) ? (_jit_B(0x8d),_jit_B(0x76),_jit_B(0x00)) : \
01181 /* movl %esi, %esi */         ( ((N)&7) == 2) ? (_jit_B(0x89),_jit_B(0xf6)) : \
01182                        ( ((N)&7) == 1) ? (_jit_B(0x90)) : \
01183                        ( ((N)&7) == 0) ? 0 : \
01184                        JITFAIL(".align argument too large")))
01185 
01186 
01187 /*** References:                                                                    */
01188 /*                                                                                  */
01189 /* [1] "Intel Architecture Software Developer's Manual Volume 1: Basic Architecture",             */
01190 /*     Intel Corporation 1997.                                                             */
01191 /*                                                                                  */
01192 /* [2] "Intel Architecture Software Developer's Manual Volume 2: Instruction Set Reference",      */
01193 /*     Intel Corporation 1997.                                                             */
01194 
01195 #endif
01196 #endif /* __lightning_asm_h */
01197