From 0fa82afe1fe66f1f7ab337438998f6bb0856028e Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Tue, 13 Nov 2007 17:30:54 +0000 Subject: [PATCH] Bugfix and optimize BxResolve calls - bugfix in 64-bit mode --- bochs/cpu/cpu.cc | 16 +- bochs/cpu/cpu.h | 158 ++++----------- bochs/cpu/fetchdecode.cc | 136 +++++++------ bochs/cpu/fetchdecode64.cc | 254 +++++++++++------------- bochs/cpu/resolve16.cc | 36 ++-- bochs/cpu/resolve32.cc | 251 ++--------------------- bochs/cpu/resolve64.cc | 395 +++---------------------------------- 7 files changed, 302 insertions(+), 944 deletions(-) diff --git a/bochs/cpu/cpu.cc b/bochs/cpu/cpu.cc index 569a9d943..57f044e26 100644 --- a/bochs/cpu/cpu.cc +++ b/bochs/cpu/cpu.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.cc,v 1.180 2007-11-12 18:20:05 sshwarts Exp $ +// $Id: cpu.cc,v 1.181 2007-11-13 17:30:52 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -363,6 +363,8 @@ void BX_CPU_C::repeat_ZFL(bxInstruction_c *i, BxExecutePtr_t execute) return; } + unsigned rep = i->repUsedValue(); + #if BX_SUPPORT_X86_64 if (i->as64L()) { while(1) { @@ -371,8 +373,8 @@ void BX_CPU_C::repeat_ZFL(bxInstruction_c *i, BxExecutePtr_t execute) BX_INSTR_REPEAT_ITERATION(BX_CPU_ID, i); RCX --; } - if ((i->repUsedValue()==3) && (get_ZF()==0)) return; - if ((i->repUsedValue()==2) && (get_ZF()!=0)) return; + if (rep==3 && get_ZF()==0) return; + if (rep==2 && get_ZF()!=0) return; if (RCX == 0) return; BX_TICK1_IF_SINGLE_PROCESSOR(); @@ -392,8 +394,8 @@ void BX_CPU_C::repeat_ZFL(bxInstruction_c *i, BxExecutePtr_t execute) BX_INSTR_REPEAT_ITERATION(BX_CPU_ID, i); RCX = ECX - 1; } - if ((i->repUsedValue()==3) && (get_ZF()==0)) return; - if ((i->repUsedValue()==2) && (get_ZF()!=0)) return; + if (rep==3 && get_ZF()==0) return; + if (rep==2 && get_ZF()!=0) return; if (ECX == 0) return; BX_TICK1_IF_SINGLE_PROCESSOR(); @@ -412,8 +414,8 @@ void BX_CPU_C::repeat_ZFL(bxInstruction_c *i, BxExecutePtr_t execute) BX_INSTR_REPEAT_ITERATION(BX_CPU_ID, i); CX --; } - if ((i->repUsedValue()==3) && (get_ZF()==0)) return; - if ((i->repUsedValue()==2) && (get_ZF()!=0)) return; + if (rep==3 && get_ZF()==0) return; + if (rep==2 && get_ZF()!=0) return; if (CX == 0) return; BX_TICK1_IF_SINGLE_PROCESSOR(); diff --git a/bochs/cpu/cpu.h b/bochs/cpu/cpu.h index d8a4c9136..c08169217 100644 --- a/bochs/cpu/cpu.h +++ b/bochs/cpu/cpu.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: cpu.h,v 1.354 2007-11-12 18:20:07 sshwarts Exp $ +// $Id: cpu.h,v 1.355 2007-11-13 17:30:52 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -644,12 +644,12 @@ public: Bit8u modRMData4; // 23..20 (unused) - // 19..16 index (sib) + // 19..16 base (sib) Bit8u modRMData3; // 15..14 mod (modrm) // 13..12 scale (sib) - // 11...8 base (sib) + // 11...8 index (sib) Bit8u modRMData2; // 7...4 (unused) @@ -740,10 +740,10 @@ public: return (modRMForm.modRMData2 >> 4) & 0x3; } BX_CPP_INLINE unsigned sibIndex() { - return modRMForm.modRMData3; + return (modRMForm.modRMData2) & 0xf; } BX_CPP_INLINE unsigned sibBase() { - return (modRMForm.modRMData2) & 0xf; + return modRMForm.modRMData3; } BX_CPP_INLINE Bit32u displ32u() { return modRMForm.displ32u; } BX_CPP_INLINE Bit16u displ16u() { return modRMForm.displ16u; } @@ -801,9 +801,6 @@ public: BX_CPP_INLINE unsigned os64L(void) { return metaInfo1 & (1<<5); } - BX_CPP_INLINE void setOs64B(unsigned bit) { - metaInfo1 = (metaInfo1 & ~(1<<5)) | (bit<<5); - } BX_CPP_INLINE void assertOs64(void) { metaInfo1 |= (1<<5); } @@ -2737,124 +2734,49 @@ public: // for now... BX_SMF void UndefinedOpcode(bxInstruction_c *); BX_SMF void BxError(bxInstruction_c *i); - BX_SMF void ResolveDummy(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolveDummy(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod0Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod0Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve16Mod1or2Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve16Mod1or2Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod0Rm(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod0Base(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod0Disp(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod0BaseIndex(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod0DispIndex(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - - BX_SMF void Resolve32Mod0Base0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod0Base7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - - BX_SMF void Resolve32Mod1or2Base0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve32Mod1or2Base7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod1or2Rm(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod1or2Base(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod1or2BaseIndex(bxInstruction_c *) BX_CPP_AttrRegparmN(1); #if BX_SUPPORT_X86_64 - // 64 bit addressing - BX_SMF void Resolve64Mod0Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rip(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm8(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm9(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm10(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm11(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm14(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Rm15(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve32Mod0Rip(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod0Rip(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm8(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm9(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm10(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm11(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm13(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm14(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Rm15(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod0Rm(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod0Base(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod0Disp(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod0BaseIndex(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod0DispIndex(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base8(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base9(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base10(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base11(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base12(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base13(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base14(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod0Base15(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - - BX_SMF void Resolve64Mod1or2Base0(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base1(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base2(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base3(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base4(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base5(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base6(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base7(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base8(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base9(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base10(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base11(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base12(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base13(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base14(bxInstruction_c *) BX_CPP_AttrRegparmN(1); - BX_SMF void Resolve64Mod1or2Base15(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod1or2Rm(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod1or2Base(bxInstruction_c *) BX_CPP_AttrRegparmN(1); + BX_SMF void BxResolve64Mod1or2BaseIndex(bxInstruction_c *) BX_CPP_AttrRegparmN(1); #endif // #if BX_SUPPORT_X86_64 // diff --git a/bochs/cpu/fetchdecode.cc b/bochs/cpu/fetchdecode.cc index efb88e351..f7185cfc6 100644 --- a/bochs/cpu/fetchdecode.cc +++ b/bochs/cpu/fetchdecode.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: fetchdecode.cc,v 1.117 2007-11-12 18:20:10 sshwarts Exp $ +// $Id: fetchdecode.cc,v 1.118 2007-11-13 17:30:52 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -61,70 +61,59 @@ * presence or absence of the LOCK prefix. */ -static BxExecutePtr_tR BxResolve16Mod0[8] = { - &BX_CPU_C::Resolve16Mod0Rm0, - &BX_CPU_C::Resolve16Mod0Rm1, - &BX_CPU_C::Resolve16Mod0Rm2, - &BX_CPU_C::Resolve16Mod0Rm3, - &BX_CPU_C::Resolve16Mod0Rm4, - &BX_CPU_C::Resolve16Mod0Rm5, - &BX_CPU_C::Resolve16Mod0Rm6, - &BX_CPU_C::Resolve16Mod0Rm7 +static BxExecutePtr_tR Resolve16Mod0[8] = { + &BX_CPU_C::BxResolve16Mod0Rm0, + &BX_CPU_C::BxResolve16Mod0Rm1, + &BX_CPU_C::BxResolve16Mod0Rm2, + &BX_CPU_C::BxResolve16Mod0Rm3, + &BX_CPU_C::BxResolve16Mod0Rm4, + &BX_CPU_C::BxResolve16Mod0Rm5, + &BX_CPU_C::BxResolve16Mod0Rm6, + &BX_CPU_C::BxResolve16Mod0Rm7 }; -static BxExecutePtr_tR BxResolve16Mod1or2[8] = { - &BX_CPU_C::Resolve16Mod1or2Rm0, - &BX_CPU_C::Resolve16Mod1or2Rm1, - &BX_CPU_C::Resolve16Mod1or2Rm2, - &BX_CPU_C::Resolve16Mod1or2Rm3, - &BX_CPU_C::Resolve16Mod1or2Rm4, - &BX_CPU_C::Resolve16Mod1or2Rm5, - &BX_CPU_C::Resolve16Mod1or2Rm6, - &BX_CPU_C::Resolve16Mod1or2Rm7 +static BxExecutePtr_tR Resolve16Mod1or2[8] = { + &BX_CPU_C::BxResolve16Mod1or2Rm0, + &BX_CPU_C::BxResolve16Mod1or2Rm1, + &BX_CPU_C::BxResolve16Mod1or2Rm2, + &BX_CPU_C::BxResolve16Mod1or2Rm3, + &BX_CPU_C::BxResolve16Mod1or2Rm4, + &BX_CPU_C::BxResolve16Mod1or2Rm5, + &BX_CPU_C::BxResolve16Mod1or2Rm6, + &BX_CPU_C::BxResolve16Mod1or2Rm7 }; -static BxExecutePtr_tR BxResolve32Mod0[8] = { - &BX_CPU_C::Resolve32Mod0Rm0, - &BX_CPU_C::Resolve32Mod0Rm1, - &BX_CPU_C::Resolve32Mod0Rm2, - &BX_CPU_C::Resolve32Mod0Rm3, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve32Mod0Rm5, - &BX_CPU_C::Resolve32Mod0Rm6, - &BX_CPU_C::Resolve32Mod0Rm7 +static BxExecutePtr_tR Resolve32Mod0[8] = { + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm, + NULL, // escape to SIB-byte + &BX_CPU_C::BxResolve32Mod0Disp, + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm }; -static BxExecutePtr_tR BxResolve32Mod1or2[8] = { - &BX_CPU_C::Resolve32Mod1or2Rm0, - &BX_CPU_C::Resolve32Mod1or2Rm1, - &BX_CPU_C::Resolve32Mod1or2Rm2, - &BX_CPU_C::Resolve32Mod1or2Rm3, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve32Mod1or2Rm5, - &BX_CPU_C::Resolve32Mod1or2Rm6, - &BX_CPU_C::Resolve32Mod1or2Rm7 +static BxExecutePtr_tR Resolve32Mod0Base[8] = { + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Disp, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, }; -static BxExecutePtr_tR BxResolve32Mod0Base[8] = { - &BX_CPU_C::Resolve32Mod0Base0, - &BX_CPU_C::Resolve32Mod0Base1, - &BX_CPU_C::Resolve32Mod0Base2, - &BX_CPU_C::Resolve32Mod0Base3, - &BX_CPU_C::Resolve32Mod0Base4, - &BX_CPU_C::Resolve32Mod0Base5, - &BX_CPU_C::Resolve32Mod0Base6, - &BX_CPU_C::Resolve32Mod0Base7, -}; - -static BxExecutePtr_tR BxResolve32Mod1or2Base[8] = { - &BX_CPU_C::Resolve32Mod1or2Base0, - &BX_CPU_C::Resolve32Mod1or2Base1, - &BX_CPU_C::Resolve32Mod1or2Base2, - &BX_CPU_C::Resolve32Mod1or2Base3, - &BX_CPU_C::Resolve32Mod1or2Base4, - &BX_CPU_C::Resolve32Mod1or2Base5, - &BX_CPU_C::Resolve32Mod1or2Base6, - &BX_CPU_C::Resolve32Mod1or2Base7, +static BxExecutePtr_tR Resolve32Mod0BaseIndex[8] = { + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0DispIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, }; @@ -1549,7 +1538,7 @@ BX_CPU_C::fetchDecode32(Bit8u *iptr, bxInstruction_c *instruction, unsigned rema os_32 = is_32 = BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].cache.u.segment.d_b; - instruction->ResolveModrm = ResolveDummy; + instruction->ResolveModrm = BxResolveDummy; instruction->initMetaInfo(/*os32*/ is_32, /*as32*/ is_32, /*os64*/ 0, /*as64*/ 0); @@ -1696,7 +1685,7 @@ fetch_b1: // 32-bit addressing modes; note that mod==11b handled above if (rm != 4) { // no s-i-b byte if (mod == 0x00) { // mod == 00b - instruction->ResolveModrm = BxResolve32Mod0[rm]; + instruction->ResolveModrm = Resolve32Mod0[rm]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_SEG_REG_DS); if (rm == 5) { @@ -1712,7 +1701,7 @@ fetch_b1: goto modrm_done; } if (mod == 0x40) { // mod == 01b - instruction->ResolveModrm = BxResolve32Mod1or2[rm]; + instruction->ResolveModrm = BxResolve32Mod1or2Rm; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm32[rm]); get_8bit_displ: @@ -1725,7 +1714,7 @@ get_8bit_displ: else return(0); } // (mod == 0x80) mod == 10b - instruction->ResolveModrm = BxResolve32Mod1or2[rm]; + instruction->ResolveModrm = BxResolve32Mod1or2Rm; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm32[rm]); get_32bit_displ: @@ -1749,11 +1738,14 @@ get_32bit_displ: base = sib & 0x07; sib >>= 3; index = sib & 0x07; sib >>= 3; scale = sib; - instruction->modRMForm.modRMData2 |= (base); - instruction->modRMForm.modRMData3 |= (index); + instruction->modRMForm.modRMData3 |= (base); + instruction->modRMForm.modRMData2 |= (index); instruction->modRMForm.modRMData2 |= (scale<<4); if (mod == 0x00) { // mod==00b, rm==4 - instruction->ResolveModrm = BxResolve32Mod0Base[base]; + if (index == 4) + instruction->ResolveModrm = Resolve32Mod0Base[base]; + else + instruction->ResolveModrm = Resolve32Mod0BaseIndex[base]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod0_base32[base]); if (base == 0x05) @@ -1762,13 +1754,19 @@ get_32bit_displ: goto modrm_done; } if (mod == 0x40) { // mod==01b, rm==4 - instruction->ResolveModrm = BxResolve32Mod1or2Base[base]; + if (index == 4) + instruction->ResolveModrm = BxResolve32Mod1or2Base; + else + instruction->ResolveModrm = BxResolve32Mod1or2BaseIndex; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod1or2_base32[base]); goto get_8bit_displ; } // (mod == 0x80), mod==10b, rm==4 - instruction->ResolveModrm = BxResolve32Mod1or2Base[base]; + if (index == 4) + instruction->ResolveModrm = BxResolve32Mod1or2Base; + else + instruction->ResolveModrm = BxResolve32Mod1or2BaseIndex; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod1or2_base32[base]); goto get_32bit_displ; @@ -1777,7 +1775,7 @@ get_32bit_displ: else { // 16-bit addressing modes, mod==11b handled above if (mod == 0x40) { // mod == 01b - instruction->ResolveModrm = BxResolve16Mod1or2[rm]; + instruction->ResolveModrm = Resolve16Mod1or2[rm]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm16[rm]); if (ilen < remain) { @@ -1789,7 +1787,7 @@ get_32bit_displ: else return(0); } if (mod == 0x80) { // mod == 10b - instruction->ResolveModrm = BxResolve16Mod1or2[rm]; + instruction->ResolveModrm = Resolve16Mod1or2[rm]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm16[rm]); if ((ilen+1) < remain) { @@ -1801,7 +1799,7 @@ get_32bit_displ: else return(0); } // mod must be 00b at this point - instruction->ResolveModrm = BxResolve16Mod0[rm]; + instruction->ResolveModrm = Resolve16Mod0[rm]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod00_rm16[rm]); if (rm == 0x06) { diff --git a/bochs/cpu/fetchdecode64.cc b/bochs/cpu/fetchdecode64.cc index 5ab1a0993..9617a576d 100644 --- a/bochs/cpu/fetchdecode64.cc +++ b/bochs/cpu/fetchdecode64.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: fetchdecode64.cc,v 1.123 2007-11-12 18:20:12 sshwarts Exp $ +// $Id: fetchdecode64.cc,v 1.124 2007-11-13 17:30:54 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -65,127 +65,97 @@ // Segment override prefixes // ------------------------- -// In 64-bit mode, the CS, DS, ES, and SS segment overrides are ignored. +// In 64-bit mode the CS, DS, ES, and SS segment overrides are ignored. -static BxExecutePtr_tR BxResolve32Mod0[8] = { - &BX_CPU_C::Resolve32Mod0Rm0, - &BX_CPU_C::Resolve32Mod0Rm1, - &BX_CPU_C::Resolve32Mod0Rm2, - &BX_CPU_C::Resolve32Mod0Rm3, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve64Mod0Rip, - &BX_CPU_C::Resolve32Mod0Rm6, - &BX_CPU_C::Resolve32Mod0Rm7 +static BxExecutePtr_tR Resolve32Mod0[8] = { + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm, + NULL, // escape to SIB-byte + &BX_CPU_C::BxResolve32Mod0Rip, + &BX_CPU_C::BxResolve32Mod0Rm, + &BX_CPU_C::BxResolve32Mod0Rm }; -static BxExecutePtr_tR BxResolve32Mod1or2[8] = { - &BX_CPU_C::Resolve32Mod1or2Rm0, - &BX_CPU_C::Resolve32Mod1or2Rm1, - &BX_CPU_C::Resolve32Mod1or2Rm2, - &BX_CPU_C::Resolve32Mod1or2Rm3, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve32Mod1or2Rm5, - &BX_CPU_C::Resolve32Mod1or2Rm6, - &BX_CPU_C::Resolve32Mod1or2Rm7 +static BxExecutePtr_tR Resolve32Mod0Base[8] = { + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Disp, + &BX_CPU_C::BxResolve32Mod0Base, + &BX_CPU_C::BxResolve32Mod0Base, }; -static BxExecutePtr_tR BxResolve32Mod0Base[8] = { - &BX_CPU_C::Resolve32Mod0Base0, - &BX_CPU_C::Resolve32Mod0Base1, - &BX_CPU_C::Resolve32Mod0Base2, - &BX_CPU_C::Resolve32Mod0Base3, - &BX_CPU_C::Resolve32Mod0Base4, - &BX_CPU_C::Resolve32Mod0Base5, - &BX_CPU_C::Resolve32Mod0Base6, - &BX_CPU_C::Resolve32Mod0Base7, +static BxExecutePtr_tR Resolve32Mod0BaseIndex[8] = { + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0DispIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, + &BX_CPU_C::BxResolve32Mod0BaseIndex, }; -static BxExecutePtr_tR BxResolve32Mod1or2Base[8] = { - &BX_CPU_C::Resolve32Mod1or2Base0, - &BX_CPU_C::Resolve32Mod1or2Base1, - &BX_CPU_C::Resolve32Mod1or2Base2, - &BX_CPU_C::Resolve32Mod1or2Base3, - &BX_CPU_C::Resolve32Mod1or2Base4, - &BX_CPU_C::Resolve32Mod1or2Base5, - &BX_CPU_C::Resolve32Mod1or2Base6, - &BX_CPU_C::Resolve32Mod1or2Base7, +static BxExecutePtr_tR Resolve64Mod0[16] = { + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + NULL, // escape to SIB-byte + &BX_CPU_C::BxResolve64Mod0Rip, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm, + NULL, // escape to SIB-byte + &BX_CPU_C::BxResolve64Mod0Rip, + &BX_CPU_C::BxResolve64Mod0Rm, + &BX_CPU_C::BxResolve64Mod0Rm }; -static BxExecutePtr_tR BxResolve64Mod0[16] = { - &BX_CPU_C::Resolve64Mod0Rm0, - &BX_CPU_C::Resolve64Mod0Rm1, - &BX_CPU_C::Resolve64Mod0Rm2, - &BX_CPU_C::Resolve64Mod0Rm3, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve64Mod0Rip, - &BX_CPU_C::Resolve64Mod0Rm6, - &BX_CPU_C::Resolve64Mod0Rm7, - &BX_CPU_C::Resolve64Mod0Rm8, - &BX_CPU_C::Resolve64Mod0Rm9, - &BX_CPU_C::Resolve64Mod0Rm10, - &BX_CPU_C::Resolve64Mod0Rm11, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve64Mod0Rip, - &BX_CPU_C::Resolve64Mod0Rm14, - &BX_CPU_C::Resolve64Mod0Rm15 +static BxExecutePtr_tR Resolve64Mod0Base[16] = { + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Disp, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Disp, + &BX_CPU_C::BxResolve64Mod0Base, + &BX_CPU_C::BxResolve64Mod0Base, }; -static BxExecutePtr_tR BxResolve64Mod1or2[16] = { - &BX_CPU_C::Resolve64Mod1or2Rm0, - &BX_CPU_C::Resolve64Mod1or2Rm1, - &BX_CPU_C::Resolve64Mod1or2Rm2, - &BX_CPU_C::Resolve64Mod1or2Rm3, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve64Mod1or2Rm5, - &BX_CPU_C::Resolve64Mod1or2Rm6, - &BX_CPU_C::Resolve64Mod1or2Rm7, - &BX_CPU_C::Resolve64Mod1or2Rm8, - &BX_CPU_C::Resolve64Mod1or2Rm9, - &BX_CPU_C::Resolve64Mod1or2Rm10, - &BX_CPU_C::Resolve64Mod1or2Rm11, - NULL, // escape to 2-byte - &BX_CPU_C::Resolve64Mod1or2Rm13, - &BX_CPU_C::Resolve64Mod1or2Rm14, - &BX_CPU_C::Resolve64Mod1or2Rm15 -}; - -static BxExecutePtr_tR BxResolve64Mod0Base[16] = { - &BX_CPU_C::Resolve64Mod0Base0, - &BX_CPU_C::Resolve64Mod0Base1, - &BX_CPU_C::Resolve64Mod0Base2, - &BX_CPU_C::Resolve64Mod0Base3, - &BX_CPU_C::Resolve64Mod0Base4, - &BX_CPU_C::Resolve64Mod0Base5, - &BX_CPU_C::Resolve64Mod0Base6, - &BX_CPU_C::Resolve64Mod0Base7, - &BX_CPU_C::Resolve64Mod0Base8, - &BX_CPU_C::Resolve64Mod0Base9, - &BX_CPU_C::Resolve64Mod0Base10, - &BX_CPU_C::Resolve64Mod0Base11, - &BX_CPU_C::Resolve64Mod0Base12, - &BX_CPU_C::Resolve64Mod0Base13, - &BX_CPU_C::Resolve64Mod0Base14, - &BX_CPU_C::Resolve64Mod0Base15, -}; - -static BxExecutePtr_tR BxResolve64Mod1or2Base[16] = { - &BX_CPU_C::Resolve64Mod1or2Base0, - &BX_CPU_C::Resolve64Mod1or2Base1, - &BX_CPU_C::Resolve64Mod1or2Base2, - &BX_CPU_C::Resolve64Mod1or2Base3, - &BX_CPU_C::Resolve64Mod1or2Base4, - &BX_CPU_C::Resolve64Mod1or2Base5, - &BX_CPU_C::Resolve64Mod1or2Base6, - &BX_CPU_C::Resolve64Mod1or2Base7, - &BX_CPU_C::Resolve64Mod1or2Base8, - &BX_CPU_C::Resolve64Mod1or2Base9, - &BX_CPU_C::Resolve64Mod1or2Base10, - &BX_CPU_C::Resolve64Mod1or2Base11, - &BX_CPU_C::Resolve64Mod1or2Base12, - &BX_CPU_C::Resolve64Mod1or2Base13, - &BX_CPU_C::Resolve64Mod1or2Base14, - &BX_CPU_C::Resolve64Mod1or2Base15, +static BxExecutePtr_tR Resolve64Mod0BaseIndex[16] = { + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0DispIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0DispIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, + &BX_CPU_C::BxResolve64Mod0BaseIndex, }; @@ -2163,7 +2133,7 @@ BX_CPU_C::fetchDecode64(Bit8u *iptr, bxInstruction_c *instruction, unsigned rema offset = 512*1; - instruction->ResolveModrm = ResolveDummy; + instruction->ResolveModrm = BxResolveDummy; instruction->initMetaInfo(/*os32*/ 1, // operand size 32 override defaults to 1 /*as32*/ 1, // address size 32 override defaults to 1 /*os64*/ 0, // operand size 64 override defaults to 0 @@ -2310,31 +2280,27 @@ fetch_b1: // Parse mod-nnn-rm and related bytes mod = b2 & 0xc0; nnn = ((b2 >> 3) & 0x07) | rex_r; - rm = b2 & 0x07; + rm = (b2 & 0x07) | rex_b; // MOVs with CRx and DRx always use register ops and ignore the mod field. if ((b1 & ~3) == 0x120) mod = 0xc0; - instruction->modRMForm.modRMData1 = 0; + instruction->modRMForm.modRMData1 = rm; instruction->modRMForm.modRMData2 = mod; instruction->modRMForm.modRMData3 = 0; instruction->modRMForm.modRMData4 = nnn; if (mod == 0xc0) { // mod == 11b - rm |= rex_b; - instruction->modRMForm.modRMData1 |= rm; instruction->assertModC0(); goto modrm_done; } - if (rm != 4) rm |= rex_b; - instruction->modRMForm.modRMData1 |= rm; if (instruction->as64L()) { // 64-bit addressing modes; note that mod==11b handled above if ((rm & 0x7) != 4) { // no s-i-b byte if (mod == 0x00) { // mod == 00b - instruction->ResolveModrm = BxResolve64Mod0[rm]; + instruction->ResolveModrm = Resolve64Mod0[rm]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_SEG_REG_DS); if ((rm & 0x7) == 5) { @@ -2350,7 +2316,7 @@ fetch_b1: goto modrm_done; } if (mod == 0x40) { // mod == 01b - instruction->ResolveModrm = BxResolve64Mod1or2[rm]; + instruction->ResolveModrm = BxResolve64Mod1or2Rm; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm32[rm]); if (ilen < remain) { @@ -2362,7 +2328,7 @@ fetch_b1: else return(0); } // (mod == 0x80) mod == 10b - instruction->ResolveModrm = BxResolve64Mod1or2[rm]; + instruction->ResolveModrm = BxResolve64Mod1or2Rm; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm32[rm]); if ((ilen+3) < remain) { @@ -2384,12 +2350,15 @@ fetch_b1: } base = (sib & 0x07) | rex_b; sib >>= 3; index = (sib & 0x07) | rex_x; sib >>= 3; - scale = sib; - instruction->modRMForm.modRMData2 |= (base); - instruction->modRMForm.modRMData3 |= (index); + scale = sib; + instruction->modRMForm.modRMData3 |= (base); + instruction->modRMForm.modRMData2 |= (index); instruction->modRMForm.modRMData2 |= (scale<<4); if (mod == 0x00) { // mod==00b, rm==4 - instruction->ResolveModrm = BxResolve64Mod0Base[base]; + if (index == 4) + instruction->ResolveModrm = Resolve64Mod0Base[base]; + else + instruction->ResolveModrm = Resolve64Mod0BaseIndex[base]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod0_base32[base]); if ((base & 0x7) == 5) @@ -2398,13 +2367,19 @@ fetch_b1: goto modrm_done; } if (mod == 0x40) { // mod==01b, rm==4 - instruction->ResolveModrm = BxResolve64Mod1or2Base[base]; + if (index == 4) + instruction->ResolveModrm = BxResolve64Mod1or2Base; + else + instruction->ResolveModrm = BxResolve64Mod1or2BaseIndex; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod1or2_base32[base]); goto get_8bit_displ; } // (mod == 0x80), mod==10b, rm==4 - instruction->ResolveModrm = BxResolve64Mod1or2Base[base]; + if (index == 4) + instruction->ResolveModrm = BxResolve64Mod1or2Base; + else + instruction->ResolveModrm = BxResolve64Mod1or2BaseIndex; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod1or2_base32[base]); goto get_32bit_displ; @@ -2414,7 +2389,7 @@ fetch_b1: // 32-bit addressing modes; note that mod==11b handled above if ((rm & 0x7) != 4) { // no s-i-b byte if (mod == 0x00) { // mod == 00b - instruction->ResolveModrm = BxResolve32Mod0[rm]; + instruction->ResolveModrm = Resolve32Mod0[rm]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_SEG_REG_DS); if ((rm & 0x7) == 5) { @@ -2430,7 +2405,7 @@ fetch_b1: goto modrm_done; } if (mod == 0x40) { // mod == 01b - instruction->ResolveModrm = BxResolve32Mod1or2[rm]; + instruction->ResolveModrm = BxResolve32Mod1or2Rm; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm32[rm]); get_8bit_displ: @@ -2443,7 +2418,7 @@ get_8bit_displ: else return(0); } // (mod == 0x80) mod == 10b - instruction->ResolveModrm = BxResolve32Mod1or2[rm]; + instruction->ResolveModrm = BxResolve32Mod1or2Rm; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod01or10_rm32[rm]); get_32bit_displ: @@ -2466,12 +2441,15 @@ get_32bit_displ: } base = (sib & 0x07) | rex_b; sib >>= 3; index = (sib & 0x07) | rex_x; sib >>= 3; - scale = sib; - instruction->modRMForm.modRMData2 |= (base); - instruction->modRMForm.modRMData3 |= (index); + scale = sib; + instruction->modRMForm.modRMData3 |= (base); + instruction->modRMForm.modRMData2 |= (index); instruction->modRMForm.modRMData2 |= (scale<<4); if (mod == 0x00) { // mod==00b, rm==4 - instruction->ResolveModrm = BxResolve32Mod0Base[base]; + if (index == 4) + instruction->ResolveModrm = Resolve32Mod0Base[base]; + else + instruction->ResolveModrm = Resolve32Mod0BaseIndex[base]; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod0_base32[base]); if ((base & 0x7) == 5) @@ -2480,13 +2458,19 @@ get_32bit_displ: goto modrm_done; } if (mod == 0x40) { // mod==01b, rm==4 - instruction->ResolveModrm = BxResolve32Mod1or2Base[base]; + if (index == 4) + instruction->ResolveModrm = BxResolve32Mod1or2Base; + else + instruction->ResolveModrm = BxResolve32Mod1or2BaseIndex; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod1or2_base32[base]); goto get_8bit_displ; } // (mod == 0x80), mod==10b, rm==4 - instruction->ResolveModrm = BxResolve32Mod1or2Base[base]; + if (index == 4) + instruction->ResolveModrm = BxResolve32Mod1or2Base; + else + instruction->ResolveModrm = BxResolve32Mod1or2BaseIndex; if (BX_NULL_SEG_REG(instruction->seg())) instruction->setSeg(BX_CPU_THIS_PTR sreg_mod1or2_base32[base]); goto get_32bit_displ; diff --git a/bochs/cpu/resolve16.cc b/bochs/cpu/resolve16.cc index 4b2abc45a..08993898f 100644 --- a/bochs/cpu/resolve16.cc +++ b/bochs/cpu/resolve16.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: resolve16.cc,v 1.11 2007-11-12 18:20:15 sshwarts Exp $ +// $Id: resolve16.cc,v 1.12 2007-11-13 17:30:54 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -31,89 +31,89 @@ #define LOG_THIS BX_CPU_THIS_PTR void BX_CPP_AttrRegparmN(1) -BX_CPU_C::ResolveDummy(bxInstruction_c *i) +BX_CPU_C::BxResolveDummy(bxInstruction_c *) { return; // used when no memory access is needed } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm0(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm0(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BX + SI); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm1(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm1(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BX + DI); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm2(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm2(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BP + SI); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm3(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm3(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BP + DI); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm4(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm4(bxInstruction_c *i) { RMAddr(i) = (Bit16u) SI; } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm5(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm5(bxInstruction_c *i) { RMAddr(i) = (Bit16u) DI; } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm6(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm6(bxInstruction_c *i) { RMAddr(i) = i->displ16u(); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod0Rm7(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod0Rm7(bxInstruction_c *i) { RMAddr(i) = (Bit16u) BX; } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm0(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm0(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BX + SI + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm1(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm1(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BX + DI + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm2(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm2(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BP + SI + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm3(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm3(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BP + DI + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm4(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm4(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (SI + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm5(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm5(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (DI + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm6(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm6(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BP + (Bit16s) i->displ16u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve16Mod1or2Rm7(bxInstruction_c *i) +BX_CPU_C::BxResolve16Mod1or2Rm7(bxInstruction_c *i) { RMAddr(i) = (Bit16u) (BX + (Bit16s) i->displ16u()); } diff --git a/bochs/cpu/resolve32.cc b/bochs/cpu/resolve32.cc index e6bbb6a9c..d8d2048b7 100644 --- a/bochs/cpu/resolve32.cc +++ b/bochs/cpu/resolve32.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: resolve32.cc,v 1.11 2006-03-06 22:03:02 sshwarts Exp $ +// $Id: resolve32.cc,v 1.12 2007-11-13 17:30:54 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -32,256 +32,47 @@ void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm0(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod0Rm(bxInstruction_c *i) { - RMAddr(i) = EAX; + RMAddr(i) = BX_READ_32BIT_REG(i->rm()); +} + + void BX_CPP_AttrRegparmN(1) +BX_CPU_C::BxResolve32Mod0Base(bxInstruction_c *i) +{ + RMAddr(i) = BX_READ_32BIT_REG(i->sibBase()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm1(bxInstruction_c *i) -{ - RMAddr(i) = ECX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm2(bxInstruction_c *i) -{ - RMAddr(i) = EDX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm3(bxInstruction_c *i) -{ - RMAddr(i) = EBX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm5(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod0Disp(bxInstruction_c *i) { RMAddr(i) = i->displ32u(); } - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm6(bxInstruction_c *i) -{ - RMAddr(i) = ESI; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Rm7(bxInstruction_c *i) -{ - RMAddr(i) = EDI; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm0(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod0BaseIndex(bxInstruction_c *i) { - RMAddr(i) = EAX + i->displ32u(); + RMAddr(i) = BX_READ_32BIT_REG(i->sibBase()) + (BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm1(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod0DispIndex(bxInstruction_c *i) { - RMAddr(i) = ECX + i->displ32u(); + RMAddr(i) = i->displ32u() + (BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale()); } - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm2(bxInstruction_c *i) -{ - RMAddr(i) = EDX + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm3(bxInstruction_c *i) -{ - RMAddr(i) = EBX + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm5(bxInstruction_c *i) -{ - RMAddr(i) = EBP + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm6(bxInstruction_c *i) -{ - RMAddr(i) = ESI + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Rm7(bxInstruction_c *i) -{ - RMAddr(i) = EDI + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base0(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod1or2Rm(bxInstruction_c *i) { - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EAX + scaled_index; + RMAddr(i) = BX_READ_32BIT_REG(i->rm()) + i->displ32u(); } - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base1(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = ECX + scaled_index; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base2(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EDX + scaled_index; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base3(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EBX + scaled_index; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base4(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = ESP + scaled_index; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base5(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = i->displ32u() + scaled_index; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base6(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = ESI + scaled_index; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod0Base7(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EDI + scaled_index; -} - - - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base0(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod1or2Base(bxInstruction_c *i) { - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EAX + scaled_index + i->displ32u(); + RMAddr(i) = BX_READ_32BIT_REG(i->sibBase()) + i->displ32u(); } + void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base1(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod1or2BaseIndex(bxInstruction_c *i) { - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = ECX + scaled_index + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base2(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EDX + scaled_index + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base3(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EBX + scaled_index + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base4(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = ESP + scaled_index + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base5(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EBP + scaled_index + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base6(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = ESI + scaled_index + i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve32Mod1or2Base7(bxInstruction_c *i) -{ - Bit32u scaled_index; - - if (i->sibIndex() != 4) - scaled_index = BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale(); - else - scaled_index = 0; - RMAddr(i) = EDI + scaled_index + i->displ32u(); + RMAddr(i) = BX_READ_32BIT_REG(i->sibBase()) + (BX_READ_32BIT_REG(i->sibIndex()) << i->sibScale()) + i->displ32u(); } diff --git a/bochs/cpu/resolve64.cc b/bochs/cpu/resolve64.cc index f128dffea..a5abf2657 100644 --- a/bochs/cpu/resolve64.cc +++ b/bochs/cpu/resolve64.cc @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////// -// $Id: resolve64.cc,v 1.10 2007-04-09 21:15:00 sshwarts Exp $ +// $Id: resolve64.cc,v 1.11 2007-11-13 17:30:54 sshwarts Exp $ ///////////////////////////////////////////////////////////////////////// // // Copyright (C) 2001 MandrakeSoft S.A. @@ -34,401 +34,62 @@ #if BX_SUPPORT_X86_64 void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm0(bxInstruction_c *i) +BX_CPU_C::BxResolve32Mod0Rip(bxInstruction_c *i) { - RMAddr(i) = RAX; + // RIP hasn't been bumped yet when this is called. must choose the saved value. + RMAddr(i) = (Bit32u) (BX_CPU_THIS_PTR prev_eip + i->ilen() + (Bit32s)i->displ32u()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm1(bxInstruction_c *i) -{ - RMAddr(i) = RCX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm2(bxInstruction_c *i) -{ - RMAddr(i) = RDX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm3(bxInstruction_c *i) -{ - RMAddr(i) = RBX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rip(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod0Rip(bxInstruction_c *i) { // RIP hasn't been bumped yet when this is called. must choose the saved value. RMAddr(i) = BX_CPU_THIS_PTR prev_eip + i->ilen() + (Bit32s)i->displ32u(); } - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm6(bxInstruction_c *i) -{ - RMAddr(i) = RSI; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm7(bxInstruction_c *i) -{ - RMAddr(i) = RDI; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm8(bxInstruction_c *i) -{ - RMAddr(i) = R8; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm9(bxInstruction_c *i) -{ - RMAddr(i) = R9; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm10(bxInstruction_c *i) -{ - RMAddr(i) = R10; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm11(bxInstruction_c *i) -{ - RMAddr(i) = R11; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm14(bxInstruction_c *i) -{ - RMAddr(i) = R14; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Rm15(bxInstruction_c *i) -{ - RMAddr(i) = R15; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm0(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod0Rm(bxInstruction_c *i) { - RMAddr(i) = RAX + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm1(bxInstruction_c *i) -{ - RMAddr(i) = RCX + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm2(bxInstruction_c *i) -{ - RMAddr(i) = RDX + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm3(bxInstruction_c *i) -{ - RMAddr(i) = RBX + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm5(bxInstruction_c *i) -{ - RMAddr(i) = RBP + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm6(bxInstruction_c *i) -{ - RMAddr(i) = RSI + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm7(bxInstruction_c *i) -{ - RMAddr(i) = RDI + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm8(bxInstruction_c *i) -{ - RMAddr(i) = R8 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm9(bxInstruction_c *i) -{ - RMAddr(i) = R9 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm10(bxInstruction_c *i) -{ - RMAddr(i) = R10 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm11(bxInstruction_c *i) -{ - RMAddr(i) = R11 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm13(bxInstruction_c *i) -{ - RMAddr(i) = R13 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm14(bxInstruction_c *i) -{ - RMAddr(i) = R14 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Rm15(bxInstruction_c *i) -{ - RMAddr(i) = R15 + (Bit32s) i->displ32u(); -} - - - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base0(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RAX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RAX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base1(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RCX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RCX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base2(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RDX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RDX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base3(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RBX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RBX; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base4(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RSP + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RSP; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base5(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base6(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RSI + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RSI; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base7(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RDI + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = RDI; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base8(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R8 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R8; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base9(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R9 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R9; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base10(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R10 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R10; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base11(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R11 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R11; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base12(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R12 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R12; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base13(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R13 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R13; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base14(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R14 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R14; -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod0Base15(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R15 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); - else - RMAddr(i) = R15; + RMAddr(i) = BX_READ_64BIT_REG(i->rm()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base0(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod0Base(bxInstruction_c *i) { - if (i->sibIndex() != 4) - RMAddr(i) = RAX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RAX + (Bit32s) i->displ32u(); + RMAddr(i) = BX_READ_64BIT_REG(i->sibBase()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base1(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod0Disp(bxInstruction_c *i) { - if (i->sibIndex() != 4) - RMAddr(i) = RCX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RCX + (Bit32s) i->displ32u(); + RMAddr(i) = (Bit32s) i->displ32u(); +} + + void BX_CPP_AttrRegparmN(1) +BX_CPU_C::BxResolve64Mod0BaseIndex(bxInstruction_c *i) +{ + RMAddr(i) = BX_READ_64BIT_REG(i->sibBase()) + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()); } void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base2(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod0DispIndex(bxInstruction_c *i) { - if (i->sibIndex() != 4) - RMAddr(i) = RDX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RDX + (Bit32s) i->displ32u(); + RMAddr(i) = (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); } + void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base3(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod1or2Rm(bxInstruction_c *i) { - if (i->sibIndex() != 4) - RMAddr(i) = RBX + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RBX + (Bit32s) i->displ32u(); + RMAddr(i) = BX_READ_64BIT_REG(i->rm()) + (Bit32s) i->displ32u(); } + void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base4(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod1or2Base(bxInstruction_c *i) { - if (i->sibIndex() != 4) - RMAddr(i) = RSP + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RSP + (Bit32s) i->displ32u(); + RMAddr(i) = BX_READ_64BIT_REG(i->sibBase()) + (Bit32s) i->displ32u(); } + void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base5(bxInstruction_c *i) +BX_CPU_C::BxResolve64Mod1or2BaseIndex(bxInstruction_c *i) { - if (i->sibIndex() != 4) - RMAddr(i) = RBP + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RBP + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base6(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RSI + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RSI + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base7(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = RDI + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = RDI + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base8(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R8 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R8 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base9(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R9 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R9 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base10(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R10 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R10 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base11(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R11 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R11 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base12(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R12 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R12 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base13(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R13 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R13 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base14(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R14 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R14 + (Bit32s) i->displ32u(); -} - void BX_CPP_AttrRegparmN(1) -BX_CPU_C::Resolve64Mod1or2Base15(bxInstruction_c *i) -{ - if (i->sibIndex() != 4) - RMAddr(i) = R15 + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); - else - RMAddr(i) = R15 + (Bit32s) i->displ32u(); + RMAddr(i) = BX_READ_64BIT_REG(i->sibBase()) + (BX_READ_64BIT_REG(i->sibIndex()) << i->sibScale()) + (Bit32s) i->displ32u(); } #endif /* if BX_SUPPORT_X86_64 */