diff options
author | 2024-03-24 22:46:26 +0100 | |
---|---|---|
committer | 2024-03-25 14:27:44 +0100 | |
commit | 5abb7f4df29ca67be124e242266b6a4c3ccca2bd (patch) | |
tree | 083eb244694214a3231cb32d0cff5fedc26e56d6 | |
parent | d790d8e0a94d8435be1dd427904e0ed303057d3e (diff) |
avr8: fix SBIW V flag once more
(cherry picked from commit 6517b66f3e9f3be8d709872652432eab541b709e)
-rw-r--r-- | src/devices/cpu/avr8/avr8ops.hxx | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/devices/cpu/avr8/avr8ops.hxx b/src/devices/cpu/avr8/avr8ops.hxx index 0ac10342616..614adac97b5 100644 --- a/src/devices/cpu/avr8/avr8ops.hxx +++ b/src/devices/cpu/avr8/avr8ops.hxx @@ -1234,10 +1234,10 @@ void avr8_base_device::op_adiw(uint16_t op) if (BIT(pd, 15)) { m_r[SREG] |= SREG_MASK_N; - if (!BIT(rr, 7)) - m_r[SREG] |= SREG_MASK_V; - else + if (BIT(rr, 7)) m_r[SREG] |= SREG_MASK_S; + else + m_r[SREG] |= SREG_MASK_V; } else { @@ -1258,14 +1258,17 @@ void avr8_base_device::op_sbiw(uint16_t op) m_r[SREG] &= ~(SREG_MASK_V | SREG_MASK_N | SREG_MASK_S | SREG_MASK_Z | SREG_MASK_C); if (BIT(pd, 15)) { - m_r[SREG] |= SREG_MASK_N; + m_r[SREG] |= SREG_MASK_N | SREG_MASK_S; if (!BIT(rr, 7)) - m_r[SREG] |= SREG_MASK_V | SREG_MASK_C; - else - m_r[SREG] |= SREG_MASK_S; + m_r[SREG] |= SREG_MASK_C; + } + else + { + if (pd == 0) + m_r[SREG] |= SREG_MASK_Z; + if (BIT(rr, 7)) + m_r[SREG] |= SREG_MASK_V | SREG_MASK_S; } - else if (pd == 0) - m_r[SREG] |= SREG_MASK_Z; m_r[24 + (DCONST(op) << 1)] = pd & 0x00ff; m_r[25 + (DCONST(op) << 1)] = (pd >> 8) & 0x00ff; } |