Skip to content

Commit 6517b66

Browse files
committed
avr8: fix SBIW V flag once more
1 parent 53ff877 commit 6517b66

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/devices/cpu/avr8/avr8ops.hxx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,10 +1234,10 @@ void avr8_base_device::op_adiw(uint16_t op)
12341234
if (BIT(pd, 15))
12351235
{
12361236
m_r[SREG] |= SREG_MASK_N;
1237-
if (!BIT(rr, 7))
1238-
m_r[SREG] |= SREG_MASK_V;
1239-
else
1237+
if (BIT(rr, 7))
12401238
m_r[SREG] |= SREG_MASK_S;
1239+
else
1240+
m_r[SREG] |= SREG_MASK_V;
12411241
}
12421242
else
12431243
{
@@ -1258,14 +1258,17 @@ void avr8_base_device::op_sbiw(uint16_t op)
12581258
m_r[SREG] &= ~(SREG_MASK_V | SREG_MASK_N | SREG_MASK_S | SREG_MASK_Z | SREG_MASK_C);
12591259
if (BIT(pd, 15))
12601260
{
1261-
m_r[SREG] |= SREG_MASK_N;
1261+
m_r[SREG] |= SREG_MASK_N | SREG_MASK_S;
12621262
if (!BIT(rr, 7))
1263-
m_r[SREG] |= SREG_MASK_V | SREG_MASK_C;
1264-
else
1265-
m_r[SREG] |= SREG_MASK_S;
1263+
m_r[SREG] |= SREG_MASK_C;
1264+
}
1265+
else
1266+
{
1267+
if (pd == 0)
1268+
m_r[SREG] |= SREG_MASK_Z;
1269+
if (BIT(rr, 7))
1270+
m_r[SREG] |= SREG_MASK_V | SREG_MASK_S;
12661271
}
1267-
else if (pd == 0)
1268-
m_r[SREG] |= SREG_MASK_Z;
12691272
m_r[24 + (DCONST(op) << 1)] = pd & 0x00ff;
12701273
m_r[25 + (DCONST(op) << 1)] = (pd >> 8) & 0x00ff;
12711274
}

0 commit comments

Comments
 (0)