tms34020: Fix BLMOVE aligment handling

BLMOVE has actually 4 different cases of execution based on two lowest
bits in opcode, which were not properly handled.

Fixes endless loop in atronic / atricmon.
This commit is contained in:
Priit Laes 2019-08-25 16:04:11 +03:00
parent 56326e9fe8
commit 54090f08d0

View file

@ -2050,9 +2050,14 @@ void tms340x0_device::blmove(uint16_t op)
if (!m_is_34020) { unimpl(op); return; }
/* src and dst are aligned */
if (!(src & 0x0f) && !(dst & 0x0f))
{
bool S = op & (1 << 1);
bool D = op & (1 << 0);
if ((S == false && (src & 0xf)) || (D == false && (dst & 0xf))) {
logerror("020:BLMOVE alignment error: PC=%x: S=%d, D=%d, src=%x, dst=%x, bits=%d\n", m_pc, S, D, src, dst, bits);
}
// logerror("020:BLMOVE: PC=%x: S=%d, D=%d, src=%x, dst=%x, bits=%d\n", m_pc, S, D, src, dst, bits);
while (bits >= 16 && m_icount > 0)
{
TMS34010_WRMEM_WORD(dst, TMS34010_RDMEM_WORD(src));
@ -2069,31 +2074,19 @@ void tms340x0_device::blmove(uint16_t op)
bits = 0;
m_icount -= 2;
}
}
/* src is aligned, dst is not */
else if (!(src & 0x0f))
{
logerror("020:BLMOVE with aligned src and unaligned dst\n");
}
/*
TODO: We do not currently emulate precisely how B0 and B2 are modified during the operation:
if D == 0, then B0 and B2 remain fixed during execution and are only incremented after operation completes.
if D == 1, then B2 is incremented during move, B0 remains fixed until operation completes.
*/
/* dst is aligned, src is not */
else if (!(dst & 0x0f))
{
logerror("020:BLMOVE with unaligned src and aligned dst\n");
}
/* neither are aligned */
else
{
logerror("020:BLMOVE with completely unaligned src and dst\n");
}
/* update the final results */
BREG(0) = src;
BREG(2) = dst;
BREG(7) = bits;
// logerror("020:BLMOVE: PC=%x: finished: B0=%x, B2=%x, B7=%d\n", m_pc, src, dst, bits);
/* if we're not done yet, back up the PC */
if (bits != 0)
m_pc -= 0x10;