u32 adr, res;
u32 src, dst;
- res = DREGu8((Opcode >> 0) & 7);
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ dst = DREGu8((Opcode >> 0) & 7);
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- DREGu8((Opcode >> 0) & 7) = res;
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ DREGu8((Opcode >> 0) & 7) = res;
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
RET(6)
}
adr = AREG((Opcode >> 0) & 7);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(12)
adr = AREG((Opcode >> 0) & 7);
AREG((Opcode >> 0) & 7) += 1;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(12)
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(14)
FETCH_SWORD(adr);
adr += AREG((Opcode >> 0) & 7);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(16)
adr = AREG((Opcode >> 0) & 7);
DECODE_EXT_WORD
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(18)
FETCH_SWORD(adr);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(16)
FETCH_LONG(adr);
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(20)
adr = AREG(7);
AREG(7) += 2;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(12)
adr = AREG(7) - 2;
AREG(7) = adr;
PRE_IO
- READ_BYTE_F(adr, res)
- res = 0x9a - res - ((flag_X >> M68K_SR_X_SFT) & 1);
+ READ_BYTE_F(adr, dst)
+ res = -dst - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res != 0x9a)
+ if (res != 0)
{
- if ((res & 0x0f) == 0xa) res = (res & 0xf0) + 0x10;
- res &= 0xFF;
- WRITE_BYTE_F(adr, res)
+ flag_V = res;
+ if (((res|dst) & 0x0f) == 0) res = (res & 0xf0) + 6;
+ res = (res + 0x9a) & 0xFF;
+ WRITE_BYTE_F(adr, res)
+ flag_V &= ~res;
flag_NotZ |= res;
flag_X = flag_C = M68K_SR_C;
}
- else flag_X = flag_C = 0;
+ else flag_V = flag_X = flag_C = 0;
flag_N = res;
POST_IO
RET(14)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
src = DREGu8((Opcode >> 0) & 7);
dst = DREGu8((Opcode >> 9) & 7);
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
DREGu8((Opcode >> 9) & 7) = res;
RET(6)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) - (src & 0xF) - ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res -= 6;
+ if (res > 0xF) corf = 6;
res += (dst & 0xF0) - (src & 0xF0);
- if (res > 0x99)
- {
- res += 0xA0;
- flag_X = flag_C = M68K_SR_C;
- }
- else flag_X = flag_C = 0;
- flag_NotZ |= res & 0xFF;
+ flag_V = res;
+ flag_X = flag_C = (s32)res < (s32)corf ? M68K_SR_C : 0;
+ if (res > 0xff) res += 0xA0;
+ res = (res - corf) & 0xFF;
+ flag_V &= ~res;
+ flag_NotZ |= res;
flag_N = res;
WRITE_BYTE_F(adr, res)
POST_IO
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
src = DREGu8((Opcode >> 0) & 7);
dst = DREGu8((Opcode >> 9) & 7);
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
DREGu8((Opcode >> 9) & 7) = res;
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG((Opcode >> 9) & 7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG((Opcode >> 0) & 7) - 1;
AREG((Opcode >> 0) & 7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
{
u32 adr, res;
u32 src, dst;
+ u32 corf = 0;
adr = AREG(7) - 2;
AREG(7) = adr;
AREG(7) = adr;
READ_BYTE_F(adr, dst)
res = (dst & 0xF) + (src & 0xF) + ((flag_X >> M68K_SR_X_SFT) & 1);
- if (res > 9) res += 6;
+ if (res > 9) corf = 6;
res += (dst & 0xF0) + (src & 0xF0);
- if (res > 0x99)
+ flag_V = ~res;
+ res += corf;
+ if (res > 0x9F)
{
res -= 0xA0;
flag_X = flag_C = M68K_SR_C;
}
else flag_X = flag_C = 0;
+ flag_V &= res;
flag_NotZ |= res & 0xFF;
flag_N = res;
WRITE_BYTE_F(adr, res)
uint src = DY;\r
uint dst = *r_dst;\r
uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ uint corf = 0;\r
\r
if(res > 9)\r
- res += 6;\r
+ corf = 6;\r
res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
- FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+ FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+ res += corf;\r
+ FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
if(FLAG_C)\r
res -= 0xa0;\r
\r
uint ea = EA_A7_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ uint corf = 0;\r
\r
if(res > 9)\r
- res += 6;\r
+ corf = 6;\r
res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
- FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+ FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+ res += corf;\r
+ FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
if(FLAG_C)\r
res -= 0xa0;\r
\r
uint ea = EA_AX_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ uint corf = 0;\r
\r
if(res > 9)\r
- res += 6;\r
+ corf = 6;\r
res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
- FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+ FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+ res += corf;\r
+ FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
if(FLAG_C)\r
res -= 0xa0;\r
\r
uint ea = EA_A7_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ uint corf = 0;\r
\r
if(res > 9)\r
- res += 6;\r
+ corf = 6;\r
res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
- FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+ FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+ res += corf;\r
+ FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
if(FLAG_C)\r
res -= 0xa0;\r
\r
uint ea = EA_AX_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(src) + LOW_NIBBLE(dst) + XFLAG_AS_1();\r
-\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ uint corf = 0;\r
\r
if(res > 9)\r
- res += 6;\r
+ corf = 6;\r
res += HIGH_NIBBLE(src) + HIGH_NIBBLE(dst);\r
- FLAG_X = FLAG_C = (res > 0x99) << 8;\r
+ FLAG_V = ~res; /* Undefined V behavior */\r
+\r
+ res += corf;\r
+ FLAG_X = FLAG_C = (res > 0x9f) << 8;\r
if(FLAG_C)\r
res -= 0xa0;\r
\r
M68KMAKE_OP(nbcd, 8, ., d)\r
{\r
uint* r_dst = &DY;\r
- uint dst = *r_dst;\r
- uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1());\r
+ uint dst = MASK_OUT_ABOVE_8(*r_dst);\r
+ uint res = -dst - XFLAG_AS_1();\r
\r
- if(res != 0x9a)\r
+ if(res != 0)\r
{\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ FLAG_V = res; /* Undefined V behavior */\r
\r
- if((res & 0x0f) == 0xa)\r
- res = (res & 0xf0) + 0x10;\r
+ if(((res|dst) & 0x0f) == 0)\r
+ res = (res & 0xf0) + 6;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res + 0x9a);\r
\r
- FLAG_V &= res; /* Undefined V behavior part II */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
\r
*r_dst = MASK_OUT_BELOW_8(*r_dst) | res;\r
\r
{\r
uint ea = M68KMAKE_GET_EA_AY_8;\r
uint dst = m68ki_read_8(ea);\r
- uint res = MASK_OUT_ABOVE_8(0x9a - dst - XFLAG_AS_1());\r
+ uint res = -dst - XFLAG_AS_1();\r
\r
- if(res != 0x9a)\r
+ if(res != 0)\r
{\r
- FLAG_V = ~res; /* Undefined V behavior */\r
+ FLAG_V = res; /* Undefined V behavior */\r
\r
- if((res & 0x0f) == 0xa)\r
- res = (res & 0xf0) + 0x10;\r
+ if(((res|dst) & 0x0f) == 0)\r
+ res = (res & 0xf0) + 6;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res + 0x9a);\r
\r
- FLAG_V &= res; /* Undefined V behavior part II */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
\r
m68ki_write_8(ea, MASK_OUT_ABOVE_8(res));\r
\r
uint src = DY;\r
uint dst = *r_dst;\r
uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+ uint corf = 0;\r
\r
-// FLAG_V = ~res; /* Undefined V behavior */\r
- FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to assume cleared. */\r
-\r
- if(res > 9)\r
- res -= 6;\r
+ if(res > 0xf)\r
+ corf = 6;\r
res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
- if(res > 0x99)\r
+ FLAG_V = res; /* Undefined V behavior */\r
+ if(res > 0xff)\r
{\r
res += 0xa0;\r
FLAG_X = FLAG_C = CFLAG_SET;\r
- FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
}\r
+ else if(res < corf)\r
+ FLAG_X = FLAG_C = CFLAG_SET;\r
else\r
- FLAG_N = FLAG_X = FLAG_C = 0;\r
+ FLAG_X = FLAG_C = 0;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res - corf);\r
\r
-// FLAG_V &= res; /* Undefined V behavior part II */\r
-// FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
+ FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
FLAG_Z |= res;\r
\r
*r_dst = MASK_OUT_BELOW_8(*r_dst) | res;\r
uint ea = EA_A7_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+ uint corf = 0;\r
\r
-// FLAG_V = ~res; /* Undefined V behavior */\r
- FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
- if(res > 9)\r
- res -= 6;\r
+ if(res > 0xf)\r
+ corf = 6;\r
res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
- if(res > 0x99)\r
+ FLAG_V = res; /* Undefined V behavior */\r
+ if(res > 0xff)\r
{\r
res += 0xa0;\r
FLAG_X = FLAG_C = CFLAG_SET;\r
- FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
}\r
+ else if(res < corf)\r
+ FLAG_X = FLAG_C = CFLAG_SET;\r
else\r
- FLAG_N = FLAG_X = FLAG_C = 0;\r
+ FLAG_X = FLAG_C = 0;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res - corf);\r
\r
-// FLAG_V &= res; /* Undefined V behavior part II */\r
-// FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
+ FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
FLAG_Z |= res;\r
\r
m68ki_write_8(ea, res);\r
uint ea = EA_AX_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+ uint corf = 0;\r
\r
-// FLAG_V = ~res; /* Undefined V behavior */\r
- FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
- if(res > 9)\r
- res -= 6;\r
+ if(res > 0xf)\r
+ corf = 6;\r
res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
- if(res > 0x99)\r
+ FLAG_V = res; /* Undefined V behavior */\r
+ if(res > 0xff)\r
{\r
res += 0xa0;\r
FLAG_X = FLAG_C = CFLAG_SET;\r
- FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
}\r
+ else if(res < corf)\r
+ FLAG_X = FLAG_C = CFLAG_SET;\r
else\r
- FLAG_N = FLAG_X = FLAG_C = 0;\r
+ FLAG_X = FLAG_C = 0;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res - corf);\r
\r
-// FLAG_V &= res; /* Undefined V behavior part II */\r
-// FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
+ FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
FLAG_Z |= res;\r
\r
m68ki_write_8(ea, res);\r
uint ea = EA_A7_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+ uint corf = 0;\r
\r
-// FLAG_V = ~res; /* Undefined V behavior */\r
- FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
- if(res > 9)\r
- res -= 6;\r
+ if(res > 0xf)\r
+ corf = 6;\r
res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
- if(res > 0x99)\r
+ FLAG_V = res; /* Undefined V behavior */\r
+ if(res > 0xff)\r
{\r
res += 0xa0;\r
FLAG_X = FLAG_C = CFLAG_SET;\r
- FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
}\r
+ else if(res < corf)\r
+ FLAG_X = FLAG_C = CFLAG_SET;\r
else\r
- FLAG_N = FLAG_X = FLAG_C = 0;\r
+ FLAG_X = FLAG_C = 0;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res - corf);\r
\r
-// FLAG_V &= res; /* Undefined V behavior part II */\r
-// FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
+ FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
FLAG_Z |= res;\r
\r
m68ki_write_8(ea, res);\r
uint ea = EA_AX_PD_8();\r
uint dst = m68ki_read_8(ea);\r
uint res = LOW_NIBBLE(dst) - LOW_NIBBLE(src) - XFLAG_AS_1();\r
+ uint corf = 0;\r
\r
-// FLAG_V = ~res; /* Undefined V behavior */\r
- FLAG_V = VFLAG_CLEAR; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to return zero. */\r
-\r
- if(res > 9)\r
- res -= 6;\r
+ if(res > 0xf)\r
+ corf = 6;\r
res += HIGH_NIBBLE(dst) - HIGH_NIBBLE(src);\r
- if(res > 0x99)\r
+ FLAG_V = res; /* Undefined V behavior */\r
+ if(res > 0xff)\r
{\r
res += 0xa0;\r
FLAG_X = FLAG_C = CFLAG_SET;\r
- FLAG_N = NFLAG_SET; /* Undefined in Motorola's M68000PM/AD rev.1 and safer to follow carry. */\r
}\r
+ else if(res < corf)\r
+ FLAG_X = FLAG_C = CFLAG_SET;\r
else\r
- FLAG_N = FLAG_X = FLAG_C = 0;\r
+ FLAG_X = FLAG_C = 0;\r
\r
- res = MASK_OUT_ABOVE_8(res);\r
+ res = MASK_OUT_ABOVE_8(res - corf);\r
\r
-// FLAG_V &= res; /* Undefined V behavior part II */\r
-// FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
+ FLAG_V &= ~res; /* Undefined V behavior part II */\r
+ FLAG_N = NFLAG_8(res); /* Undefined N behavior */\r
FLAG_Z |= res;\r
\r
m68ki_write_8(ea, res);\r