Skip to content

Commit

Permalink
avr8: fix SBIW V flag once more
Browse files Browse the repository at this point in the history
(cherry picked from commit 6517b66)
  • Loading branch information
happppp committed Mar 25, 2024
1 parent d790d8e commit 5abb7f4
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/devices/cpu/avr8/avr8ops.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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;
}
Expand Down

0 comments on commit 5abb7f4

Please sign in to comment.