DOSBox-X
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
src/cpu/core_normal/support.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 LoadMbs(off) (Bit8s)(LoadMb(off))
00021 #define LoadMws(off) (Bit16s)(LoadMw(off))
00022 #define LoadMds(off) (Bit32s)(LoadMd(off))
00023 
00024 #define LoadRb(reg) reg
00025 #define LoadRw(reg) reg
00026 #define LoadRd(reg) reg
00027 
00028 #define SaveRb(reg,val) reg=((Bit8u)(val))
00029 #define SaveRw(reg,val) reg=((Bit16u)(val))
00030 #define SaveRd(reg,val) reg=((Bit32u)(val))
00031 
00032 static INLINE Bit8s Fetchbs() {
00033         return (Bit8s)Fetchb();
00034 }
00035 static INLINE Bit16s Fetchws() {
00036         return (Bit16s)Fetchw();
00037 }
00038 
00039 static INLINE Bit32s Fetchds() {
00040         return (Bit32s)Fetchd();
00041 }
00042 
00043 
00044 #define RUNEXCEPTION() {                                                                                \
00045         CPU_Exception(cpu.exception.which,cpu.exception.error);         \
00046         continue;                                                                                                       \
00047 }
00048 
00049 #define EXCEPTION(blah)                                                                         \
00050         {                                                                                                               \
00051                 CPU_Exception(blah);                                                            \
00052                 continue;                                                                                       \
00053         }
00054 
00055 /* NTS: At first glance, this looks like code that will only fetch the delta for conditional jumps
00056  *      if the condition is true. Further examination shows that DOSBox's core has two different
00057  *      CS:IP variables, reg_ip and core.cseip which Fetchb() modifies. */
00058 //TODO Could probably make all byte operands fast?
00059 #define JumpCond16_b(COND) {                                            \
00060         const Bit32u adj=(Bit32u)Fetchbs();                                             \
00061         SAVEIP;                                                         \
00062         if (COND) reg_ip+=adj;                                          \
00063         continue;                                                       \
00064 }
00065 
00066 #define JumpCond16_w(COND) {                                            \
00067         const Bit32u adj=(Bit32u)Fetchws();                                             \
00068         SAVEIP;                                                         \
00069         if (COND) reg_ip+=adj;                                          \
00070         continue;                                                       \
00071 }
00072 
00073 #define JumpCond32_b(COND) {                                            \
00074         const Bit32u adj=(Bit32u)Fetchbs();                                             \
00075         SAVEIP;                                                         \
00076         if (COND) reg_eip+=adj;                                         \
00077         continue;                                                       \
00078 }
00079 
00080 #define JumpCond32_d(COND) {                                            \
00081         const Bit32u adj=(Bit32u)Fetchds();                                             \
00082         SAVEIP;                                                         \
00083         if (COND) reg_eip+=adj;                                         \
00084         continue;                                                       \
00085 }
00086 
00087 #define MoveCond16(COND) {                                                      \
00088         GetRMrw;                                                                                \
00089         if (rm >= 0xc0 ) {GetEArw; if (COND) *rmrw=*earw;}\
00090         else {GetEAa; if (COND) *rmrw=LoadMw(eaa);}             \
00091 }
00092 
00093 #define MoveCond32(COND) {                                                      \
00094         GetRMrd;                                                                                \
00095         if (rm >= 0xc0 ) {GetEArd; if (COND) *rmrd=*eard;}\
00096         else {GetEAa; if (COND) *rmrd=LoadMd(eaa);}             \
00097 }
00098 
00099 #define SETcc(cc)                                                       \
00100         {                                                               \
00101                 GetRM;                                                  \
00102                 if (rm >= 0xc0 ) {GetEArb;*earb=(cc) ? 1 : 0;}          \
00103                 else {GetEAa;SaveMb(eaa,(cc) ? 1 : 0);}                 \
00104         }
00105 
00106 #include "helpers.h"
00107 #if CPU_CORE <= CPU_ARCHTYPE_8086
00108 # include "table_ea_8086.h"
00109 #else
00110 # include "table_ea.h"
00111 #endif
00112 #include "../modrm.h"
00113 
00114