DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/cpu/core_normal/helpers.h
00001 /*
00002  *  Copyright (C) 2002-2020  The DOSBox Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License along
00015  *  with this program; if not, write to the Free Software Foundation, Inc.,
00016  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  */
00018 
00019 
00020 #define GetEAa                                                                                          \
00021         PhysPt eaa=EALookupTable[rm]();                                 
00022 
00023 #define GetRMEAa                                                                                        \
00024         GetRM;                                                                                                  \
00025         GetEAa;                                                                                 
00026 
00027 
00028 #define RMEbGb(inst)                                                                                                            \
00029         {                                                                                                                                               \
00030                 GetRMrb;                                                                                                                        \
00031                 if (rm >= 0xc0 ) {GetEArb;inst(*earb,*rmrb,LoadRb,SaveRb);}                     \
00032                 else {GetEAa;inst(eaa,*rmrb,LoadMb,SaveMb);}                                            \
00033         }
00034 
00035 #define RMGbEb(inst)                                                                                                            \
00036         {                                                                                                                                               \
00037                 GetRMrb;                                                                                                                        \
00038                 if (rm >= 0xc0 ) {GetEArb;inst(*rmrb,*earb,LoadRb,SaveRb);}                     \
00039                 else {GetEAa;inst(*rmrb,LoadMb(eaa),LoadRb,SaveRb);}                            \
00040         }
00041 
00042 #define RMEb(inst)                                                                                                                      \
00043         {                                                                                                                                               \
00044                 if (rm >= 0xc0 ) {GetEArb;inst(*earb,LoadRb,SaveRb);}                           \
00045                 else {GetEAa;inst(eaa,LoadMb,SaveMb);}                                                          \
00046         }
00047 
00048 #define RMEwGw(inst)                                                                                                            \
00049         {                                                                                                                                               \
00050                 GetRMrw;                                                                                                                        \
00051                 if (rm >= 0xc0 ) {GetEArw;inst(*earw,*rmrw,LoadRw,SaveRw);}                     \
00052                 else {GetEAa;inst(eaa,*rmrw,LoadMw,SaveMw);}                                            \
00053         }
00054 
00055 #define RMEwGwOp3(inst,op3)                                                                                                     \
00056         {                                                                                                                                               \
00057                 GetRMrw;                                                                                                                        \
00058                 if (rm >= 0xc0 ) {GetEArw;inst(*earw,*rmrw,op3,LoadRw,SaveRw);}         \
00059                 else {GetEAa;inst(eaa,*rmrw,op3,LoadMw,SaveMw);}                                        \
00060         }
00061 
00062 #define RMGwEw(inst)                                                                                                            \
00063         {                                                                                                                                               \
00064                 GetRMrw;                                                                                                                        \
00065                 if (rm >= 0xc0 ) {GetEArw;inst(*rmrw,*earw,LoadRw,SaveRw);}                     \
00066                 else {GetEAa;inst(*rmrw,LoadMw(eaa),LoadRw,SaveRw);}                            \
00067         }                                                                                                                               
00068 
00069 #define RMGwEwOp3(inst,op3)                                                                                                     \
00070         {                                                                                                                                               \
00071                 GetRMrw;                                                                                                                        \
00072                 if (rm >= 0xc0 ) {GetEArw;inst(*rmrw,*earw,op3,LoadRw,SaveRw);}         \
00073                 else {GetEAa;inst(*rmrw,LoadMw(eaa),op3,LoadRw,SaveRw);}                        \
00074         }                                                                                                                               
00075 
00076 #define RMEw(inst)                                                                                                                      \
00077         {                                                                                                                                               \
00078                 if (rm >= 0xc0 ) {GetEArw;inst(*earw,LoadRw,SaveRw);}                           \
00079                 else {GetEAa;inst(eaa,LoadMw,SaveMw);}                                                          \
00080         }
00081 
00082 #define RMEdGd(inst)                                                                                                            \
00083         {                                                                                                                                               \
00084                 GetRMrd;                                                                                                                        \
00085                 if (rm >= 0xc0 ) {GetEArd;inst(*eard,*rmrd,LoadRd,SaveRd);}                     \
00086                 else {GetEAa;inst(eaa,*rmrd,LoadMd,SaveMd);}                                            \
00087         }
00088 
00089 #define RMEdGdOp3(inst,op3)                                                                                                     \
00090         {                                                                                                                                               \
00091                 GetRMrd;                                                                                                                        \
00092                 if (rm >= 0xc0 ) {GetEArd;inst(*eard,*rmrd,op3,LoadRd,SaveRd);}         \
00093                 else {GetEAa;inst(eaa,*rmrd,op3,LoadMd,SaveMd);}                                        \
00094         }
00095 
00096 
00097 #define RMGdEd(inst)                                                                                                            \
00098         {                                                                                                                                               \
00099                 GetRMrd;                                                                                                                        \
00100                 if (rm >= 0xc0 ) {GetEArd;inst(*rmrd,*eard,LoadRd,SaveRd);}                     \
00101                 else {GetEAa;inst(*rmrd,LoadMd(eaa),LoadRd,SaveRd);}                            \
00102         }                                                                                                                               
00103 
00104 #define RMGdEdOp3(inst,op3)                                                                                                     \
00105         {                                                                                                                                               \
00106                 GetRMrd;                                                                                                                        \
00107                 if (rm >= 0xc0 ) {GetEArd;inst(*rmrd,*eard,op3,LoadRd,SaveRd);}         \
00108                 else {GetEAa;inst(*rmrd,LoadMd(eaa),op3,LoadRd,SaveRd);}                        \
00109         }                                                                                                                               
00110 
00111 
00112 
00113 
00114 #define RMEw(inst)                                                                                                                      \
00115         {                                                                                                                                               \
00116                 if (rm >= 0xc0 ) {GetEArw;inst(*earw,LoadRw,SaveRw);}                           \
00117                 else {GetEAa;inst(eaa,LoadMw,SaveMw);}                                                          \
00118         }
00119 
00120 #define RMEd(inst)                                                                                                                      \
00121         {                                                                                                                                               \
00122                 if (rm >= 0xc0 ) {GetEArd;inst(*eard,LoadRd,SaveRd);}                           \
00123                 else {GetEAa;inst(eaa,LoadMd,SaveMd);}                                                          \
00124         }
00125 
00126 #define ALIb(inst)                                                                                                                      \
00127         { inst(reg_al,Fetchb(),LoadRb,SaveRb)}
00128 
00129 #define AXIw(inst)                                                                                                                      \
00130         { inst(reg_ax,Fetchw(),LoadRw,SaveRw);}
00131 
00132 #define EAXId(inst)                                                                                                                     \
00133         { inst(reg_eax,Fetchd(),LoadRd,SaveRd);}
00134 
00135 #define FPU_ESC(code) {                                                                                                         \
00136         Bit8u rm=Fetchb();                                                                                                              \
00137         if (rm >= 0xc0) {                                                                                                                       \
00138                 FPU_ESC ## code ## _Normal(rm);                                                                         \
00139         } else {                                                                                                                                \
00140                 GetEAa;FPU_ESC ## code ## _EA(rm,eaa);                                                          \
00141         }                                                                                                                                               \
00142 }
00143 
00144 #define CASE_W(_WHICH)                                                  \
00145         case (OPCODE_NONE+_WHICH):
00146 
00147 #if CPU_CORE >= CPU_ARCHTYPE_386
00148 # define CASE_D(_WHICH)                                                 \
00149         case (OPCODE_SIZE+_WHICH):
00150 #else
00151 # define CASE_D(_WHICH)
00152 #endif
00153 
00154 #define CASE_B(_WHICH)                                                  \
00155         CASE_W(_WHICH)                                                          \
00156         CASE_D(_WHICH)
00157 
00158 #define CASE_0F_W(_WHICH)                                               \
00159         case ((OPCODE_0F|OPCODE_NONE)+_WHICH):
00160 
00161 #if CPU_CORE >= CPU_ARCHTYPE_386
00162 # define CASE_0F_D(_WHICH)                                              \
00163         case ((OPCODE_0F|OPCODE_SIZE)+_WHICH):
00164 #else
00165 # define CASE_0F_D(_WHICH)
00166 #endif
00167 
00168 #define CASE_0F_B(_WHICH)                                               \
00169         CASE_0F_W(_WHICH)                                                       \
00170         CASE_0F_D(_WHICH)