From 0a58d76509d8e97e93e078fd3289539415790dbf Mon Sep 17 00:00:00 2001 From: hap Date: Thu, 15 Dec 2022 13:35:57 +0100 Subject: [PATCH] m6809/konami: no need for those safe_shift functions --- src/devices/cpu/m6809/konami.cpp | 52 ----------------------------- src/devices/cpu/m6809/konami.h | 3 -- src/devices/cpu/m6809/konami.ops | 56 ++++++++++++-------------------- 3 files changed, 20 insertions(+), 91 deletions(-) diff --git a/src/devices/cpu/m6809/konami.cpp b/src/devices/cpu/m6809/konami.cpp index 806d2620bfb..afcc4b2feef 100644 --- a/src/devices/cpu/m6809/konami.cpp +++ b/src/devices/cpu/m6809/konami.cpp @@ -237,58 +237,6 @@ inline void konami_cpu_device::write_exgtfr_register(uint8_t reg, uint16_t value } -//------------------------------------------------- -// safe_shift_right -//------------------------------------------------- - -template T konami_cpu_device::safe_shift_right(T value, uint32_t shift) -{ - T result; - - if (shift < (sizeof(T) * 8)) - result = value >> shift; - else if (value < 0) - result = (T) -1; - else - result = 0; - - return result; -} - - -//------------------------------------------------- -// safe_shift_right_unsigned -//------------------------------------------------- - -template T konami_cpu_device::safe_shift_right_unsigned(T value, uint32_t shift) -{ - T result; - - if (shift < (sizeof(T) * 8)) - result = value >> shift; - else - result = 0; - - return result; -} - -//------------------------------------------------- -// safe_shift_left -//------------------------------------------------- - -template T konami_cpu_device::safe_shift_left(T value, uint32_t shift) -{ - T result; - - if (shift < (sizeof(T) * 8)) - result = value << shift; - else - result = 0; - - return result; -} - - //------------------------------------------------- // lmul //------------------------------------------------- diff --git a/src/devices/cpu/m6809/konami.h b/src/devices/cpu/m6809/konami.h index e5acdef5b39..a73464dbcb1 100644 --- a/src/devices/cpu/m6809/konami.h +++ b/src/devices/cpu/m6809/konami.h @@ -64,9 +64,6 @@ private: void divx(); // miscellaneous - template T safe_shift_right(T value, uint32_t shift); - template T safe_shift_right_unsigned(T value, uint32_t shift); - template T safe_shift_left(T value, uint32_t shift); void set_lines(uint8_t data); void execute_one(); diff --git a/src/devices/cpu/m6809/konami.ops b/src/devices/cpu/m6809/konami.ops index 2009bdc060f..3dc1b919bc3 100644 --- a/src/devices/cpu/m6809/konami.ops +++ b/src/devices/cpu/m6809/konami.ops @@ -521,19 +521,15 @@ LSRD: @m_temp.b.h = read_operand(0); @m_temp.b.l = read_operand(1); - if (m_bcount != 0x00) + while(m_bcount--) { - // set C condition code - if (m_temp.w & safe_shift_left(1, m_bcount - 1)) - m_cc |= CC_C; - else - m_cc &= ~CC_C; - - m_temp.w = set_flags(CC_NZ, safe_shift_right_unsigned(m_temp.w, m_bcount)); - @write_operand(0, m_temp.b.h); - write_operand(1, m_temp.b.l); + @eat(1); + m_cc &= ~CC_C; + m_cc |= (m_temp.w & 1) ? CC_C : 0; + m_temp.w = set_flags(CC_NZ, m_temp.w >> 1); } - eat(m_bcount); + @write_operand(0, m_temp.b.h); + write_operand(1, m_temp.b.l); return; ASLD: @@ -546,19 +542,13 @@ ASLD: @m_temp.b.h = read_operand(0); @m_temp.b.l = read_operand(1); - if (m_bcount != 0x00) + while(m_bcount--) { - // set C condition code - if (m_temp.w & safe_shift_right(0x10000, m_bcount)) - m_cc |= CC_C; - else - m_cc &= ~CC_C; - - m_temp.w = set_flags(CC_NZV, safe_shift_left(m_temp.w, m_bcount)); - @write_operand(0, m_temp.b.h); - write_operand(1, m_temp.b.l); + @eat(1); + m_temp.w = set_flags(CC_NZVC, m_temp.w, m_temp.w, m_temp.w << 1); } - eat(m_bcount); + @write_operand(0, m_temp.b.h); + write_operand(1, m_temp.b.l); return; ASRD: @@ -571,19 +561,15 @@ ASRD: @m_temp.b.h = read_operand(0); @m_temp.b.l = read_operand(1); - if (m_bcount != 0x00) + while(m_bcount--) { - // set C condition code - if (m_temp.w & safe_shift_left(1, m_bcount - 1)) - m_cc |= CC_C; - else - m_cc &= ~CC_C; - - m_temp.w = set_flags(CC_NZ, safe_shift_right(m_temp.w, m_bcount)); - @write_operand(0, m_temp.b.h); - write_operand(1, m_temp.b.l); + @eat(1); + m_cc &= ~CC_C; + m_cc |= (m_temp.w & 1) ? CC_C : 0; + m_temp.w = set_flags(CC_NZ, ((int16_t) m_temp.w) >> 1); } - eat(m_bcount); + @write_operand(0, m_temp.b.h); + write_operand(1, m_temp.b.l); return; ROLD: @@ -596,11 +582,10 @@ ROLD: @m_temp.b.h = read_operand(0); @m_temp.b.l = read_operand(1); - // doing this as a loop is lame while(m_bcount--) { @eat(1); - m_temp.w = set_flags(CC_NZ, rotate_left(m_temp.w)); + m_temp.w = set_flags(CC_NZV, rotate_left(m_temp.w)); } @write_operand(0, m_temp.b.h); write_operand(1, m_temp.b.l); @@ -616,7 +601,6 @@ RORD: @m_temp.b.h = read_operand(0); @m_temp.b.l = read_operand(1); - // doing this as a loop is lame while(m_bcount--) { @eat(1);