From c7ff0f658bc326c29dfbf79e9aac22250939e329 Mon Sep 17 00:00:00 2001 From: ptitSeb Date: Wed, 12 Feb 2025 11:04:46 +0100 Subject: [ARM64_DYNAREC] More work on flag --- src/emu/x64primop.c | 50 ++++++++++++++++++++------------------------------ 1 file changed, 20 insertions(+), 30 deletions(-) (limited to 'src/emu') diff --git a/src/emu/x64primop.c b/src/emu/x64primop.c index 85abdd07..e1961434 100644 --- a/src/emu/x64primop.c +++ b/src/emu/x64primop.c @@ -521,8 +521,7 @@ uint8_t rcl8(x64emu_t *emu, uint8_t d, uint8_t s) CONDITIONAL_SET_FLAG(cf, F_CF); /* OVERFLOW is set *IFF* cnt==1, then it is the xor of CF and the most significant bit. Blecck. */ - if(cnt == 1) - CONDITIONAL_SET_FLAG((cf ^ (res >> 7)) & 0x1, F_OF); + CONDITIONAL_SET_FLAG((cf ^ (res >> 7)) & 0x1, F_OF); } return (uint8_t)res; @@ -544,8 +543,7 @@ uint16_t rcl16(x64emu_t *emu, uint16_t d, uint8_t s) res |= 1 << (cnt - 1); } CONDITIONAL_SET_FLAG(cf, F_CF); - if(cnt == 1) - CONDITIONAL_SET_FLAG((cf ^ (res >> 15)) & 0x1, F_OF); + CONDITIONAL_SET_FLAG((cf ^ (res >> 15)) & 0x1, F_OF); } return (uint16_t)res; } @@ -566,10 +564,7 @@ uint32_t rcl32(x64emu_t *emu, uint32_t d, uint8_t s) res |= 1 << (cnt - 1); } CONDITIONAL_SET_FLAG(cf, F_CF); - if(cnt == 1) - CONDITIONAL_SET_FLAG((cf ^ (res >> 31)) & 0x1, F_OF); - else - CLEAR_FLAG(F_OF); // UND, but clear for dynarec_test + CONDITIONAL_SET_FLAG((cf ^ (res >> 31)) & 0x1, F_OF); } return res; } @@ -590,10 +585,7 @@ uint64_t rcl64(x64emu_t *emu, uint64_t d, uint8_t s) res |= 1LL << (cnt - 1); } CONDITIONAL_SET_FLAG(cf, F_CF); - if(cnt == 1) - CONDITIONAL_SET_FLAG((cf ^ (res >> 63)) & 0x1, F_OF); - else - CLEAR_FLAG(F_OF); // UND, but clear for dynarec_test + CONDITIONAL_SET_FLAG((cf ^ (res >> 63)) & 0x1, F_OF); } return res; } @@ -634,7 +626,13 @@ uint8_t rcr8(x64emu_t *emu, uint8_t d, uint8_t s) if ((cnt = s % 9) != 0) { /* extract the new CARRY FLAG. */ /* CF <- b_(n-1) */ - if (cnt == 1) { + ocf = ACCESS_FLAG(F_CF) != 0; + /* OVERFLOW is set *IFF* cnt==1, then it is the + xor of CF and the most significant bit. Blecck. */ + /* parenthesized... */ + CONDITIONAL_SET_FLAG((ocf ^ (d >> 7)) & 0x1, + F_OF); + if (cnt == 1) { cf = d & 0x1; /* note hackery here. Access_flag(..) evaluates to either 0 if flag not set @@ -643,12 +641,6 @@ uint8_t rcr8(x64emu_t *emu, uint8_t d, uint8_t s) 0..1 in any representation of the flags register (i.e. packed bit array or unpacked.) */ - ocf = ACCESS_FLAG(F_CF) != 0; - /* OVERFLOW is set *IFF* cnt==1, then it is the - xor of CF and the most significant bit. Blecck. */ - /* parenthesized... */ - CONDITIONAL_SET_FLAG((ocf ^ (d >> 7)) & 0x1, - F_OF); } else cf = (d >> (cnt - 1)) & 0x1; @@ -691,11 +683,11 @@ uint16_t rcr16(x64emu_t *emu, uint16_t d, uint8_t s) /* rotate right through carry */ res = d; if ((cnt = s % 17) != 0) { + ocf = ACCESS_FLAG(F_CF) != 0; + CONDITIONAL_SET_FLAG((ocf ^ (d >> 15)) & 0x1, + F_OF); if (cnt == 1) { cf = d & 0x1; - ocf = ACCESS_FLAG(F_CF) != 0; - CONDITIONAL_SET_FLAG((ocf ^ (d >> 15)) & 0x1, - F_OF); } else cf = (d >> (cnt - 1)) & 0x1; mask = (1 << (16 - cnt)) - 1; @@ -719,14 +711,13 @@ uint32_t rcr32(x64emu_t *emu, uint32_t d, uint8_t s) /* rotate right through carry */ res = d; if ((cnt = s) != 0) { + ocf = ACCESS_FLAG(F_CF) != 0; + CONDITIONAL_SET_FLAG((ocf ^ (d >> 31)) & 0x1, + F_OF); if (cnt == 1) { cf = d & 0x1; - ocf = ACCESS_FLAG(F_CF) != 0; - CONDITIONAL_SET_FLAG((ocf ^ (d >> 31)) & 0x1, - F_OF); } else { cf = (d >> (cnt - 1)) & 0x1; - CLEAR_FLAG(F_OF); // UND, but clear for dynarec_test } mask = (1 << (32 - cnt)) - 1; res = (d >> cnt) & mask; @@ -750,14 +741,13 @@ uint64_t rcr64(x64emu_t *emu, uint64_t d, uint8_t s) /* rotate right through carry */ res = d; if ((cnt = s) != 0) { + ocf = ACCESS_FLAG(F_CF) != 0; + CONDITIONAL_SET_FLAG((ocf ^ (d >> 63)) & 0x1, + F_OF); if (cnt == 1) { cf = d & 0x1; - ocf = ACCESS_FLAG(F_CF) != 0; - CONDITIONAL_SET_FLAG((ocf ^ (d >> 63)) & 0x1, - F_OF); } else { cf = (d >> (cnt - 1)) & 0x1; - CLEAR_FLAG(F_OF); // UND, but clear for dynarec_test } mask = (1LL << (64 - cnt)) - 1; res = (d >> cnt) & mask; -- cgit 1.4.1