Check segment limits on 286 or higher if enabled, do NOT check segment limits if 8086 or 80186

This commit is contained in:
Jonathan Campbell
2021-11-22 00:04:32 -08:00
parent 00c91ad621
commit 2c1645c62a
5 changed files with 24 additions and 2 deletions

View File

@@ -174,8 +174,6 @@ static GetEAHandler EATable[512]={
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
extern bool do_seg_limits;
#define GetEADirect(sz) \
PhysPt eaa; \
if (TEST_PREFIX_ADDR) \

View File

@@ -29,6 +29,14 @@ bool CPU_WRMSR();
bool CPU_SYSENTER();
bool CPU_SYSEXIT();
/* wrap original variable name in inline function prior to #define, use inline function name in redefine of do_seg_limits */
static inline bool _seg_limit_check(void) {
return do_seg_limits;
}
/* Do not emulate segment limit exceptions on 80186, DO emulate on 286. */
#define do_seg_limits (_seg_limit_check() && CPU_ArchitectureType >= CPU_ARCHTYPE_286)
#define PRE_EXCEPTION { }
#define CPU_CORE CPU_ARCHTYPE_286

View File

@@ -22,6 +22,10 @@
#include "pic.h"
#include "fpu.h"
/* Do not emulate segment limit exceptions on 8086. This turns the if() statements into if (0)
* and the C++ compiler optimizer should then completely omit the code for the 8086 cputype. */
#define do_seg_limits (0)
/* 8086: Apparently exceptions like DIVIDE BY ZERO are given a return address of the next instruction */
#define PRE_EXCEPTION SAVEIP

View File

@@ -34,6 +34,14 @@ bool CPU_WRMSR();
bool CPU_SYSENTER();
bool CPU_SYSEXIT();
/* wrap original variable name in inline function prior to #define, use inline function name in redefine of do_seg_limits */
static inline bool _seg_limit_check(void) {
return do_seg_limits;
}
/* Do not emulate segment limit exceptions on 80186, DO emulate on 286. */
#define do_seg_limits (_seg_limit_check() && CPU_ArchitectureType >= CPU_ARCHTYPE_286)
#define PRE_EXCEPTION { }
#define CPU_CORE CPU_ARCHTYPE_286

View File

@@ -29,6 +29,10 @@ using namespace std;
#include <algorithm>
/* Do not emulate segment limit exceptions on 8086. This turns the if() statements into if (0)
* and the C++ compiler optimizer should then completely omit the code for the 8086 cputype. */
#define do_seg_limits (0)
/* 8086: Apparently exceptions like DIVIDE BY ZERO are given a return address of the next instruction */
#define PRE_EXCEPTION SAVEIP