summaryrefslogtreecommitdiffstatshomepage
path: root/src/devices/cpu/m88000/m88000.cpp
diff options
context:
space:
mode:
author Patrick Mackinlay <pmackinlay@hotmail.com>2023-03-22 13:54:59 +0700
committer Patrick Mackinlay <pmackinlay@hotmail.com>2023-03-22 13:54:59 +0700
commitdbd21411413ce4e4ad45421a8272ae9fe8f0d683 (patch)
tree7810f2f64f9f1779e4b6df71c4d5162e68b1bb23 /src/devices/cpu/m88000/m88000.cpp
parent4113b4c75b8d79027bd0c80c219fd00ca2a7d393 (diff)
m88000: fix doubleword load/store word order
Diffstat (limited to 'src/devices/cpu/m88000/m88000.cpp')
-rw-r--r--src/devices/cpu/m88000/m88000.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/devices/cpu/m88000/m88000.cpp b/src/devices/cpu/m88000/m88000.cpp
index 26d17fb302c..deae133b1bd 100644
--- a/src/devices/cpu/m88000/m88000.cpp
+++ b/src/devices/cpu/m88000/m88000.cpp
@@ -564,7 +564,7 @@ void mc88100_device::execute(u32 const inst)
unsigned const offset = inst & 31;
if (width && (width + offset) < 32)
- m_r[D] = s32(m_r[S1] << (32 - (width + offset))) >> (32 - width);
+ m_r[D] = util::sext(m_r[S1] >> offset, width);
else
m_r[D] = s32(m_r[S1]) >> offset;
}
@@ -884,7 +884,7 @@ void mc88100_device::execute(u32 const inst)
// bit field register
case 0x400: // clr: clear bit field (register)
{
- unsigned const width = (m_r[S2] >> 5) & 31;
+ unsigned const width = BIT(m_r[S2], 5, 5);
unsigned const offset = m_r[S2] & 31;
m_r[D] = m_r[S1] & ~(make_bitmask<u32>(width ? width : 32) << offset);
@@ -892,7 +892,7 @@ void mc88100_device::execute(u32 const inst)
break;
case 0x440: // set: set bit field (register)
{
- unsigned const width = (m_r[S2] >> 5) & 31;
+ unsigned const width = BIT(m_r[S2], 5, 5);
unsigned const offset = m_r[S2] & 31;
m_r[D] = m_r[S1] | (make_bitmask<u32>(width ? width : 32) << offset);
@@ -900,18 +900,18 @@ void mc88100_device::execute(u32 const inst)
break;
case 0x480: // ext: extract signed bit field (register)
{
- unsigned const width = (m_r[S2] >> 5) & 31;
+ unsigned const width = BIT(m_r[S2], 5, 5);
unsigned const offset = m_r[S2] & 31;
if (width && (width + offset) < 32)
- m_r[D] = s32(m_r[S1] << (32 - (width + offset))) >> (32 - width);
+ m_r[D] = util::sext(m_r[S1] >> offset, width);
else
m_r[D] = s32(m_r[S1]) >> offset;
}
break;
case 0x4c0: // extu: extract unsigned bit field (register)
{
- unsigned const width = (m_r[S2] >> 5) & 31;
+ unsigned const width = BIT(m_r[S2], 5, 5);
unsigned const offset = m_r[S2] & 31;
if (width)
@@ -922,7 +922,7 @@ void mc88100_device::execute(u32 const inst)
break;
case 0x500: // mak: make bit field (register)
{
- unsigned const width = (m_r[S2] >> 5) & 31;
+ unsigned const width = BIT(m_r[S2], 5, 5);
unsigned const offset = m_r[S2] & 31;
if (width)
@@ -1473,8 +1473,8 @@ template <typename T> void mc88100_device::ld(u32 address, unsigned const reg)
}
else
{
- std::optional<u32> const lo = m_cmmu_d->read<u32>(address + 0, m_cr[PSR] & PSR_MODE);
- std::optional<u32> const hi = m_cmmu_d->read<u32>(address + 4, m_cr[PSR] & PSR_MODE);
+ std::optional<u32> const hi = m_cmmu_d->read<u32>(address + 0, m_cr[PSR] & PSR_MODE);
+ std::optional<u32> const lo = m_cmmu_d->read<u32>(address + 4, m_cr[PSR] & PSR_MODE);
if (lo.has_value() && hi.has_value())
{
if (reg != 0)
@@ -1511,12 +1511,13 @@ template <typename T> void mc88100_device::ld(u32 address, unsigned const reg)
}
else if constexpr (sizeof(T) == 8)
{
- u64 const data = m_data_space.read_qword(address);
+ u32 const hi = m_data_space.read_dword(address + 0);
+ u32 const lo = m_data_space.read_dword(address + 4);
if (reg != 0)
- m_r[(reg + 0) & 31] = u32(data >> 32);
+ m_r[(reg + 0) & 31] = hi;
if (reg != 31)
- m_r[(reg + 1) & 31] = u32(data >> 0);
+ m_r[(reg + 1) & 31] = lo;
}
}
}
@@ -1550,8 +1551,8 @@ template <typename T> bool mc88100_device::st(u32 address, unsigned const reg)
else
{
bool result = true;
- result &= m_cmmu_d->write(address + 0, m_r[(reg + 1) & 31], m_cr[PSR] & PSR_MODE);
- result &= m_cmmu_d->write(address + 4, m_r[(reg + 0) & 31], m_cr[PSR] & PSR_MODE);
+ result &= m_cmmu_d->write(address + 0, m_r[(reg + 0) & 31], m_cr[PSR] & PSR_MODE);
+ result &= m_cmmu_d->write(address + 4, m_r[(reg + 1) & 31], m_cr[PSR] & PSR_MODE);
if (!result)
exception(E_DATA);
@@ -1568,7 +1569,10 @@ template <typename T> bool mc88100_device::st(u32 address, unsigned const reg)
else if constexpr (sizeof(T) == 4)
m_data_space.write_dword(address, m_r[reg]);
else if constexpr (sizeof(T) == 8)
- m_data_space.write_qword(address, (u64(m_r[(reg + 0) & 31]) << 32) | m_r[(reg + 1) & 31]);
+ {
+ m_data_space.write_dword(address + 0, m_r[(reg + 0) & 31]);
+ m_data_space.write_dword(address + 4, m_r[(reg + 1) & 31]);
+ }
return true;
}