From 0006fba49565386afa9b66d9fb8e02f744cf7cdb Mon Sep 17 00:00:00 2001 From: AJR Date: Wed, 8 Nov 2023 23:15:34 -0500 Subject: mb86233: Use util::sext for sign extension --- src/devices/cpu/mb86233/mb86233.cpp | 32 ++++++++------------------------ src/devices/cpu/mb86233/mb86233.h | 1 - 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/src/devices/cpu/mb86233/mb86233.cpp b/src/devices/cpu/mb86233/mb86233.cpp index 441fc521eff..6a5451c0095 100644 --- a/src/devices/cpu/mb86233/mb86233.cpp +++ b/src/devices/cpu/mb86233/mb86233.cpp @@ -222,14 +222,6 @@ void mb86233_device::device_reset() m_stall = false; } -s32 mb86233_device::s24_32(u32 val) -{ - if(val & 0x00800000) - return val | 0xff000000; - else - return val & 0x00ffffff; -} - u32 mb86233_device::set_exp(u32 val, u32 exp) { return (val & 0x807fffff) | ((exp & 0xff) << 23); @@ -571,12 +563,8 @@ void mb86233_device::ea_post_0(u32 r) return; if(!(r & 0x080)) m_x0 += m_i0; - else { - if(r & 0x10) - m_x0 += (r & 0xf) - 0x10; - else - m_x0 += r & 0xf; - } + else + m_x0 += util::sext(r, 5); } u16 mb86233_device::ea_pre_1(u32 r) @@ -602,12 +590,8 @@ void mb86233_device::ea_post_1(u32 r) return; if(!(r & 0x080)) m_x1 += m_i1; - else { - if(r & 0x10) - m_x1 += (r & 0xf) - 0x10; - else - m_x1 += r & 0xf; - } + else + m_x1 += util::sext(r, 5); } u32 mb86233_device::read_reg(u32 r) @@ -992,13 +976,13 @@ void mb86233_device::execute_run() m_p = (m_p & 0xffffff000000) | (opcode & 0xffffff); break; case 1: - m_a = s24_32(opcode); + m_a = util::sext(opcode, 24); break; case 2: - m_b = s24_32(opcode); + m_b = util::sext(opcode, 24); break; case 3: - m_d = s24_32(opcode); + m_d = util::sext(opcode, 24); testdz(); break; } @@ -1049,7 +1033,7 @@ void mb86233_device::execute_run() case 0x10: case 0x11: case 0x12: case 0x13: case 0x14: case 0x15: case 0x16: case 0x17: case 0x18: case 0x19: case 0x1a: case 0x1b: case 0x1c: case 0x1d: case 0x1e: case 0x1f: { // ldi - write_reg(opcode >> 24, s24_32(opcode)); + write_reg(opcode >> 24, util::sext(opcode, 24)); break; } diff --git a/src/devices/cpu/mb86233/mb86233.h b/src/devices/cpu/mb86233/mb86233.h index e421aa21652..34dac1407c0 100644 --- a/src/devices/cpu/mb86233/mb86233.h +++ b/src/devices/cpu/mb86233/mb86233.h @@ -105,7 +105,6 @@ private: bool m_stall; - static s32 s24_32(u32 val); static u32 set_exp(u32 val, u32 exp); static u32 set_mant(u32 val, u32 mant); static u32 get_exp(u32 val); -- cgit v1.2.3