From ac442009aaf2af04ceb83b58774a4102490b1e3d Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Sun, 15 Oct 2017 22:01:32 +0000 Subject: [PATCH] lazy flags code small refactoring --- bochs/cpu/cpu.h | 195 +++++++------------------------------ bochs/cpu/lazy_flags.h | 215 ++++++++++++++++++++++++++++++++++++++++- bochs/cpu/mult16.cc | 8 +- bochs/cpu/mult32.cc | 8 +- bochs/cpu/mult64.cc | 8 +- bochs/cpu/mult8.cc | 4 +- bochs/cpu/shift16.cc | 44 ++++----- bochs/cpu/shift32.cc | 36 +++---- bochs/cpu/shift64.cc | 36 +++---- bochs/cpu/shift8.cc | 36 +++---- 10 files changed, 337 insertions(+), 253 deletions(-) diff --git a/bochs/cpu/cpu.h b/bochs/cpu/cpu.h index 002e973fa..2db2859cd 100644 --- a/bochs/cpu/cpu.h +++ b/bochs/cpu/cpu.h @@ -951,7 +951,7 @@ public: // for now... Bit32u eflags; // Raw 32-bit value in x86 bit position. // lazy arithmetic flags state - bx_lf_flags_entry oszapc; + bx_lazyflags_entry oszapc; // so that we can back up when handling faults, exceptions, etc. // we need to store the value of the instruction pointer, before @@ -1341,164 +1341,43 @@ public: // for now... BX_SMF BX_CPP_INLINE void clearEFlagsOSZAPC(void) { SET_FLAGS_OSZAPC_LOGIC_32(1); } + + BX_SMF BX_CPP_INLINE unsigned getB_OF(void) { return BX_CPU_THIS_PTR oszapc.getB_OF(); } + BX_SMF BX_CPP_INLINE unsigned get_OF(void) { return BX_CPU_THIS_PTR oszapc.get_OF(); } + BX_SMF BX_CPP_INLINE void set_OF(bx_bool val) { BX_CPU_THIS_PTR oszapc.set_OF(val); } + BX_SMF BX_CPP_INLINE void clear_OF(void) { BX_CPU_THIS_PTR oszapc.clear_OF(); } + BX_SMF BX_CPP_INLINE void assert_OF(void) { BX_CPU_THIS_PTR oszapc.assert_OF(); } + + BX_SMF BX_CPP_INLINE unsigned getB_SF(void) { return BX_CPU_THIS_PTR oszapc.getB_SF(); } + BX_SMF BX_CPP_INLINE unsigned get_SF(void) { return BX_CPU_THIS_PTR oszapc.get_SF(); } + BX_SMF BX_CPP_INLINE void set_SF(bx_bool val) { BX_CPU_THIS_PTR oszapc.set_SF(val); } + BX_SMF BX_CPP_INLINE void clear_SF(void) { BX_CPU_THIS_PTR oszapc.clear_SF(); } + BX_SMF BX_CPP_INLINE void assert_SF(void) { BX_CPU_THIS_PTR oszapc.assert_SF(); } + + BX_SMF BX_CPP_INLINE unsigned getB_ZF(void) { return BX_CPU_THIS_PTR oszapc.getB_ZF(); } + BX_SMF BX_CPP_INLINE unsigned get_ZF(void) { return BX_CPU_THIS_PTR oszapc.get_ZF(); } + BX_SMF BX_CPP_INLINE void set_ZF(bx_bool val) { BX_CPU_THIS_PTR oszapc.set_ZF(val); } + BX_SMF BX_CPP_INLINE void clear_ZF(void) { BX_CPU_THIS_PTR oszapc.clear_ZF(); } + BX_SMF BX_CPP_INLINE void assert_ZF(void) { BX_CPU_THIS_PTR oszapc.assert_ZF(); } + + BX_SMF BX_CPP_INLINE unsigned getB_AF(void) { return BX_CPU_THIS_PTR oszapc.getB_AF(); } + BX_SMF BX_CPP_INLINE unsigned get_AF(void) { return BX_CPU_THIS_PTR oszapc.get_AF(); } + BX_SMF BX_CPP_INLINE void set_AF(bx_bool val) { BX_CPU_THIS_PTR oszapc.set_AF(val); } + BX_SMF BX_CPP_INLINE void clear_AF(void) { BX_CPU_THIS_PTR oszapc.clear_AF(); } + BX_SMF BX_CPP_INLINE void assert_AF(void) { BX_CPU_THIS_PTR oszapc.assert_AF(); } + + BX_SMF BX_CPP_INLINE unsigned getB_PF(void) { return BX_CPU_THIS_PTR oszapc.getB_PF(); } + BX_SMF BX_CPP_INLINE unsigned get_PF(void) { return BX_CPU_THIS_PTR oszapc.get_PF(); } + BX_SMF BX_CPP_INLINE void set_PF(bx_bool val) { BX_CPU_THIS_PTR oszapc.set_PF(val); } + BX_SMF BX_CPP_INLINE void clear_PF(void) { BX_CPU_THIS_PTR oszapc.clear_PF(); } + BX_SMF BX_CPP_INLINE void assert_PF(void) { BX_CPU_THIS_PTR oszapc.assert_PF(); } + + BX_SMF BX_CPP_INLINE unsigned getB_CF(void) { return BX_CPU_THIS_PTR oszapc.getB_CF(); } + BX_SMF BX_CPP_INLINE unsigned get_CF(void) { return BX_CPU_THIS_PTR oszapc.get_CF(); } + BX_SMF BX_CPP_INLINE void set_CF(bx_bool val) { BX_CPU_THIS_PTR oszapc.set_CF(val); } + BX_SMF BX_CPP_INLINE void clear_CF(void) { BX_CPU_THIS_PTR oszapc.clear_CF(); } + BX_SMF BX_CPP_INLINE void assert_CF(void) { BX_CPU_THIS_PTR oszapc.assert_CF(); } - BX_SMF BX_CPP_INLINE void SET_FLAGS_OxxxxC(Bit32u new_of, Bit32u new_cf) { - Bit32u temp_po = new_of ^ new_cf; - BX_CPU_THIS_PTR oszapc.auxbits &= ~(LF_MASK_PO | LF_MASK_CF); - BX_CPU_THIS_PTR oszapc.auxbits |= - (temp_po << LF_BIT_PO) | (new_cf << LF_BIT_CF); - } - - BX_SMF BX_CPP_INLINE void ASSERT_FLAGS_OxxxxC() { - SET_FLAGS_OxxxxC(1, 1); - } - - // ZF - BX_SMF BX_CPP_INLINE unsigned getB_ZF(void) { - return (0 == BX_CPU_THIS_PTR oszapc.result); - } - - BX_SMF BX_CPP_INLINE unsigned get_ZF(void) { return getB_ZF(); } - - BX_SMF BX_CPP_INLINE void set_ZF(bx_bool val) { - if (val) assert_ZF(); - else clear_ZF(); - } - - BX_SMF BX_CPP_INLINE void clear_ZF(void) { - BX_CPU_THIS_PTR oszapc.result |= (1 << 8); - } - - BX_SMF BX_CPP_INLINE void assert_ZF(void) { - // merge the sign bit into the Sign Delta - BX_CPU_THIS_PTR oszapc.auxbits ^= - (((BX_CPU_THIS_PTR oszapc.result >> BX_LF_SIGN_BIT) & 1) << LF_BIT_SD); - - // merge the parity bits into the Parity Delta Byte - Bit32u temp_pdb = (255 & BX_CPU_THIS_PTR oszapc.result); - BX_CPU_THIS_PTR oszapc.auxbits ^= (temp_pdb << LF_BIT_PDB); - - // now zero the .result value - BX_CPU_THIS_PTR oszapc.result = 0; - } - - // SF - BX_SMF BX_CPP_INLINE unsigned getB_SF(void) { - return ((BX_CPU_THIS_PTR oszapc.result >> BX_LF_SIGN_BIT) ^ - (BX_CPU_THIS_PTR oszapc.auxbits >> LF_BIT_SD)) & 1; - } - - BX_SMF BX_CPP_INLINE unsigned get_SF(void) { return getB_SF(); } - - BX_SMF BX_CPP_INLINE void set_SF(bx_bool val) { - bx_bool temp_sf = getB_SF(); - - BX_CPU_THIS_PTR oszapc.auxbits ^= (temp_sf ^ val) << LF_BIT_SD; - } - - BX_SMF BX_CPP_INLINE void clear_SF(void) { - set_SF(0); - } - - BX_SMF BX_CPP_INLINE void assert_SF(void) { - set_SF(1); - } - - // PF - bit 2 in EFLAGS, represented by lower 8 bits of oszapc.result - BX_SMF BX_CPP_INLINE unsigned getB_PF(void) { - Bit32u temp = (255 & BX_CPU_THIS_PTR oszapc.result); - temp = temp ^ (255 & (BX_CPU_THIS_PTR oszapc.auxbits >> LF_BIT_PDB)); - temp = (temp ^ (temp >> 4)) & 0x0F; - return (0x9669U >> temp) & 1; - } - - BX_SMF BX_CPP_INLINE unsigned get_PF(void) { return getB_PF(); } - - BX_SMF BX_CPP_INLINE void set_PF(bx_bool val) { - Bit32u temp_pdb = (255 & BX_CPU_THIS_PTR oszapc.result) ^ (!val); - - BX_CPU_THIS_PTR oszapc.auxbits &= ~(LF_MASK_PDB); - BX_CPU_THIS_PTR oszapc.auxbits |= (temp_pdb << LF_BIT_PDB); - } - - BX_SMF BX_CPP_INLINE void clear_PF(void) { - set_PF(0); - } - - BX_SMF BX_CPP_INLINE void assert_PF(void) { - set_PF(1); - } - - // AF - bit 4 in EFLAGS, represented by bit LF_BIT_AF of oszapc.auxbits - BX_SMF BX_CPP_INLINE unsigned getB_AF(void) { - return ((BX_CPU_THIS_PTR oszapc.auxbits >> LF_BIT_AF) & 1); - } - - BX_SMF BX_CPP_INLINE unsigned get_AF(void) { - return (BX_CPU_THIS_PTR oszapc.auxbits & LF_MASK_AF); - } - - BX_SMF BX_CPP_INLINE void set_AF(bx_bool val) { - BX_CPU_THIS_PTR oszapc.auxbits &= ~(LF_MASK_AF); - BX_CPU_THIS_PTR oszapc.auxbits |= (val) << LF_BIT_AF; - } - - BX_SMF BX_CPP_INLINE void clear_AF(void) { - BX_CPU_THIS_PTR oszapc.auxbits &= ~(LF_MASK_AF); - } - - BX_SMF BX_CPP_INLINE void assert_AF(void) { - BX_CPU_THIS_PTR oszapc.auxbits |= (LF_MASK_AF); - } - - // CF - BX_SMF BX_CPP_INLINE unsigned getB_CF(void) { - return ((BX_CPU_THIS_PTR oszapc.auxbits >> LF_BIT_CF) & 1); - } - - BX_SMF BX_CPP_INLINE unsigned get_CF(void) { - return (BX_CPU_THIS_PTR oszapc.auxbits & LF_MASK_CF); - } - - BX_SMF BX_CPP_INLINE void set_CF(bx_bool val) { - bx_bool temp_of = getB_OF(); - SET_FLAGS_OxxxxC(temp_of, (val)); - } - - BX_SMF BX_CPP_INLINE void clear_CF(void) { - bx_bool temp_of = getB_OF(); - SET_FLAGS_OxxxxC(temp_of, (0)); - } - - BX_SMF BX_CPP_INLINE void assert_CF(void) { - bx_bool temp_of = getB_OF(); - SET_FLAGS_OxxxxC(temp_of, (1)); - } - - // OF - BX_SMF BX_CPP_INLINE unsigned getB_OF(void) { - return ((BX_CPU_THIS_PTR oszapc.auxbits + (1U << LF_BIT_PO)) >> LF_BIT_CF) & 1; - } - - BX_SMF BX_CPP_INLINE unsigned get_OF(void) { - return (BX_CPU_THIS_PTR oszapc.auxbits + (1U << LF_BIT_PO)) & (1U << LF_BIT_CF); - } - - BX_SMF BX_CPP_INLINE void set_OF(bx_bool val) { - bx_bool temp_cf = getB_CF(); - SET_FLAGS_OxxxxC((val), temp_cf); - } - - BX_SMF BX_CPP_INLINE void clear_OF(void) { - bx_bool temp_cf = getB_CF(); - SET_FLAGS_OxxxxC((0), temp_cf); - } - - BX_SMF BX_CPP_INLINE void assert_OF(void) { - unsigned temp_cf = getB_CF(); - SET_FLAGS_OxxxxC((1), temp_cf); - } - // constructors & destructors... BX_CPU_C(unsigned id = 0); ~BX_CPU_C(); diff --git a/bochs/cpu/lazy_flags.h b/bochs/cpu/lazy_flags.h index 095d86fb6..b4122c552 100644 --- a/bochs/cpu/lazy_flags.h +++ b/bochs/cpu/lazy_flags.h @@ -29,11 +29,6 @@ #define BX_LF_SIGN_BIT 31 #endif -typedef struct { - bx_address result; - bx_address auxbits; -} bx_lf_flags_entry; - // These are the lazy flags bits in oszapc.auxbits which hold lazy state // of zero flag, adjust flag, carry flag, and overflow flag. @@ -195,4 +190,214 @@ const Bit32u LF_MASK_PO = (0x01 << LF_BIT_PO); SET_FLAGS_OSZAxC_LOGIC_SIZE(64, (result_64)) #endif +struct bx_lazyflags_entry { + bx_address result; + bx_address auxbits; + + BX_CPP_INLINE unsigned getB_OF(void) const; + BX_CPP_INLINE unsigned get_OF(void) const; + BX_CPP_INLINE void set_OF(bx_bool val); + BX_CPP_INLINE void clear_OF(void); + BX_CPP_INLINE void assert_OF(void); + + BX_CPP_INLINE unsigned getB_SF(void) const; + BX_CPP_INLINE unsigned get_SF(void) const; + BX_CPP_INLINE void set_SF(bx_bool val); + BX_CPP_INLINE void clear_SF(void); + BX_CPP_INLINE void assert_SF(void); + + BX_CPP_INLINE unsigned getB_ZF(void) const; + BX_CPP_INLINE unsigned get_ZF(void) const; + BX_CPP_INLINE void set_ZF(bx_bool val); + BX_CPP_INLINE void clear_ZF(void); + BX_CPP_INLINE void assert_ZF(void); + + BX_CPP_INLINE unsigned getB_AF(void) const; + BX_CPP_INLINE unsigned get_AF(void) const; + BX_CPP_INLINE void set_AF(bx_bool val); + BX_CPP_INLINE void clear_AF(void); + BX_CPP_INLINE void assert_AF(void); + + BX_CPP_INLINE unsigned getB_PF(void) const; + BX_CPP_INLINE unsigned get_PF(void) const; + BX_CPP_INLINE void set_PF(bx_bool val); + BX_CPP_INLINE void clear_PF(void); + BX_CPP_INLINE void assert_PF(void); + + BX_CPP_INLINE unsigned getB_CF(void) const; + BX_CPP_INLINE unsigned get_CF(void) const; + BX_CPP_INLINE void set_CF(bx_bool val); + BX_CPP_INLINE void clear_CF(void); + BX_CPP_INLINE void assert_CF(void); + + BX_CPP_INLINE void set_flags_OxxxxC(Bit32u new_of, Bit32u new_cf) + { + Bit32u temp_po = new_of ^ new_cf; + auxbits &= ~(LF_MASK_PO | LF_MASK_CF); + auxbits |= (temp_po << LF_BIT_PO) | (new_cf << LF_BIT_CF); + } + + BX_CPP_INLINE void assert_flags_OxxxxC() { set_flags_OxxxxC(1,1); } +}; + +/// OF //////////////////////////////////////// +BX_CPP_INLINE unsigned bx_lazyflags_entry::getB_OF(void) const +{ + return ((auxbits + (1U << LF_BIT_PO)) >> LF_BIT_CF) & 1; +} + +BX_CPP_INLINE unsigned bx_lazyflags_entry::get_OF(void) const +{ + return (auxbits + (1U << LF_BIT_PO)) & (1U << LF_BIT_CF); +} + +BX_CPP_INLINE void bx_lazyflags_entry::set_OF(bx_bool val) +{ + bx_bool temp_cf = getB_CF(); + set_flags_OxxxxC(val, temp_cf); +} + +BX_CPP_INLINE void bx_lazyflags_entry::clear_OF(void) +{ + bx_bool temp_cf = getB_CF(); + set_flags_OxxxxC(0, temp_cf); +} + +BX_CPP_INLINE void bx_lazyflags_entry::assert_OF(void) +{ + unsigned temp_cf = getB_CF(); + set_flags_OxxxxC(1, temp_cf); +} + +/// SF //////////////////////////////////////// +BX_CPP_INLINE unsigned bx_lazyflags_entry::getB_SF(void) const +{ + return ((result >> BX_LF_SIGN_BIT) ^ (auxbits >> LF_BIT_SD)) & 1; +} + +BX_CPP_INLINE unsigned bx_lazyflags_entry::get_SF(void) const { return getB_SF(); } + +BX_CPP_INLINE void bx_lazyflags_entry::set_SF(bx_bool val) +{ + bx_bool temp_sf = getB_SF(); + auxbits ^= (temp_sf ^ val) << LF_BIT_SD; +} + +BX_CPP_INLINE void bx_lazyflags_entry::clear_SF (void) { set_SF(0); } +BX_CPP_INLINE void bx_lazyflags_entry::assert_SF (void) { set_SF(1); } + +/// ZF //////////////////////////////////////// +BX_CPP_INLINE unsigned bx_lazyflags_entry::getB_ZF(void) const +{ + return (0 == result); +} + +BX_CPP_INLINE unsigned bx_lazyflags_entry::get_ZF(void) const { return getB_ZF(); } + +BX_CPP_INLINE void bx_lazyflags_entry::set_ZF(bx_bool val) +{ + if (val) assert_ZF(); + else clear_ZF(); +} + +BX_CPP_INLINE void bx_lazyflags_entry::clear_ZF(void) +{ + result |= (1 << 8); +} + +BX_CPP_INLINE void bx_lazyflags_entry::assert_ZF(void) +{ + // merge the sign bit into the Sign Delta + auxbits ^= (((result >> BX_LF_SIGN_BIT) & 1) << LF_BIT_SD); + + // merge the parity bits into the Parity Delta Byte + Bit32u temp_pdb = (255 & result); + auxbits ^= (temp_pdb << LF_BIT_PDB); + + // now zero the .result value + result = 0; +} + +/// AF //////////////////////////////////////// + +// AF - bit 4 in EFLAGS, represented by bit LF_BIT_AF of oszapc.auxbits +BX_CPP_INLINE unsigned bx_lazyflags_entry::getB_AF(void) const +{ + return (auxbits >> LF_BIT_AF) & 1; +} + +BX_CPP_INLINE unsigned bx_lazyflags_entry::get_AF(void) const +{ + return (auxbits & LF_MASK_AF); +} + +BX_CPP_INLINE void bx_lazyflags_entry::set_AF(bx_bool val) +{ + auxbits &= ~(LF_MASK_AF); + auxbits |= (val) << LF_BIT_AF; +} + +BX_CPP_INLINE void bx_lazyflags_entry::clear_AF(void) +{ + auxbits &= ~(LF_MASK_AF); +} + +BX_CPP_INLINE void bx_lazyflags_entry::assert_AF(void) +{ + auxbits |= (LF_MASK_AF); +} + +/// PF //////////////////////////////////////// + +// PF - bit 2 in EFLAGS, represented by lower 8 bits of oszapc.result +BX_CPP_INLINE unsigned bx_lazyflags_entry::getB_PF(void) const +{ + Bit32u temp = (255 & result); + temp = temp ^ (255 & (auxbits >> LF_BIT_PDB)); + temp = (temp ^ (temp >> 4)) & 0x0F; + return (0x9669U >> temp) & 1; +} + +BX_CPP_INLINE unsigned bx_lazyflags_entry::get_PF(void) const { return getB_PF(); } + +BX_CPP_INLINE void bx_lazyflags_entry::set_PF(bx_bool val) +{ + Bit32u temp_pdb = (255 & result) ^ (!val); + auxbits &= ~(LF_MASK_PDB); + auxbits |= (temp_pdb << LF_BIT_PDB); +} + +BX_CPP_INLINE void bx_lazyflags_entry::clear_PF (void) { set_PF(0); } +BX_CPP_INLINE void bx_lazyflags_entry::assert_PF (void) { set_PF(1); } + +/// CF //////////////////////////////////////// + +BX_CPP_INLINE unsigned bx_lazyflags_entry::getB_CF(void) const +{ + return (auxbits >> LF_BIT_CF) & 1; +} + +BX_CPP_INLINE unsigned bx_lazyflags_entry::get_CF(void) const +{ + return (auxbits & LF_MASK_CF); +} + +BX_CPP_INLINE void bx_lazyflags_entry::set_CF(bx_bool val) +{ + bx_bool temp_of = getB_OF(); + set_flags_OxxxxC(temp_of, val); +} + +BX_CPP_INLINE void bx_lazyflags_entry::clear_CF(void) +{ + bx_bool temp_of = getB_OF(); + set_flags_OxxxxC(temp_of, 0); +} + +BX_CPP_INLINE void bx_lazyflags_entry::assert_CF(void) +{ + bx_bool temp_of = getB_OF(); + set_flags_OxxxxC(temp_of, 1); +} + #endif // BX_LAZY_FLAGS_DEF diff --git a/bochs/cpu/mult16.cc b/bochs/cpu/mult16.cc index 12f6bd697..29ba652d0 100644 --- a/bochs/cpu/mult16.cc +++ b/bochs/cpu/mult16.cc @@ -41,7 +41,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MUL_AXEwR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_16(product_16l); if(product_16h != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -67,7 +67,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_AXEwR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_16(product_16l); if(product_32 != (Bit16s)product_32) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -140,7 +140,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_GwEwIwR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_16(product_16); if(product_32 != (Bit16s) product_32) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -164,7 +164,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_GwEwR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_16(product_16); if(product_32 != (Bit16s) product_32) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/mult32.cc b/bochs/cpu/mult32.cc index 4d085b9af..68bf30a69 100644 --- a/bochs/cpu/mult32.cc +++ b/bochs/cpu/mult32.cc @@ -41,7 +41,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MUL_EAXEdR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_32(product_32l); if(product_32h != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -67,7 +67,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_EAXEdR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_32(product_32l); if(product_64 != (Bit32s)product_64) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -153,7 +153,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_GdEdIdR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_32(product_32); if(product_64 != (Bit32s) product_64) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -177,7 +177,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_GdEdR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_32(product_32); if(product_64 != (Bit32s) product_64) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/mult64.cc b/bochs/cpu/mult64.cc index 25f2d0b4c..ad8584bf3 100644 --- a/bochs/cpu/mult64.cc +++ b/bochs/cpu/mult64.cc @@ -220,7 +220,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MUL_RAXEqR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_64(product_128.lo); if(product_128.hi != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -252,7 +252,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_RAXEqR(bxInstruction_c *i) /* magic compare between RDX:RAX and sign extended RAX */ if (((Bit64u)(product_128.hi) + (product_128.lo >> 63)) != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -349,7 +349,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_GqEqIdR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_64(product_128.lo); if (((Bit64u)(product_128.hi) + (product_128.lo >> 63)) != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -370,7 +370,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_GqEqR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_64(product_128.lo); if (((Bit64u)(product_128.hi) + (product_128.lo >> 63)) != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/mult8.cc b/bochs/cpu/mult8.cc index 26e669866..f99d97ee7 100644 --- a/bochs/cpu/mult8.cc +++ b/bochs/cpu/mult8.cc @@ -41,7 +41,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::MUL_ALEbR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_8(product_8l); if(product_8h != 0) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); @@ -66,7 +66,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::IMUL_ALEbR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_8(product_8); if(product_16 != (Bit8s) product_16) { - ASSERT_FLAGS_OxxxxC(); + BX_CPU_THIS_PTR oszapc.assert_flags_OxxxxC(); } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/shift16.cc b/bochs/cpu/shift16.cc index 40a81550c..23537ec8f 100644 --- a/bochs/cpu/shift16.cc +++ b/bochs/cpu/shift16.cc @@ -67,7 +67,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHLD_EwGwM(bxInstruction_c *i) cf = (temp_32 >> (32 - count)) & 0x1; of = cf ^ (result_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -113,7 +113,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHLD_EwGwR(bxInstruction_c *i) cf = (temp_32 >> (32 - count)) & 0x1; of = cf ^ (result_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -162,7 +162,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EwGwM(bxInstruction_c *i) cf = (op1_16 >> (count - 1)) & 0x1; of = ((Bit16u)((result_16 << 1) ^ result_16) >> 15) & 0x1; // of = result14 ^ result15 if (count > 16) cf = (op2_16 >> (count - 17)) & 0x1; // undefined flags behavior matching real HW - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -208,7 +208,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EwGwR(bxInstruction_c *i) cf = (op1_16 >> (count - 1)) & 0x1; of = ((Bit16u)((result_16 << 1) ^ result_16) >> 15) & 0x1; // of = result14 ^ result15 if (count > 16) cf = (op2_16 >> (count - 17)) & 0x1; // undefined flags behavior matching real HW - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -233,7 +233,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EwM(bxInstruction_c *i) bit0 = (op1_16 & 0x1); bit15 = (op1_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(bit0 ^ bit15, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit15, bit0); } } else { @@ -246,7 +246,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EwM(bxInstruction_c *i) bit0 = (result_16 & 0x1); bit15 = (result_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(bit0 ^ bit15, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit15, bit0); } BX_NEXT_INSTR(i); @@ -269,7 +269,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EwR(bxInstruction_c *i) bit0 = (op1_16 & 0x1); bit15 = (op1_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(bit0 ^ bit15, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit15, bit0); } } else { @@ -282,7 +282,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EwR(bxInstruction_c *i) bit0 = (result_16 & 0x1); bit15 = (result_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(bit0 ^ bit15, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit15, bit0); } BX_NEXT_INSTR(i); @@ -307,7 +307,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EwM(bxInstruction_c *i) bit14 = (op1_16 >> 14) & 1; bit15 = (op1_16 >> 15) & 1; // of = result14 ^ result15 - SET_FLAGS_OxxxxC(bit14 ^ bit15, bit15); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit14 ^ bit15, bit15); } } else { @@ -320,7 +320,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EwM(bxInstruction_c *i) bit14 = (result_16 >> 14) & 1; bit15 = (result_16 >> 15) & 1; // of = result14 ^ result15 - SET_FLAGS_OxxxxC(bit14 ^ bit15, bit15); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit14 ^ bit15, bit15); } BX_NEXT_INSTR(i); @@ -343,7 +343,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EwR(bxInstruction_c *i) bit14 = (op1_16 >> 14) & 1; bit15 = (op1_16 >> 15) & 1; // of = result14 ^ result15 - SET_FLAGS_OxxxxC(bit14 ^ bit15, bit15); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit14 ^ bit15, bit15); } } else { @@ -356,7 +356,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EwR(bxInstruction_c *i) bit14 = (result_16 >> 14) & 1; bit15 = (result_16 >> 15) & 1; // of = result14 ^ result15 - SET_FLAGS_OxxxxC(bit14 ^ bit15, bit15); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit14 ^ bit15, bit15); } BX_NEXT_INSTR(i); @@ -397,7 +397,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EwM(bxInstruction_c *i) cf = (op1_16 >> (16 - count)) & 0x1; of = cf ^ (result_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -436,7 +436,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EwR(bxInstruction_c *i) cf = (op1_16 >> (16 - count)) & 0x1; of = cf ^ (result_16 >> 15); // of = cf ^ result15 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -468,7 +468,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EwM(bxInstruction_c *i) cf = (op1_16 >> (count - 1)) & 0x1; of = ((Bit16u)((result_16 << 1) ^ result_16) >> 15) & 0x1; // of = result15 ^ result14 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -498,7 +498,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EwR(bxInstruction_c *i) cf = (op1_16 >> (count - 1)) & 0x1; of = ((Bit16u)((result_16 << 1) ^ result_16) >> 15) & 0x1; // of = result15 ^ result14 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -534,7 +534,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EwM(bxInstruction_c *i) write_RMW_linear_word(result_16); SET_FLAGS_OSZAPC_LOGIC_16(result_16); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -568,7 +568,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EwR(bxInstruction_c *i) BX_WRITE_16BIT_REG(i->dst(), result_16); SET_FLAGS_OSZAPC_LOGIC_16(result_16); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -601,7 +601,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EwM(bxInstruction_c *i) of = ((Bit16u)((result_16 << 1) ^ result_16) >> 15) & 0x1; SET_FLAGS_OSZAPC_LOGIC_16(result_16); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -630,7 +630,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EwR(bxInstruction_c *i) of = ((Bit16u)((result_16 << 1) ^ result_16) >> 15) & 0x1; SET_FLAGS_OSZAPC_LOGIC_16(result_16); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -657,7 +657,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EwM(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_16(result_16); /* signed overflow cannot happen in SAR instruction */ - SET_FLAGS_OxxxxC(0, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); write_RMW_linear_word(result_16); } @@ -685,7 +685,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EwR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_16(result_16); /* signed overflow cannot happen in SAR instruction */ - SET_FLAGS_OxxxxC(0, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/shift32.cc b/bochs/cpu/shift32.cc index 7b5f727f3..0ad7995bf 100644 --- a/bochs/cpu/shift32.cc +++ b/bochs/cpu/shift32.cc @@ -51,7 +51,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHLD_EdGdM(bxInstruction_c *i) cf = (op1_32 >> (32 - count)) & 0x1; of = cf ^ (result_32 >> 31); // of = cf ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -85,7 +85,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHLD_EdGdR(bxInstruction_c *i) cf = (op1_32 >> (32 - count)) & 0x1; of = cf ^ (result_32 >> 31); // of = cf ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -118,7 +118,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EdGdM(bxInstruction_c *i) cf = (op1_32 >> (count - 1)) & 0x1; of = ((result_32 << 1) ^ result_32) >> 31; // of = result30 ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -152,7 +152,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EdGdR(bxInstruction_c *i) cf = (op1_32 >> (count - 1)) & 0x1; of = ((result_32 << 1) ^ result_32) >> 31; // of = result30 ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -181,7 +181,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EdM(bxInstruction_c *i) unsigned bit0 = (result_32 & 0x1); unsigned bit31 = (result_32 >> 31); // of = cf ^ result31 - SET_FLAGS_OxxxxC(bit0 ^ bit31, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit31, bit0); } BX_NEXT_INSTR(i); @@ -211,7 +211,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EdR(bxInstruction_c *i) bit0 = (result_32 & 0x1); bit31 = (result_32 >> 31); // of = cf ^ result31 - SET_FLAGS_OxxxxC(bit0 ^ bit31, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit31, bit0); } BX_NEXT_INSTR(i); @@ -241,7 +241,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EdM(bxInstruction_c *i) bit31 = (result_32 >> 31) & 1; bit30 = (result_32 >> 30) & 1; // of = result30 ^ result31 - SET_FLAGS_OxxxxC(bit30 ^ bit31, bit31); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit30 ^ bit31, bit31); } BX_NEXT_INSTR(i); @@ -271,7 +271,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EdR(bxInstruction_c *i) bit31 = (result_32 >> 31) & 1; bit30 = (result_32 >> 30) & 1; // of = result30 ^ result31 - SET_FLAGS_OxxxxC(bit30 ^ bit31, bit31); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit30 ^ bit31, bit31); } BX_NEXT_INSTR(i); @@ -311,7 +311,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EdM(bxInstruction_c *i) cf = (op1_32 >> (32 - count)) & 0x1; of = cf ^ (result_32 >> 31); // of = cf ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -349,7 +349,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EdR(bxInstruction_c *i) cf = (op1_32 >> (32 - count)) & 0x1; of = cf ^ (result_32 >> 31); // of = cf ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -389,7 +389,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EdM(bxInstruction_c *i) cf = (op1_32 >> (count - 1)) & 0x1; of = ((result_32 << 1) ^ result_32) >> 31; // of = result30 ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -428,7 +428,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EdR(bxInstruction_c *i) cf = (op1_32 >> (count - 1)) & 0x1; of = ((result_32 << 1) ^ result_32) >> 31; // of = result30 ^ result31 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -458,7 +458,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EdM(bxInstruction_c *i) cf = (op1_32 >> (32 - count)) & 0x1; of = cf ^ (result_32 >> 31); SET_FLAGS_OSZAPC_LOGIC_32(result_32); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -490,7 +490,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EdR(bxInstruction_c *i) unsigned of = cf ^ (result_32 >> 31); SET_FLAGS_OSZAPC_LOGIC_32(result_32); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -522,7 +522,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EdM(bxInstruction_c *i) unsigned of = ((result_32 << 1) ^ result_32) >> 31; SET_FLAGS_OSZAPC_LOGIC_32(result_32); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -553,7 +553,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EdR(bxInstruction_c *i) unsigned of = ((result_32 << 1) ^ result_32) >> 31; SET_FLAGS_OSZAPC_LOGIC_32(result_32); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -582,7 +582,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EdM(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_32(result_32); unsigned cf = (op1_32 >> (count - 1)) & 1; - SET_FLAGS_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ } BX_NEXT_INSTR(i); @@ -612,7 +612,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EdR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_32(result_32); unsigned cf = (op1_32 >> (count - 1)) & 1; - SET_FLAGS_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/shift64.cc b/bochs/cpu/shift64.cc index 6b94f9b3b..caef79d8d 100644 --- a/bochs/cpu/shift64.cc +++ b/bochs/cpu/shift64.cc @@ -55,7 +55,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHLD_EqGqM(bxInstruction_c *i) cf = (op1_64 >> (64 - count)) & 0x1; of = cf ^ (result_64 >> 63); // of = cf ^ result63 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -86,7 +86,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHLD_EqGqR(bxInstruction_c *i) cf = (op1_64 >> (64 - count)) & 0x1; of = cf ^ (result_64 >> 63); // of = cf ^ result63 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -121,7 +121,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EqGqM(bxInstruction_c *i) cf = (op1_64 >> (count - 1)) & 0x1; of = ((result_64 << 1) ^ result_64) >> 63; // of = result62 ^ result63 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -152,7 +152,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHRD_EqGqR(bxInstruction_c *i) cf = (op1_64 >> (count - 1)) & 0x1; of = ((result_64 << 1) ^ result_64) >> 63; // of = result62 ^ result63 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -181,7 +181,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EqM(bxInstruction_c *i) unsigned bit0 = (result_64 & 0x1); unsigned bit63 = (result_64 >> 63); // of = cf ^ result63 - SET_FLAGS_OxxxxC(bit0 ^ bit63, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit63, bit0); } BX_NEXT_INSTR(i); @@ -206,7 +206,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EqR(bxInstruction_c *i) unsigned bit0 = (result_64 & 0x1); unsigned bit63 = (result_64 >> 63); // of = cf ^ result63 - SET_FLAGS_OxxxxC(bit0 ^ bit63, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit63, bit0); } BX_NEXT_INSTR(i); @@ -235,7 +235,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EqM(bxInstruction_c *i) unsigned bit63 = (result_64 >> 63) & 1; unsigned bit62 = (result_64 >> 62) & 1; // of = result62 ^ result63 - SET_FLAGS_OxxxxC(bit62 ^ bit63, bit63); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit62 ^ bit63, bit63); } BX_NEXT_INSTR(i); @@ -260,7 +260,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EqR(bxInstruction_c *i) unsigned bit63 = (result_64 >> 63) & 1; unsigned bit62 = (result_64 >> 62) & 1; // of = result62 ^ result63 - SET_FLAGS_OxxxxC(bit62 ^ bit63, bit63); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit62 ^ bit63, bit63); } BX_NEXT_INSTR(i); @@ -301,7 +301,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EqM(bxInstruction_c *i) cf = (op1_64 >> (64 - count)) & 0x1; of = cf ^ (result_64 >> 63); // of = cf ^ result63 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -339,7 +339,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EqR(bxInstruction_c *i) cf = (op1_64 >> (64 - count)) & 0x1; of = cf ^ (result_64 >> 63); // of = cf ^ result63 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -379,7 +379,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EqM(bxInstruction_c *i) cf = (op1_64 >> (count - 1)) & 0x1; of = ((result_64 << 1) ^ result_64) >> 63; - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -417,7 +417,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EqR(bxInstruction_c *i) cf = (op1_64 >> (count - 1)) & 0x1; of = ((result_64 << 1) ^ result_64) >> 63; - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -447,7 +447,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EqM(bxInstruction_c *i) write_RMW_linear_qword(result_64); SET_FLAGS_OSZAPC_LOGIC_64(result_64); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -475,7 +475,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EqR(bxInstruction_c *i) cf = (op1_64 >> (64 - count)) & 0x1; of = cf ^ (result_64 >> 63); SET_FLAGS_OSZAPC_LOGIC_64(result_64); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -507,7 +507,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EqM(bxInstruction_c *i) unsigned of = ((result_64 << 1) ^ result_64) >> 63; SET_FLAGS_OSZAPC_LOGIC_64(result_64); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -535,7 +535,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EqR(bxInstruction_c *i) unsigned of = ((result_64 << 1) ^ result_64) >> 63; SET_FLAGS_OSZAPC_LOGIC_64(result_64); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -564,7 +564,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EqM(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_64(result_64); unsigned cf = (op1_64 >> (count - 1)) & 1; - SET_FLAGS_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ } BX_NEXT_INSTR(i); @@ -591,7 +591,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EqR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_64(result_64); unsigned cf = (op1_64 >> (count - 1)) & 1; - SET_FLAGS_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); /* signed overflow cannot happen in SAR instruction */ } BX_NEXT_INSTR(i); diff --git a/bochs/cpu/shift8.cc b/bochs/cpu/shift8.cc index ef45b5311..ca939a412 100644 --- a/bochs/cpu/shift8.cc +++ b/bochs/cpu/shift8.cc @@ -40,7 +40,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EbR(bxInstruction_c *i) if (count & 0x18) { bit0 = (op1_8 & 1); bit7 = (op1_8 >> 7); - SET_FLAGS_OxxxxC(bit0 ^ bit7, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit7, bit0); } } else { @@ -56,7 +56,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EbR(bxInstruction_c *i) bit0 = (result_8 & 1); bit7 = (result_8 >> 7); - SET_FLAGS_OxxxxC(bit0 ^ bit7, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit7, bit0); } BX_NEXT_INSTR(i); @@ -80,7 +80,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EbM(bxInstruction_c *i) if (count & 0x18) { bit0 = (op1_8 & 1); bit7 = (op1_8 >> 7); - SET_FLAGS_OxxxxC(bit0 ^ bit7, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit7, bit0); } } else { @@ -96,7 +96,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROL_EbM(bxInstruction_c *i) bit0 = (result_8 & 1); bit7 = (result_8 >> 7); - SET_FLAGS_OxxxxC(bit0 ^ bit7, bit0); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit0 ^ bit7, bit0); } BX_NEXT_INSTR(i); @@ -119,7 +119,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EbR(bxInstruction_c *i) bit6 = (op1_8 >> 6) & 1; bit7 = (op1_8 >> 7) & 1; - SET_FLAGS_OxxxxC(bit6 ^ bit7, bit7); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit6 ^ bit7, bit7); } } else { @@ -135,7 +135,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EbR(bxInstruction_c *i) bit6 = (result_8 >> 6) & 1; bit7 = (result_8 >> 7) & 1; - SET_FLAGS_OxxxxC(bit6 ^ bit7, bit7); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit6 ^ bit7, bit7); } BX_NEXT_INSTR(i); @@ -160,7 +160,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EbM(bxInstruction_c *i) bit6 = (op1_8 >> 6) & 1; bit7 = (op1_8 >> 7) & 1; - SET_FLAGS_OxxxxC(bit6 ^ bit7, bit7); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit6 ^ bit7, bit7); } } else { @@ -176,7 +176,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::ROR_EbM(bxInstruction_c *i) bit6 = (result_8 >> 6) & 1; bit7 = (result_8 >> 7) & 1; - SET_FLAGS_OxxxxC(bit6 ^ bit7, bit7); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(bit6 ^ bit7, bit7); } BX_NEXT_INSTR(i); @@ -215,7 +215,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EbR(bxInstruction_c *i) cf = (op1_8 >> (8 - count)) & 0x01; of = cf ^ (result_8 >> 7); // of = cf ^ result7 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -255,7 +255,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCL_EbM(bxInstruction_c *i) cf = (op1_8 >> (8 - count)) & 0x01; of = cf ^ (result_8 >> 7); // of = cf ^ result7 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -284,7 +284,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EbR(bxInstruction_c *i) cf = (op1_8 >> (count - 1)) & 0x1; of = (((result_8 << 1) ^ result_8) >> 7) & 0x1; // of = result6 ^ result7 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -316,7 +316,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RCR_EbM(bxInstruction_c *i) cf = (op1_8 >> (count - 1)) & 0x1; of = (((result_8 << 1) ^ result_8) >> 7) & 0x1; // of = result6 ^ result7 - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -353,7 +353,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EbR(bxInstruction_c *i) BX_WRITE_8BIT_REGx(i->dst(), i->extend8bitL(), result_8); SET_FLAGS_OSZAPC_LOGIC_8(result_8); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -391,7 +391,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHL_EbM(bxInstruction_c *i) write_RMW_linear_byte(result_8); SET_FLAGS_OSZAPC_LOGIC_8(result_8); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); BX_NEXT_INSTR(i); } @@ -418,7 +418,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EbR(bxInstruction_c *i) unsigned of = (((result_8 << 1) ^ result_8) >> 7) & 0x1; SET_FLAGS_OSZAPC_LOGIC_8(result_8); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -450,7 +450,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SHR_EbM(bxInstruction_c *i) unsigned of = (((result_8 << 1) ^ result_8) >> 7) & 0x1; SET_FLAGS_OSZAPC_LOGIC_8(result_8); - SET_FLAGS_OxxxxC(of, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(of, cf); } BX_NEXT_INSTR(i); @@ -476,7 +476,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EbR(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_8(result_8); /* signed overflow cannot happen in SAR instruction */ - SET_FLAGS_OxxxxC(0, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); } BX_NEXT_INSTR(i); @@ -506,7 +506,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::SAR_EbM(bxInstruction_c *i) SET_FLAGS_OSZAPC_LOGIC_8(result_8); /* signed overflow cannot happen in SAR instruction */ - SET_FLAGS_OxxxxC(0, cf); + BX_CPU_THIS_PTR oszapc.set_flags_OxxxxC(0, cf); } BX_NEXT_INSTR(i);