Merge pull request #3270 from 86Box/feature/checkio_optimize

386_common: Handle IOPB segment limit corner case more like the old code
This commit is contained in:
Miran Grča
2023-04-23 03:59:23 +02:00
committed by GitHub
2 changed files with 25 additions and 14 deletions

View File

@@ -1429,26 +1429,29 @@ x86illegal(void)
int
checkio(uint32_t port, int mask)
{
uint16_t t;
uint32_t t;
cpl_override = 1;
t = readmemw(tr.base, 0x66);
if (cpu_state.abrt) {
if (UNLIKELY(cpu_state.abrt)) {
cpl_override = 0;
return 0;
}
if ((t + (port >> 3UL) + 1) > tr.limit) {
t += (port >> 3UL);
mask <<= (port & 7);
if (UNLIKELY(mask & 0xff00)) {
if (LIKELY(t < tr.limit))
mask &= readmemwl(tr.base + t);
} else {
if (LIKELY(t <= tr.limit))
mask &= readmembl(tr.base + t);
}
cpl_override = 0;
return mask;
}
t = readmemwl(tr.base + t + (port >> 3));
cpl_override = 0;
return (t >> (port & 7)) & mask;
}
#ifdef OLD_DIVEXCP
# define divexcp() \
{ \

View File

@@ -55,6 +55,14 @@
#define BCD16(x) ((((x) / 1000) << 12) | (((x) / 100) << 8) | BCD8(x))
#define BCD32(x) ((((x) / 10000000) << 28) | (((x) / 1000000) << 24) | (((x) / 100000) << 20) | (((x) / 10000) << 16) | BCD16(x))
#if defined(__GNUC__) || defined(__clang__)
# define UNLIKELY(x) __builtin_expect((x), 0)
# define LIKELY(x) __builtin_expect((x), 1)
#else
# define UNLIKELY(x) (x)
# define LIKELY(x) (x)
#endif
#ifdef __cplusplus
extern "C" {
#endif