From a251ccf3d6ab6de6b55398d179f9319750f4f219 Mon Sep 17 00:00:00 2001 From: thrust26 Date: Mon, 25 Feb 2019 19:50:33 +0100 Subject: [PATCH] another small unsafe optimization --- src/emucore/Thumbulator.cxx | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/src/emucore/Thumbulator.cxx b/src/emucore/Thumbulator.cxx index 9a3198d2b..98276125a 100644 --- a/src/emucore/Thumbulator.cxx +++ b/src/emucore/Thumbulator.cxx @@ -527,7 +527,7 @@ void Thumbulator::do_zflag(uInt32 x) // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void Thumbulator::do_nflag(uInt32 x) { - if(x & 0x80000000) cpsr|=CPSR_N; else cpsr&=~CPSR_N; + if(x & 0x80000000) cpsr |= CPSR_N; else cpsr &= ~CPSR_N; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1688,7 +1688,11 @@ int Thumbulator::execute() rb = (inst >> 6) & 0x1F; DO_DISS(statusMsg << "ldrb r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl); rb = read_register(rn) + rb; +#ifndef UNSAFE_OPTIMIZATIONS rc = read16(rb & (~1u)); +#else + rc = read16(rb); +#endif if(rb & 1) { rc >>= 8; @@ -1707,14 +1711,15 @@ int Thumbulator::execute() rm = (inst >> 6) & 0x7; DO_DISS(statusMsg << "ldrb r" << dec << rd << ",[r" << dec << rn << ",r" << dec << rm << "]" << endl); rb = read_register(rn) + read_register(rm); +#ifndef UNSAFE_OPTIMIZATIONS rc = read16(rb & (~1u)); +#else + rc = read16(rb); +#endif if(rb & 1) { rc >>= 8; } - else - { - } write_register(rd, rc & 0xFF); return 0; } @@ -1726,7 +1731,7 @@ int Thumbulator::execute() rb = (inst >> 6) & 0x1F; rb <<= 1; DO_DISS(statusMsg << "ldrh r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX2 << rb << "]" << endl); - rb=read_register(rn) + rb; + rb = read_register(rn) + rb; rc = read16(rb); write_register(rd, rc & 0xFFFF); return 0; @@ -1751,14 +1756,15 @@ int Thumbulator::execute() rm = (inst >> 6) & 0x7; DO_DISS(statusMsg << "ldrsb r" << dec << rd << ",[r" << dec << rn << ",r" << dec << rm << "]" << endl); rb = read_register(rn) + read_register(rm); +#ifndef UNSAFE_OPTIMIZATIONS rc = read16(rb & (~1u)); +#else + rc = read16(rb); +#endif if(rb & 1) { rc >>= 8; } - else - { - } rc &= 0xFF; if(rc & 0x80) rc |= ((~0u) << 8); @@ -2275,7 +2281,11 @@ int Thumbulator::execute() DO_DISS(statusMsg << "strb r" << dec << rd << ",[r" << dec << rn << ",#0x" << Base::HEX8 << rb << "]" << endl); rb = read_register(rn) + rb; rc = read_register(rd); +#ifndef UNSAFE_OPTIMIZATIONS ra = read16(rb & (~1u)); +#else + ra = read16(rb); +#endif if(rb & 1) { ra &= 0x00FF; @@ -2298,7 +2308,11 @@ int Thumbulator::execute() DO_DISS(statusMsg << "strb r" << dec << rd << ",[r" << dec << rn << ",r" << rm << "]" << endl); rb = read_register(rn) + read_register(rm); rc = read_register(rd); +#ifndef UNSAFE_OPTIMIZATIONS ra = read16(rb & (~1u)); +#else + ra = read16(rb); +#endif if(rb & 1) { ra &= 0x00FF;