From 6a1a1eff9c46de1474d112df7105a84e2c94b650 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Mon, 24 Feb 2020 19:57:20 +0000 Subject: [PATCH 1/3] missing line ends and a warning fix Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4331 --- src/dosbox.cpp | 3 ++- src/gui/sdlmain.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 8ae1e4df..7c0b1814 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -571,7 +571,8 @@ void DOSBOX_Init(void) { Pstring->Set_help("Device that will receive the MIDI data from MPU-401."); Pstring = secprop->Add_string("midiconfig",Property::Changeable::WhenIdle,""); - Pstring->Set_help("Special configuration options for the device driver. This is usually the id or part of the name of the device you want to use (find the id/name with mixer/listmidi).\n" + Pstring->Set_help("Special configuration options for the device driver. This is usually the id or part of the name of the device you want to use\n" + "(find the id/name with mixer/listmidi).\n" "Or in the case of coreaudio, you can specify a soundfont here.\n" "When using a Roland MT-32 rev. 0 as midi output device, some games may require a delay in order to prevent 'buffer overflow' issues.\n" "In that case, add 'delaysysex', for example: midiconfig=2 delaysysex\n" diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index 15f2f8cf..84cee0f3 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -903,7 +903,7 @@ dosurface: if (sdl.overlay && sdl.overlay->pitches[0] < 4 * width) { // We get a distorted image in this case. Cleanup and go to surface. - LOG_MSG("SDL: overlay pitch is too small. (%u < %u)", sdl.overlay->pitches[0], width * 4); + LOG_MSG("SDL: overlay pitch is too small. (%u < %" sBitfs(u) ")", sdl.overlay->pitches[0], width * 4); SDL_FreeYUVOverlay(sdl.overlay); sdl.overlay = 0; } @@ -2185,7 +2185,7 @@ void Config_Add_SDL() { Pstring = sdl_sec->Add_string("fullresolution",Property::Changeable::Always,"original"); Pstring->Set_help("What resolution to use for fullscreen: original, desktop or a fixed size (e.g. 1024x768).\n" "Using your monitor's native resolution with aspect=true might give the best results.\n" - "If you end up with small window on a large screen, try an output different from surface." + "If you end up with small window on a large screen, try an output different from surface.\n" "On Windows 10 with display scaling (Scale and layout) set to a value above 100%, it is recommended\n" "to use a lower full/windowresolution, in order to avoid window size problems."); From 5d654fc5c531023946099ebf49f866d8f187e89c Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Mon, 24 Feb 2020 20:00:55 +0000 Subject: [PATCH 2/3] Make value operator== const, add some limit checks in PrintConfigfile and related functions. Unify style a bit more. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4332 --- include/programs.h | 2 +- include/setup.h | 4 +- src/misc/setup.cpp | 178 +++++++++++++++++++++++---------------------- 3 files changed, 94 insertions(+), 90 deletions(-) diff --git a/include/programs.h b/include/programs.h index ac48bd89..d640fbca 100644 --- a/include/programs.h +++ b/include/programs.h @@ -44,7 +44,7 @@ public: const char * GetFileName(){ return file_name.c_str();} bool FindExist(char const * const name,bool remove=false); - bool FindHex(char const * const name,int & value,bool remove=false); + bool FindHex(char const * const name,unsigned int & value,bool remove=false); bool FindInt(char const * const name,int & value,bool remove=false); bool FindString(char const * const name,std::string & value,bool remove=false); bool FindCommand(unsigned int which,std::string & value); diff --git a/include/setup.h b/include/setup.h index 566c08c4..7c2fd925 100644 --- a/include/setup.h +++ b/include/setup.h @@ -96,7 +96,7 @@ public: Value& operator= (char const * const in) { return copy(Value(in));} Value& operator= (Value const& in) { return copy(Value(in));} - bool operator== (Value const & other); + bool operator== (Value const & other) const; operator bool () const; operator Hex () const; operator int () const; @@ -150,7 +150,7 @@ protected: } Value value; std::vector suggested_values; - typedef std::vector::iterator iter; + typedef std::vector::const_iterator const_iter; Value default_value; const Changeable::Value change; }; diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index 47946284..cd5e0f63 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -80,7 +80,7 @@ Value::operator char const* () const { return _string->c_str(); } -bool Value::operator==(Value const& other) { +bool Value::operator==(Value const& other) const { if(this == &other) return true; if(type != other.type) return false; switch(type){ @@ -221,8 +221,8 @@ string Value::ToString() const { } bool Property::CheckValue(Value const& in, bool warn){ - if(suggested_values.empty()) return true; - for(iter it = suggested_values.begin();it != suggested_values.end();it++) { + if (suggested_values.empty()) return true; + for(const_iter it = suggested_values.begin();it != suggested_values.end();++it) { if ( (*it) == in) { //Match! return true; } @@ -318,12 +318,12 @@ bool Prop_string::SetValue(std::string const& input) { } bool Prop_string::CheckValue(Value const& in, bool warn) { if (suggested_values.empty()) return true; - for(iter it = suggested_values.begin();it != suggested_values.end();it++) { + for(const_iter it = suggested_values.begin();it != suggested_values.end();++it) { if ( (*it) == in) { //Match! return true; } if ((*it).ToString() == "%u") { - Bit32u value; + unsigned int value; if(sscanf(in.ToString().c_str(),"%u",&value) == 1) { return true; } @@ -340,7 +340,7 @@ bool Prop_path::SetValue(std::string const& input) { bool retval = SetVal(val,false,true); if (input.empty()) { - realpath = ""; + realpath.clear(); return false; } std::string workcopy(input); @@ -371,7 +371,7 @@ void Prop_multival::make_default_value() { std::string result = p->Get_Default_Value().ToString(); while( (p = section->Get_prop(i++)) ) { std::string props = p->Get_Default_Value().ToString(); - if (props == "") continue; + if (props.empty()) continue; result += separator; result += props; } Value val(result,Value::V_STRING); @@ -406,7 +406,7 @@ bool Prop_multival_remain::SetValue(std::string const& input) { local.erase(0,loc+1); } else if (local.size()) { //last argument or last property in = local; - local = ""; + local.clear(); } //Test Value. If it fails set default Value valtest (in,p->Get_type()); @@ -444,7 +444,7 @@ bool Prop_multival::SetValue(std::string const& input) { local.erase(0,loc+1); } else if (local.size()) { //last argument in = local; - local = ""; + local.clear(); } if (p->Get_type() == Value::V_STRING) { @@ -560,8 +560,8 @@ int Section_prop::Get_int(string const&_propname) const { } bool Section_prop::Get_bool(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if ((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ return ((*tel)->GetValue()); } } @@ -569,8 +569,8 @@ bool Section_prop::Get_bool(string const& _propname) const { } double Section_prop::Get_double(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if ((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ return ((*tel)->GetValue()); } } @@ -578,8 +578,8 @@ double Section_prop::Get_double(string const& _propname) const { } Prop_path* Section_prop::Get_path(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if ((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ Prop_path* val = dynamic_cast((*tel)); if (val) return val; else return NULL; } @@ -588,8 +588,8 @@ Prop_path* Section_prop::Get_path(string const& _propname) const { } Prop_multival* Section_prop::Get_multival(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ Prop_multival* val = dynamic_cast((*tel)); if(val) return val; else return NULL; } @@ -598,8 +598,8 @@ Prop_multival* Section_prop::Get_multival(string const& _propname) const { } Prop_multival_remain* Section_prop::Get_multivalremain(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if ((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ Prop_multival_remain* val = dynamic_cast((*tel)); if (val) return val; else return NULL; } @@ -607,23 +607,23 @@ Prop_multival_remain* Section_prop::Get_multivalremain(string const& _propname) return NULL; } Property* Section_prop::Get_prop(int index){ - for(it tel=properties.begin();tel!=properties.end();tel++){ + for(it tel = properties.begin();tel != properties.end();++tel){ if (!index--) return (*tel); } return NULL; } const char* Section_prop::Get_string(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ return ((*tel)->GetValue()); } } return ""; } Hex Section_prop::Get_hex(string const& _propname) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ - if((*tel)->propname==_propname){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ + if ((*tel)->propname == _propname){ return ((*tel)->GetValue()); } } @@ -646,8 +646,8 @@ bool Section_prop::HandleInputline(string const& gegevens){ ) val = val.substr(1,length - 2); /* trim the results incase there were spaces somewhere */ trim(name);trim(val); - for(it tel = properties.begin();tel != properties.end();tel++){ - if(!strcasecmp((*tel)->propname.c_str(),name.c_str())){ + for(it tel = properties.begin();tel != properties.end();++tel){ + if (!strcasecmp((*tel)->propname.c_str(),name.c_str())){ return (*tel)->SetValue(val); } } @@ -658,18 +658,20 @@ void Section_prop::PrintData(FILE* outfile) const { /* Now print out the individual section entries */ size_t len = 0; // Determine maximum length of the props in this section - for(const_it tel = properties.begin();tel != properties.end();tel++) { + for(const_it tel = properties.begin();tel != properties.end();++tel) { if ((*tel)->propname.length() > len) len = (*tel)->propname.length(); } - - for(const_it tel = properties.begin();tel != properties.end();tel++) { - fprintf(outfile,"%-*s = %s\n", len, (*tel)->propname.c_str(), (*tel)->GetValue().ToString().c_str()); + // fprintf wants int instead of size_t, also refuse to print sections with weirdly long properties. + int intlen = (len > 100)?100:static_cast(len); + if (intlen == 100) return; + for(const_it tel = properties.begin();tel != properties.end();++tel) { + fprintf(outfile,"%-*s = %s\n", intlen, (*tel)->propname.c_str(), (*tel)->GetValue().ToString().c_str()); } } string Section_prop::GetPropValue(string const& _property) const { - for(const_it tel=properties.begin();tel!=properties.end();tel++){ + for(const_it tel = properties.begin();tel != properties.end();++tel){ if (!strcasecmp((*tel)->propname.c_str(),_property.c_str())){ return (*tel)->GetValue().ToString(); } @@ -693,15 +695,15 @@ string Section_line::GetPropValue(string const& /* _property*/) const { bool Config::PrintConfig(char const * const configfilename) const { char temp[50];char helpline[256]; - FILE* outfile=fopen(configfilename,"w+t"); - if(outfile==NULL) return false; + FILE* outfile = fopen(configfilename,"w+t"); + if (outfile == NULL) return false; /* Print start of configfile and add a return to improve readibility. */ fprintf(outfile,MSG_Get("CONFIGFILE_INTRO"),VERSION); fprintf(outfile,"\n"); - for (const_it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){ + for (const_it tel = sectionlist.begin(); tel != sectionlist.end(); ++tel){ /* Print out the Section header */ - strcpy(temp,(*tel)->GetName()); + safe_strncpy(temp,(*tel)->GetName(),sizeof(temp)); lowcase(temp); fprintf(outfile,"[%s]\n",temp); @@ -715,20 +717,21 @@ bool Config::PrintConfig(char const * const configfilename) const { } i=0; char prefix[80]; - snprintf(prefix,80, "\n# %*s ", (int)maxwidth, ""); + int intmaxwidth = (maxwidth>60)?60:static_cast(maxwidth); + snprintf(prefix,80, "\n# %*s ", intmaxwidth, ""); while ((p = sec->Get_prop(i++))) { std::string help = p->Get_help(); std::string::size_type pos = std::string::npos; - while ((pos = help.find("\n", pos+1)) != std::string::npos) { + while ((pos = help.find('\n', pos+1)) != std::string::npos) { help.replace(pos, 1, prefix); } - fprintf(outfile, "# %*s: %s", (int)maxwidth, p->propname.c_str(), help.c_str()); + fprintf(outfile, "# %*s: %s", intmaxwidth, p->propname.c_str(), help.c_str()); std::vector values = p->GetValues(); if (!values.empty()) { fprintf(outfile, "%s%s:", prefix, MSG_Get("CONFIG_SUGGESTED_VALUES")); - std::vector::iterator it = values.begin(); + std::vector::const_iterator it = values.begin(); while (it != values.end()) { if((*it).ToString() != "%u") { //Hack hack hack. else we need to modify GetValues, but that one is const... if (it != values.begin()) fputs(",", outfile); @@ -743,16 +746,17 @@ bool Config::PrintConfig(char const * const configfilename) const { } else { upcase(temp); strcat(temp,"_CONFIGFILE_HELP"); - const char * helpstr=MSG_Get(temp); - char * helpwrite=helpline; - while (*helpstr) { - *helpwrite++=*helpstr; + const char * helpstr = MSG_Get(temp); + const char * linestart = helpstr; + char * helpwrite = helpline; + while (*helpstr && helpstr - linestart < sizeof(helpline)) { + *helpwrite++ = *helpstr; if (*helpstr == '\n') { - *helpwrite=0; + *helpwrite = 0; fprintf(outfile,"# %s",helpline); - helpwrite=helpline; - } - helpstr++; + helpwrite = helpline; + linestart = ++helpstr; + } else helpstr++; } } @@ -776,7 +780,7 @@ Section_prop::~Section_prop() { //ExecuteDestroy should be here else the destroy functions use destroyed properties ExecuteDestroy(true); /* Delete properties themself (properties stores the pointer of a prop */ - for(it prop = properties.begin(); prop != properties.end(); prop++) + for(it prop = properties.begin(); prop != properties.end(); ++prop) delete (*prop); } @@ -790,7 +794,7 @@ Section_line* Config::AddSection_line(char const * const _name,void (*_initfunct void Config::Init() { - for (const_it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++) { + for (const_it tel=sectionlist.begin(); tel!=sectionlist.end(); ++tel) { (*tel)->ExecuteInit(); } } @@ -806,45 +810,45 @@ void Section::AddDestroyFunction(SectionFunction func,bool canchange) { void Section::ExecuteInit(bool initall) { typedef std::list::iterator func_it; - for (func_it tel=initfunctions.begin(); tel!=initfunctions.end(); tel++) { - if(initall || (*tel).canchange) (*tel).function(this); + for (func_it tel = initfunctions.begin(); tel != initfunctions.end(); ++tel) { + if (initall || (*tel).canchange) (*tel).function(this); } } void Section::ExecuteDestroy(bool destroyall) { typedef std::list::iterator func_it; - for (func_it tel=destroyfunctions.begin(); tel!=destroyfunctions.end(); ) { - if(destroyall || (*tel).canchange) { + for (func_it tel = destroyfunctions.begin(); tel != destroyfunctions.end(); ) { + if (destroyall || (*tel).canchange) { (*tel).function(this); - tel=destroyfunctions.erase(tel); //Remove destroyfunction once used - } else tel++; + tel = destroyfunctions.erase(tel); //Remove destroyfunction once used + } else ++tel; } } Config::~Config() { - reverse_it cnt=sectionlist.rbegin(); - while (cnt!=sectionlist.rend()) { + reverse_it cnt = sectionlist.rbegin(); + while (cnt != sectionlist.rend()) { delete (*cnt); cnt++; } } Section* Config::GetSection(int index) { - for (it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){ + for (it tel = sectionlist.begin(); tel != sectionlist.end(); ++tel){ if (!index--) return (*tel); } return NULL; } Section* Config::GetSection(string const& _sectionname) const { - for (const_it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){ + for (const_it tel = sectionlist.begin(); tel != sectionlist.end(); ++tel){ if (!strcasecmp((*tel)->GetName(),_sectionname.c_str())) return (*tel); } return NULL; } Section* Config::GetSectionFromProperty(char const * const prop) const { - for (const_it tel=sectionlist.begin(); tel!=sectionlist.end(); tel++){ + for (const_it tel = sectionlist.begin(); tel != sectionlist.end(); ++tel){ if ((*tel)->GetPropValue(prop) != NO_SUCH_PROPERTY) return (*tel); } return NULL; @@ -948,10 +952,10 @@ bool CommandLine::FindExist(char const * const name,bool remove) { return true; } -bool CommandLine::FindHex(char const * const name,int & value,bool remove) { +bool CommandLine::FindHex(char const * const name,unsigned int & value,bool remove) { cmd_it it,it_next; if (!(FindEntry(name,it,true))) return false; - it_next=it;it_next++; + it_next=it;++it_next; sscanf((*it_next).c_str(),"%X",&value); if (remove) cmds.erase(it,++it_next); return true; @@ -960,7 +964,7 @@ bool CommandLine::FindHex(char const * const name,int & value,bool remove) { bool CommandLine::FindInt(char const * const name,int & value,bool remove) { cmd_it it,it_next; if (!(FindEntry(name,it,true))) return false; - it_next=it;it_next++; + it_next=it;++it_next; value=atoi((*it_next).c_str()); if (remove) cmds.erase(it,++it_next); return true; @@ -969,7 +973,7 @@ bool CommandLine::FindInt(char const * const name,int & value,bool remove) { bool CommandLine::FindString(char const * const name,std::string & value,bool remove) { cmd_it it,it_next; if (!(FindEntry(name,it,true))) return false; - it_next=it;it_next++; + it_next=it;++it_next; value=*it_next; if (remove) cmds.erase(it,++it_next); return true; @@ -985,9 +989,9 @@ bool CommandLine::FindCommand(unsigned int which,std::string & value) { } bool CommandLine::FindEntry(char const * const name,cmd_it & it,bool neednext) { - for (it=cmds.begin();it!=cmds.end();it++) { + for (it = cmds.begin(); it != cmds.end(); ++it) { if (!strcasecmp((*it).c_str(),name)) { - cmd_it itnext=it;itnext++; + cmd_it itnext=it;++itnext; if (neednext && (itnext==cmds.end())) return false; return true; } @@ -997,7 +1001,7 @@ bool CommandLine::FindEntry(char const * const name,cmd_it & it,bool neednext) { bool CommandLine::FindStringBegin(char const* const begin,std::string & value, bool remove) { size_t len = strlen(begin); - for (cmd_it it=cmds.begin();it!=cmds.end();it++) { + for (cmd_it it = cmds.begin(); it != cmds.end();++it) { if (strncmp(begin,(*it).c_str(),len)==0) { value=((*it).c_str() + len); if (remove) cmds.erase(it); @@ -1008,12 +1012,12 @@ bool CommandLine::FindStringBegin(char const* const begin,std::string & value, b } bool CommandLine::FindStringRemain(char const * const name,std::string & value) { - cmd_it it;value=""; + cmd_it it;value.clear(); if (!FindEntry(name,it)) return false; - it++; - for (;it!=cmds.end();it++) { - value+=" "; - value+=(*it); + ++it; + for (;it != cmds.end();++it) { + value += " "; + value += (*it); } return true; } @@ -1023,27 +1027,27 @@ bool CommandLine::FindStringRemain(char const * const name,std::string & value) * Restoring quotes back into the commands so command /C mount d "/tmp/a b" works as intended */ bool CommandLine::FindStringRemainBegin(char const * const name,std::string & value) { - cmd_it it;value=""; + cmd_it it;value.clear(); if (!FindEntry(name,it)) { size_t len = strlen(name); - for (it=cmds.begin();it!=cmds.end();it++) { + for (it = cmds.begin();it != cmds.end();++it) { if (strncasecmp(name,(*it).c_str(),len)==0) { std::string temp = ((*it).c_str() + len); //Restore quotes for correct parsing in later stages - if(temp.find(" ") != std::string::npos) + if(temp.find(' ') != std::string::npos) value = std::string("\"") + temp + std::string("\""); else value = temp; break; } } - if( it == cmds.end()) return false; + if (it == cmds.end()) return false; } - it++; - for (;it!=cmds.end();it++) { + ++it; + for (;it != cmds.end();++it) { value += " "; std::string temp = (*it); - if(temp.find(" ") != std::string::npos) + if(temp.find(' ') != std::string::npos) value += std::string("\"") + temp + std::string("\""); else value += temp; @@ -1054,10 +1058,10 @@ bool CommandLine::FindStringRemainBegin(char const * const name,std::string & va bool CommandLine::GetStringRemain(std::string & value) { if (!cmds.size()) return false; - cmd_it it=cmds.begin();value=(*it++); - for(;it != cmds.end();it++) { - value+=" "; - value+=(*it); + cmd_it it = cmds.begin();value = (*it++); + for(;it != cmds.end();++it) { + value += " "; + value += (*it); } return true; } @@ -1068,7 +1072,7 @@ unsigned int CommandLine::GetCount(void) { } void CommandLine::FillVector(std::vector & vector) { - for(cmd_it it=cmds.begin(); it != cmds.end(); it++) { + for(cmd_it it = cmds.begin(); it != cmds.end(); ++it) { vector.push_back((*it)); } // add back the \" if the parameter contained a space @@ -1088,7 +1092,7 @@ int CommandLine::GetParameterFromList(const char* const params[], std::vector Date: Mon, 24 Feb 2020 20:02:58 +0000 Subject: [PATCH 3/3] Optimize xchg a bit. (jmarsh) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4333 --- src/cpu/core_dyn_x86/risc_x64.h | 5 +++-- src/cpu/core_dyn_x86/risc_x86.h | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/cpu/core_dyn_x86/risc_x64.h b/src/cpu/core_dyn_x86/risc_x64.h index 384cdb4d..0e18b18a 100644 --- a/src/cpu/core_dyn_x86/risc_x64.h +++ b/src/cpu/core_dyn_x86/risc_x64.h @@ -608,7 +608,8 @@ static void gen_dop_byte(DualOps op,DynReg * dr1,Bitu di1,DynReg * dr2,Bitu di2) case DOP_OR: tmp=0x0a; if ((dr1==dr2) && (di1==di2)) goto nochange; break; case DOP_TEST: tmp=0x84; goto nochange; case DOP_MOV: if ((dr1==dr2) && (di1==di2)) return; tmp=0x8a; break; - case DOP_XCHG: tmp=0x86; dr2->flags|=DYNFLG_CHANGED; break; + case DOP_XCHG: if ((dr1==dr2) && (di1==di2)) return; + tmp=0x86; dr2->flags|=DYNFLG_CHANGED; break; default: IllegalOption("gen_dop_byte"); } @@ -786,7 +787,7 @@ static void gen_dop_word(DualOps op,bool dword,DynReg * dr1,DynReg * dr2) { case DOP_OR: tmp=0x0b; if (dr1==dr2) goto nochange; break; case DOP_TEST: tmp=0x85; goto nochange; case DOP_MOV: if (dr1==dr2) return; tmp=0x8b; break; - case DOP_XCHG: + case DOP_XCHG: if (dr1==dr2) return; dr2->flags|=DYNFLG_CHANGED; if (dword && !((dr1->flags&DYNFLG_HAS8) ^ (dr2->flags&DYNFLG_HAS8))) { dr1->genreg=gr2;gr2->dynreg=dr1; diff --git a/src/cpu/core_dyn_x86/risc_x86.h b/src/cpu/core_dyn_x86/risc_x86.h index 6b1cc9ec..762fee11 100644 --- a/src/cpu/core_dyn_x86/risc_x86.h +++ b/src/cpu/core_dyn_x86/risc_x86.h @@ -340,7 +340,8 @@ static void gen_dop_byte(DualOps op,DynReg * dr1,Bit8u di1,DynReg * dr2,Bit8u di case DOP_OR: tmp=0x0a; if ((dr1==dr2) && (di1==di2)) goto nochange; break; case DOP_TEST: tmp=0x84; goto nochange; case DOP_MOV: if ((dr1==dr2) && (di1==di2)) return; tmp=0x8a; break; - case DOP_XCHG: tmp=0x86; dr2->flags|=DYNFLG_CHANGED; break; + case DOP_XCHG: if ((dr1==dr2) && (di1==di2)) return; + tmp=0x86; dr2->flags|=DYNFLG_CHANGED; break; default: IllegalOption("gen_dop_byte"); } @@ -507,7 +508,7 @@ static void gen_dop_word(DualOps op,bool dword,DynReg * dr1,DynReg * dr2) { case DOP_OR: tmp=0x0b; if (dr1==dr2) goto nochange; break; case DOP_TEST: tmp=0x85; goto nochange; case DOP_MOV: if (dr1==dr2) return; tmp=0x8b; break; - case DOP_XCHG: + case DOP_XCHG: if (dr1==dr2) return; dr2->flags|=DYNFLG_CHANGED; if (dword && !((dr1->flags&DYNFLG_HAS8) ^ (dr2->flags&DYNFLG_HAS8))) { dr1->genreg=gr2;dr1->genreg->dynreg=dr1;