mirror of
https://github.com/sarah-walker-pcem/pcem.git
synced 2025-07-23 19:50:35 +02:00
[no ci] Format Changes
This commit is contained in:
148
.clang-format
Normal file
148
.clang-format
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
# BasedOnStyle: LLVM
|
||||||
|
AccessModifierOffset: -4
|
||||||
|
AlignAfterOpenBracket: Align
|
||||||
|
AlignConsecutiveMacros: false
|
||||||
|
AlignConsecutiveAssignments: false
|
||||||
|
AlignConsecutiveBitFields: false
|
||||||
|
AlignConsecutiveDeclarations: false
|
||||||
|
AlignEscapedNewlines: Right
|
||||||
|
AlignOperands: Align
|
||||||
|
AlignTrailingComments: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
AllowAllConstructorInitializersOnNextLine: true
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AllowShortEnumsOnASingleLine: true
|
||||||
|
AllowShortBlocksOnASingleLine: Never
|
||||||
|
AllowShortCaseLabelsOnASingleLine: false
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortLambdasOnASingleLine: All
|
||||||
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
AlwaysBreakAfterDefinitionReturnType: None
|
||||||
|
AlwaysBreakAfterReturnType: None
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
BinPackArguments: true
|
||||||
|
BinPackParameters: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterCaseLabel: false
|
||||||
|
AfterClass: false
|
||||||
|
AfterControlStatement: Never
|
||||||
|
AfterEnum: false
|
||||||
|
AfterFunction: false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: false
|
||||||
|
AfterStruct: false
|
||||||
|
AfterUnion: false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
BeforeLambdaBody: false
|
||||||
|
BeforeWhile: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
BreakBeforeBinaryOperators: None
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
BreakBeforeInheritanceComma: false
|
||||||
|
BreakInheritanceList: BeforeColon
|
||||||
|
BreakBeforeTernaryOperators: true
|
||||||
|
BreakConstructorInitializersBeforeComma: false
|
||||||
|
BreakConstructorInitializers: BeforeColon
|
||||||
|
BreakAfterJavaFieldAnnotations: false
|
||||||
|
BreakStringLiterals: true
|
||||||
|
ColumnLimit: 130
|
||||||
|
CommentPragmas: '^ IWYU pragma:'
|
||||||
|
CompactNamespaces: false
|
||||||
|
ConstructorInitializerAllOnOneLineOrOnePerLine: false
|
||||||
|
ConstructorInitializerIndentWidth: 8
|
||||||
|
ContinuationIndentWidth: 8
|
||||||
|
Cpp11BracedListStyle: true
|
||||||
|
DeriveLineEnding: true
|
||||||
|
DerivePointerAlignment: false
|
||||||
|
DisableFormat: false
|
||||||
|
ExperimentalAutoDetectBinPacking: false
|
||||||
|
FixNamespaceComments: true
|
||||||
|
ForEachMacros:
|
||||||
|
- foreach
|
||||||
|
- Q_FOREACH
|
||||||
|
- BOOST_FOREACH
|
||||||
|
IncludeBlocks: Preserve
|
||||||
|
IncludeCategories:
|
||||||
|
- Regex: '^"(llvm|llvm-c|clang|clang-c)/'
|
||||||
|
Priority: 2
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '^(<|"(gtest|gmock|isl|json)/)'
|
||||||
|
Priority: 3
|
||||||
|
SortPriority: 0
|
||||||
|
- Regex: '.*'
|
||||||
|
Priority: 1
|
||||||
|
SortPriority: 0
|
||||||
|
IncludeIsMainRegex: '(Test)?$'
|
||||||
|
IncludeIsMainSourceRegex: ''
|
||||||
|
IndentCaseLabels: false
|
||||||
|
IndentCaseBlocks: false
|
||||||
|
IndentGotoLabels: true
|
||||||
|
IndentPPDirectives: None
|
||||||
|
IndentExternBlock: AfterExternBlock
|
||||||
|
IndentWidth: 8
|
||||||
|
IndentWrappedFunctionNames: false
|
||||||
|
InsertTrailingCommas: None
|
||||||
|
JavaScriptQuotes: Leave
|
||||||
|
JavaScriptWrapImports: true
|
||||||
|
KeepEmptyLinesAtTheStartOfBlocks: true
|
||||||
|
MacroBlockBegin: ''
|
||||||
|
MacroBlockEnd: ''
|
||||||
|
MaxEmptyLinesToKeep: 1
|
||||||
|
NamespaceIndentation: None
|
||||||
|
ObjCBinPackProtocolList: Auto
|
||||||
|
ObjCBlockIndentWidth: 8
|
||||||
|
ObjCBreakBeforeNestedBlockParam: true
|
||||||
|
ObjCSpaceAfterProperty: false
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
PenaltyBreakAssignment: 2
|
||||||
|
PenaltyBreakBeforeFirstCallParameter: 19
|
||||||
|
PenaltyBreakComment: 300
|
||||||
|
PenaltyBreakFirstLessLess: 120
|
||||||
|
PenaltyBreakString: 1000
|
||||||
|
PenaltyBreakTemplateDeclaration: 10
|
||||||
|
PenaltyExcessCharacter: 1000000
|
||||||
|
PenaltyReturnTypeOnItsOwnLine: 60
|
||||||
|
PointerAlignment: Right
|
||||||
|
ReflowComments: true
|
||||||
|
SortIncludes: false
|
||||||
|
SortUsingDeclarations: false
|
||||||
|
SpaceAfterCStyleCast: false
|
||||||
|
SpaceAfterLogicalNot: false
|
||||||
|
SpaceAfterTemplateKeyword: true
|
||||||
|
SpaceBeforeAssignmentOperators: true
|
||||||
|
SpaceBeforeCpp11BracedList: false
|
||||||
|
SpaceBeforeCtorInitializerColon: true
|
||||||
|
SpaceBeforeInheritanceColon: true
|
||||||
|
SpaceBeforeParens: ControlStatements
|
||||||
|
SpaceBeforeRangeBasedForLoopColon: true
|
||||||
|
SpaceInEmptyBlock: false
|
||||||
|
SpaceInEmptyParentheses: false
|
||||||
|
SpacesBeforeTrailingComments: 1
|
||||||
|
SpacesInAngles: false
|
||||||
|
SpacesInConditionalStatement: false
|
||||||
|
SpacesInContainerLiterals: true
|
||||||
|
SpacesInCStyleCastParentheses: false
|
||||||
|
SpacesInParentheses: false
|
||||||
|
SpacesInSquareBrackets: false
|
||||||
|
SpaceBeforeSquareBrackets: false
|
||||||
|
Standard: Latest
|
||||||
|
StatementMacros:
|
||||||
|
- Q_UNUSED
|
||||||
|
- QT_REQUIRE_VERSION
|
||||||
|
TabWidth: 8
|
||||||
|
UseCRLF: false
|
||||||
|
UseTab: Never
|
||||||
|
WhitespaceSensitiveMacros:
|
||||||
|
- STRINGIZE
|
||||||
|
- PP_STRINGIZE
|
||||||
|
- BOOST_PP_STRINGIZE
|
||||||
|
---
|
File diff suppressed because it is too large
Load Diff
@@ -6,40 +6,37 @@
|
|||||||
|
|
||||||
extern char pcem_path[512];
|
extern char pcem_path[512];
|
||||||
|
|
||||||
LPT_DEVICE l_epsonlx810 = { "Epson LX-810 Printer", "lpt_epsonlx810", &lpt_epsonprinter_device };
|
LPT_DEVICE l_epsonlx810 = {"Epson LX-810 Printer", "lpt_epsonlx810", &lpt_epsonprinter_device};
|
||||||
|
|
||||||
#define safe_strncpy(a,b,n) do { strncpy((a),(b),(n)-1); (a)[(n)-1] = 0; } while (0)
|
#define safe_strncpy(a, b, n) \
|
||||||
|
do { \
|
||||||
|
strncpy((a), (b), (n)-1); \
|
||||||
|
(a)[(n)-1] = 0; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
char printer_path[512];
|
char printer_path[512];
|
||||||
|
|
||||||
void set_printer_path(char *s)
|
void set_printer_path(char *s) {
|
||||||
{
|
|
||||||
safe_strncpy(printer_path, s, 512);
|
safe_strncpy(printer_path, s, 512);
|
||||||
append_slash(printer_path, 512);
|
append_slash(printer_path, 512);
|
||||||
}
|
}
|
||||||
|
|
||||||
void load_config()
|
void load_config() {
|
||||||
{
|
char *cfg_printer_path = config_get_string(CFG_GLOBAL, "Paths", "printer_path", 0);
|
||||||
char* cfg_printer_path = config_get_string(CFG_GLOBAL, "Paths", "printer_path", 0);
|
|
||||||
|
|
||||||
if (cfg_printer_path)
|
if (cfg_printer_path)
|
||||||
set_printer_path(cfg_printer_path);
|
set_printer_path(cfg_printer_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void save_config()
|
void save_config() { config_set_string(CFG_GLOBAL, "Paths", "printer_path", printer_path); }
|
||||||
{
|
|
||||||
config_set_string(CFG_GLOBAL, "Paths", "printer_path", printer_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
void init_config()
|
void init_config() {
|
||||||
{
|
|
||||||
char s[512];
|
char s[512];
|
||||||
append_filename(s, pcem_path, "printer/", 512);
|
append_filename(s, pcem_path, "printer/", 512);
|
||||||
set_printer_path(s);
|
set_printer_path(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
PLUGIN_INIT(printer_epsonlx810)
|
PLUGIN_INIT(printer_epsonlx810) {
|
||||||
{
|
|
||||||
add_config_callback(load_config, save_config, init_config);
|
add_config_callback(load_config, save_config, init_config);
|
||||||
pcem_add_lpt(&l_epsonlx810);
|
pcem_add_lpt(&l_epsonlx810);
|
||||||
}
|
}
|
||||||
|
@@ -4,33 +4,28 @@
|
|||||||
#include <wx/wfstream.h>
|
#include <wx/wfstream.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
|
|
||||||
int wx_image_save_fullpath(const char* fullpath, const char* format, unsigned char* rgba, int width, int height, int alpha)
|
int wx_image_save_fullpath(const char *fullpath, const char *format, unsigned char *rgba, int width, int height, int alpha) {
|
||||||
{
|
|
||||||
int x, y;
|
int x, y;
|
||||||
wxLogNull logNull;
|
wxLogNull logNull;
|
||||||
wxImage image(width, height);
|
wxImage image(width, height);
|
||||||
if (alpha)
|
if (alpha) {
|
||||||
{
|
|
||||||
// these will be automatically freed
|
// these will be automatically freed
|
||||||
unsigned char* rgb = (unsigned char*)malloc(width*height*3);
|
unsigned char *rgb = (unsigned char *)malloc(width * height * 3);
|
||||||
unsigned char* a = (unsigned char*)malloc(width*height);
|
unsigned char *a = (unsigned char *)malloc(width * height);
|
||||||
for (x = 0; x < width; ++x)
|
for (x = 0; x < width; ++x) {
|
||||||
{
|
for (y = 0; y < height; ++y) {
|
||||||
for (y = 0; y < height; ++y)
|
rgb[(y * width + x) * 3 + 0] = rgba[(y * width + x) * 4 + 0];
|
||||||
{
|
rgb[(y * width + x) * 3 + 1] = rgba[(y * width + x) * 4 + 1];
|
||||||
rgb[(y*width+x)*3+0] = rgba[(y*width+x)*4+0];
|
rgb[(y * width + x) * 3 + 2] = rgba[(y * width + x) * 4 + 2];
|
||||||
rgb[(y*width+x)*3+1] = rgba[(y*width+x)*4+1];
|
a[y * width + x] = rgba[(y * width + x) * 4 + 3];
|
||||||
rgb[(y*width+x)*3+2] = rgba[(y*width+x)*4+2];
|
|
||||||
a[y*width+x] = rgba[(y*width+x)*4+3];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
image.SetData(rgb);
|
image.SetData(rgb);
|
||||||
image.SetAlpha(a);
|
image.SetAlpha(a);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
image.SetData(rgba, true);
|
image.SetData(rgba, true);
|
||||||
|
|
||||||
wxImageHandler* h;
|
wxImageHandler *h;
|
||||||
|
|
||||||
if (!strcmp(format, IMAGE_TIFF))
|
if (!strcmp(format, IMAGE_TIFF))
|
||||||
h = new wxTIFFHandler();
|
h = new wxTIFFHandler();
|
||||||
@@ -42,8 +37,7 @@ int wx_image_save_fullpath(const char* fullpath, const char* format, unsigned ch
|
|||||||
h = new wxPNGHandler();
|
h = new wxPNGHandler();
|
||||||
|
|
||||||
int res = 0;
|
int res = 0;
|
||||||
if (h)
|
if (h) {
|
||||||
{
|
|
||||||
wxString p(fullpath);
|
wxString p(fullpath);
|
||||||
|
|
||||||
wxFileOutputStream stream(p);
|
wxFileOutputStream stream(p);
|
||||||
|
@@ -9,111 +9,71 @@
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#define bswap_16(x) \
|
#define bswap_16(x) \
|
||||||
({ \
|
({ \
|
||||||
uint16_t __x = (x); \
|
uint16_t __x = (x); \
|
||||||
((uint16_t)( \
|
((uint16_t)((((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | (((uint16_t)(__x) & (uint16_t)0xff00U) >> 8))); \
|
||||||
(((uint16_t)(__x) & (uint16_t)0x00ffU) << 8) | \
|
})
|
||||||
(((uint16_t)(__x) & (uint16_t)0xff00U) >> 8) )); \
|
|
||||||
})
|
|
||||||
|
|
||||||
#define bswap_32(x) \
|
#define bswap_32(x) \
|
||||||
({ \
|
({ \
|
||||||
uint32_t __x = (x); \
|
uint32_t __x = (x); \
|
||||||
((uint32_t)( \
|
((uint32_t)((((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
|
||||||
(((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
|
|
||||||
(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
|
(((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
|
||||||
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
|
(((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
|
||||||
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
|
(((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24))); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#define bswap_64(x) \
|
#define bswap_64(x) \
|
||||||
({ \
|
({ \
|
||||||
uint64_t __x = (x); \
|
uint64_t __x = (x); \
|
||||||
((uint64_t)( \
|
((uint64_t)((uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000000000ffULL) << 56) | \
|
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000000000ff00ULL) << 40) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000000000ff0000ULL) << 24) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00000000ff000000ULL) << 8) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x000000ff00000000ULL) >> 8) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x0000ff0000000000ULL) >> 24) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0x00ff000000000000ULL) >> 40) | \
|
||||||
(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56) )); \
|
(uint64_t)(((uint64_t)(__x) & (uint64_t)0xff00000000000000ULL) >> 56))); \
|
||||||
})
|
})
|
||||||
|
|
||||||
#endif /* !HAVE_BYTESWAP_H */
|
#endif /* !HAVE_BYTESWAP_H */
|
||||||
|
|
||||||
static inline uint16_t bswap16(uint16_t x)
|
static inline uint16_t bswap16(uint16_t x) { return bswap_16(x); }
|
||||||
{
|
|
||||||
return bswap_16(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint32_t bswap32(uint32_t x)
|
static inline uint32_t bswap32(uint32_t x) { return bswap_32(x); }
|
||||||
{
|
|
||||||
return bswap_32(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint64_t bswap64(uint64_t x)
|
static inline uint64_t bswap64(uint64_t x) { return bswap_64(x); }
|
||||||
{
|
|
||||||
return bswap_64(x);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void bswap16s(uint16_t *s)
|
static inline void bswap16s(uint16_t *s) { *s = bswap16(*s); }
|
||||||
{
|
|
||||||
*s = bswap16(*s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void bswap32s(uint32_t *s)
|
static inline void bswap32s(uint32_t *s) { *s = bswap32(*s); }
|
||||||
{
|
|
||||||
*s = bswap32(*s);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void bswap64s(uint64_t *s)
|
static inline void bswap64s(uint64_t *s) { *s = bswap64(*s); }
|
||||||
{
|
|
||||||
*s = bswap64(*s);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(WORDS_BIGENDIAN)
|
#if defined(WORDS_BIGENDIAN)
|
||||||
#define be_bswap(v, size) (v)
|
#define be_bswap(v, size) (v)
|
||||||
#define le_bswap(v, size) bswap ## size(v)
|
#define le_bswap(v, size) bswap##size(v)
|
||||||
#define be_bswaps(v, size)
|
#define be_bswaps(v, size)
|
||||||
#define le_bswaps(p, size) *p = bswap ## size(*p);
|
#define le_bswaps(p, size) *p = bswap##size(*p);
|
||||||
#else
|
#else
|
||||||
#define le_bswap(v, size) (v)
|
#define le_bswap(v, size) (v)
|
||||||
#define be_bswap(v, size) bswap ## size(v)
|
#define be_bswap(v, size) bswap##size(v)
|
||||||
#define le_bswaps(v, size)
|
#define le_bswaps(v, size)
|
||||||
#define be_bswaps(p, size) *p = bswap ## size(*p);
|
#define be_bswaps(p, size) *p = bswap##size(*p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CPU_CONVERT(endian, size, type)\
|
#define CPU_CONVERT(endian, size, type) \
|
||||||
static inline type endian ## size ## _to_cpu(type v)\
|
static inline type endian##size##_to_cpu(type v) { return endian##_bswap(v, size); } \
|
||||||
{\
|
\
|
||||||
return endian ## _bswap(v, size);\
|
static inline type cpu_to_##endian##size(type v) { return endian##_bswap(v, size); } \
|
||||||
}\
|
\
|
||||||
\
|
static inline void endian##size##_to_cpus(type *p) { endian##_bswaps(p, size) } \
|
||||||
static inline type cpu_to_ ## endian ## size(type v)\
|
\
|
||||||
{\
|
static inline void cpu_to_##endian##size##s(type *p) { endian##_bswaps(p, size) } \
|
||||||
return endian ## _bswap(v, size);\
|
\
|
||||||
}\
|
static inline type endian##size##_to_cpup(const type *p) { return endian##size##_to_cpu(*p); } \
|
||||||
\
|
\
|
||||||
static inline void endian ## size ## _to_cpus(type *p)\
|
static inline void cpu_to_##endian##size##w(type *p, type v) { *p = cpu_to_##endian##size(v); }
|
||||||
{\
|
|
||||||
endian ## _bswaps(p, size)\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
static inline void cpu_to_ ## endian ## size ## s(type *p)\
|
|
||||||
{\
|
|
||||||
endian ## _bswaps(p, size)\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
static inline type endian ## size ## _to_cpup(const type *p)\
|
|
||||||
{\
|
|
||||||
return endian ## size ## _to_cpu(*p);\
|
|
||||||
}\
|
|
||||||
\
|
|
||||||
static inline void cpu_to_ ## endian ## size ## w(type *p, type v)\
|
|
||||||
{\
|
|
||||||
*p = cpu_to_ ## endian ## size(v);\
|
|
||||||
}
|
|
||||||
|
|
||||||
CPU_CONVERT(be, 16, uint16_t)
|
CPU_CONVERT(be, 16, uint16_t)
|
||||||
CPU_CONVERT(be, 32, uint32_t)
|
CPU_CONVERT(be, 32, uint32_t)
|
||||||
@@ -137,16 +97,14 @@ CPU_CONVERT(le, 64, uint64_t)
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
static inline void cpu_to_le16wu(uint16_t *p, uint16_t v)
|
static inline void cpu_to_le16wu(uint16_t *p, uint16_t v) {
|
||||||
{
|
|
||||||
uint8_t *p1 = (uint8_t *)p;
|
uint8_t *p1 = (uint8_t *)p;
|
||||||
|
|
||||||
p1[0] = v;
|
p1[0] = v;
|
||||||
p1[1] = v >> 8;
|
p1[1] = v >> 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
|
static inline void cpu_to_le32wu(uint32_t *p, uint32_t v) {
|
||||||
{
|
|
||||||
uint8_t *p1 = (uint8_t *)p;
|
uint8_t *p1 = (uint8_t *)p;
|
||||||
|
|
||||||
p1[0] = v;
|
p1[0] = v;
|
||||||
@@ -155,28 +113,24 @@ static inline void cpu_to_le32wu(uint32_t *p, uint32_t v)
|
|||||||
p1[3] = v >> 24;
|
p1[3] = v >> 24;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint16_t le16_to_cpupu(const uint16_t *p)
|
static inline uint16_t le16_to_cpupu(const uint16_t *p) {
|
||||||
{
|
|
||||||
const uint8_t *p1 = (const uint8_t *)p;
|
const uint8_t *p1 = (const uint8_t *)p;
|
||||||
return p1[0] | (p1[1] << 8);
|
return p1[0] | (p1[1] << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t le32_to_cpupu(const uint32_t *p)
|
static inline uint32_t le32_to_cpupu(const uint32_t *p) {
|
||||||
{
|
|
||||||
const uint8_t *p1 = (const uint8_t *)p;
|
const uint8_t *p1 = (const uint8_t *)p;
|
||||||
return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
|
return p1[0] | (p1[1] << 8) | (p1[2] << 16) | (p1[3] << 24);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cpu_to_be16wu(uint16_t *p, uint16_t v)
|
static inline void cpu_to_be16wu(uint16_t *p, uint16_t v) {
|
||||||
{
|
|
||||||
uint8_t *p1 = (uint8_t *)p;
|
uint8_t *p1 = (uint8_t *)p;
|
||||||
|
|
||||||
p1[0] = v >> 8;
|
p1[0] = v >> 8;
|
||||||
p1[1] = v;
|
p1[1] = v;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void cpu_to_be32wu(uint32_t *p, uint32_t v)
|
static inline void cpu_to_be32wu(uint32_t *p, uint32_t v) {
|
||||||
{
|
|
||||||
uint8_t *p1 = (uint8_t *)p;
|
uint8_t *p1 = (uint8_t *)p;
|
||||||
|
|
||||||
p1[0] = v >> 24;
|
p1[0] = v >> 24;
|
||||||
|
@@ -1,7 +1,8 @@
|
|||||||
#ifndef _MCA_H_
|
#ifndef _MCA_H_
|
||||||
#define _MCA_H_
|
#define _MCA_H_
|
||||||
void mca_init(int nr_cards);
|
void mca_init(int nr_cards);
|
||||||
void mca_add(uint8_t (*read)(int addr, void *priv), void (*write)(int addr, uint8_t val, void *priv), void (*reset)(void *priv), void *priv);
|
void mca_add(uint8_t (*read)(int addr, void *priv), void (*write)(int addr, uint8_t val, void *priv), void (*reset)(void *priv),
|
||||||
|
void *priv);
|
||||||
void mca_set_index(int index);
|
void mca_set_index(int index);
|
||||||
uint8_t mca_read(uint16_t port);
|
uint8_t mca_read(uint16_t port);
|
||||||
void mca_write(uint16_t port, uint8_t val);
|
void mca_write(uint16_t port, uint8_t val);
|
||||||
|
@@ -2,8 +2,10 @@
|
|||||||
#define _PCI_H_
|
#define _PCI_H_
|
||||||
void pci_init(int type);
|
void pci_init(int type);
|
||||||
void pci_slot(int card);
|
void pci_slot(int card);
|
||||||
void pci_add_specific(int card, uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv);
|
void pci_add_specific(int card, uint8_t (*read)(int func, int addr, void *priv),
|
||||||
int pci_add(uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv), void *priv);
|
void (*write)(int func, int addr, uint8_t val, void *priv), void *priv);
|
||||||
|
int pci_add(uint8_t (*read)(int func, int addr, void *priv), void (*write)(int func, int addr, uint8_t val, void *priv),
|
||||||
|
void *priv);
|
||||||
void pci_set_irq_routing(int card, int irq);
|
void pci_set_irq_routing(int card, int irq);
|
||||||
void pci_set_card_routing(int card, int pci_int);
|
void pci_set_card_routing(int card, int pci_int);
|
||||||
void pci_set_irq(int card, int pci_int);
|
void pci_set_irq(int card, int pci_int);
|
||||||
|
@@ -29,8 +29,7 @@
|
|||||||
same page).
|
same page).
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct codeblock_t
|
typedef struct codeblock_t {
|
||||||
{
|
|
||||||
uint32_t pc;
|
uint32_t pc;
|
||||||
uint32_t _cs;
|
uint32_t _cs;
|
||||||
uint32_t phys, phys_2;
|
uint32_t phys, phys_2;
|
||||||
@@ -86,13 +85,9 @@ extern uint8_t *block_write_data;
|
|||||||
|
|
||||||
#define BLOCK_INVALID 0
|
#define BLOCK_INVALID 0
|
||||||
|
|
||||||
static inline int get_block_nr(codeblock_t *block)
|
static inline int get_block_nr(codeblock_t *block) { return ((uintptr_t)block - (uintptr_t)codeblock) / sizeof(codeblock_t); }
|
||||||
{
|
|
||||||
return ((uintptr_t)block - (uintptr_t)codeblock) / sizeof(codeblock_t);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs)
|
static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs) {
|
||||||
{
|
|
||||||
codeblock_t *block;
|
codeblock_t *block;
|
||||||
uint64_t a = _cs | ((uint64_t)phys << 32);
|
uint64_t a = _cs | ((uint64_t)phys << 32);
|
||||||
|
|
||||||
@@ -100,11 +95,9 @@ static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
block = &codeblock[pages[phys >> 12].head];
|
block = &codeblock[pages[phys >> 12].head];
|
||||||
while (block)
|
while (block) {
|
||||||
{
|
|
||||||
uint64_t block_cmp = block->_cs | ((uint64_t)block->phys << 32);
|
uint64_t block_cmp = block->_cs | ((uint64_t)block->phys << 32);
|
||||||
if (a == block_cmp)
|
if (a == block_cmp) {
|
||||||
{
|
|
||||||
if (!((block->status ^ cpu_cur_status) & CPU_STATUS_FLAGS) &&
|
if (!((block->status ^ cpu_cur_status) & CPU_STATUS_FLAGS) &&
|
||||||
((block->status & cpu_cur_status & CPU_STATUS_MASK) == (cpu_cur_status & CPU_STATUS_MASK)))
|
((block->status & cpu_cur_status & CPU_STATUS_MASK) == (cpu_cur_status & CPU_STATUS_MASK)))
|
||||||
break;
|
break;
|
||||||
@@ -118,23 +111,18 @@ static inline codeblock_t *codeblock_tree_find(uint32_t phys, uint32_t _cs)
|
|||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codeblock_tree_add(codeblock_t *new_block)
|
static inline void codeblock_tree_add(codeblock_t *new_block) {
|
||||||
{
|
|
||||||
codeblock_t *block = &codeblock[pages[new_block->phys >> 12].head];
|
codeblock_t *block = &codeblock[pages[new_block->phys >> 12].head];
|
||||||
uint64_t a = new_block->_cs | ((uint64_t)new_block->phys << 32);
|
uint64_t a = new_block->_cs | ((uint64_t)new_block->phys << 32);
|
||||||
|
|
||||||
if (!pages[new_block->phys >> 12].head)
|
if (!pages[new_block->phys >> 12].head) {
|
||||||
{
|
|
||||||
pages[new_block->phys >> 12].head = get_block_nr(new_block);
|
pages[new_block->phys >> 12].head = get_block_nr(new_block);
|
||||||
new_block->parent = new_block->left = new_block->right = BLOCK_INVALID;
|
new_block->parent = new_block->left = new_block->right = BLOCK_INVALID;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
codeblock_t *old_block = NULL;
|
codeblock_t *old_block = NULL;
|
||||||
uint64_t old_block_cmp = 0;
|
uint64_t old_block_cmp = 0;
|
||||||
|
|
||||||
while (block)
|
while (block) {
|
||||||
{
|
|
||||||
old_block = block;
|
old_block = block;
|
||||||
old_block_cmp = old_block->_cs | ((uint64_t)old_block->phys << 32);
|
old_block_cmp = old_block->_cs | ((uint64_t)old_block->phys << 32);
|
||||||
|
|
||||||
@@ -154,8 +142,7 @@ static inline void codeblock_tree_add(codeblock_t *new_block)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codeblock_tree_delete(codeblock_t *block)
|
static inline void codeblock_tree_delete(codeblock_t *block) {
|
||||||
{
|
|
||||||
uint16_t parent_nr = block->parent;
|
uint16_t parent_nr = block->parent;
|
||||||
codeblock_t *parent;
|
codeblock_t *parent;
|
||||||
|
|
||||||
@@ -164,13 +151,11 @@ static inline void codeblock_tree_delete(codeblock_t *block)
|
|||||||
else
|
else
|
||||||
parent = NULL;
|
parent = NULL;
|
||||||
|
|
||||||
if (!block->left && !block->right)
|
if (!block->left && !block->right) {
|
||||||
{
|
|
||||||
/*Easy case - remove from parent*/
|
/*Easy case - remove from parent*/
|
||||||
if (!parent)
|
if (!parent)
|
||||||
pages[block->phys >> 12].head = BLOCK_INVALID;
|
pages[block->phys >> 12].head = BLOCK_INVALID;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
uint16_t block_nr = get_block_nr(block);
|
uint16_t block_nr = get_block_nr(block);
|
||||||
|
|
||||||
if (parent->left == block_nr)
|
if (parent->left == block_nr)
|
||||||
@@ -179,59 +164,43 @@ static inline void codeblock_tree_delete(codeblock_t *block)
|
|||||||
parent->right = BLOCK_INVALID;
|
parent->right = BLOCK_INVALID;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else if (!block->left) {
|
||||||
else if (!block->left)
|
|
||||||
{
|
|
||||||
/*Only right node*/
|
/*Only right node*/
|
||||||
if (!parent_nr)
|
if (!parent_nr) {
|
||||||
{
|
|
||||||
pages[block->phys >> 12].head = block->right;
|
pages[block->phys >> 12].head = block->right;
|
||||||
codeblock[pages[block->phys >> 12].head].parent = BLOCK_INVALID;
|
codeblock[pages[block->phys >> 12].head].parent = BLOCK_INVALID;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
uint16_t block_nr = get_block_nr(block);
|
uint16_t block_nr = get_block_nr(block);
|
||||||
|
|
||||||
if (parent->left == block_nr)
|
if (parent->left == block_nr) {
|
||||||
{
|
|
||||||
parent->left = block->right;
|
parent->left = block->right;
|
||||||
codeblock[parent->left].parent = parent_nr;
|
codeblock[parent->left].parent = parent_nr;
|
||||||
}
|
}
|
||||||
if (parent->right == block_nr)
|
if (parent->right == block_nr) {
|
||||||
{
|
|
||||||
parent->right = block->right;
|
parent->right = block->right;
|
||||||
codeblock[parent->right].parent = parent_nr;
|
codeblock[parent->right].parent = parent_nr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else if (!block->right) {
|
||||||
else if (!block->right)
|
|
||||||
{
|
|
||||||
/*Only left node*/
|
/*Only left node*/
|
||||||
if (!parent_nr)
|
if (!parent_nr) {
|
||||||
{
|
|
||||||
pages[block->phys >> 12].head = block->left;
|
pages[block->phys >> 12].head = block->left;
|
||||||
codeblock[pages[block->phys >> 12].head].parent = BLOCK_INVALID;
|
codeblock[pages[block->phys >> 12].head].parent = BLOCK_INVALID;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
uint16_t block_nr = get_block_nr(block);
|
uint16_t block_nr = get_block_nr(block);
|
||||||
|
|
||||||
if (parent->left == block_nr)
|
if (parent->left == block_nr) {
|
||||||
{
|
|
||||||
parent->left = block->left;
|
parent->left = block->left;
|
||||||
codeblock[parent->left].parent = parent_nr;
|
codeblock[parent->left].parent = parent_nr;
|
||||||
}
|
}
|
||||||
if (parent->right == block_nr)
|
if (parent->right == block_nr) {
|
||||||
{
|
|
||||||
parent->right = block->left;
|
parent->right = block->left;
|
||||||
codeblock[parent->right].parent = parent_nr;
|
codeblock[parent->right].parent = parent_nr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
/*Difficult case - node has two children. Walk right child to find lowest node*/
|
/*Difficult case - node has two children. Walk right child to find lowest node*/
|
||||||
codeblock_t *lowest = &codeblock[block->right], *highest;
|
codeblock_t *lowest = &codeblock[block->right], *highest;
|
||||||
codeblock_t *old_parent;
|
codeblock_t *old_parent;
|
||||||
@@ -246,8 +215,7 @@ static inline void codeblock_tree_delete(codeblock_t *block)
|
|||||||
/*Replace deleted node with lowest node*/
|
/*Replace deleted node with lowest node*/
|
||||||
if (!parent_nr)
|
if (!parent_nr)
|
||||||
pages[block->phys >> 12].head = lowest_nr;
|
pages[block->phys >> 12].head = lowest_nr;
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
uint16_t block_nr = get_block_nr(block);
|
uint16_t block_nr = get_block_nr(block);
|
||||||
|
|
||||||
if (parent->left == block_nr)
|
if (parent->left == block_nr)
|
||||||
@@ -264,10 +232,8 @@ static inline void codeblock_tree_delete(codeblock_t *block)
|
|||||||
old_parent->left = BLOCK_INVALID;
|
old_parent->left = BLOCK_INVALID;
|
||||||
|
|
||||||
highest = &codeblock[lowest->right];
|
highest = &codeblock[lowest->right];
|
||||||
if (!lowest->right)
|
if (!lowest->right) {
|
||||||
{
|
if (lowest_nr != block->right) {
|
||||||
if (lowest_nr != block->right)
|
|
||||||
{
|
|
||||||
lowest->right = block->right;
|
lowest->right = block->right;
|
||||||
codeblock[block->right].parent = lowest_nr;
|
codeblock[block->right].parent = lowest_nr;
|
||||||
}
|
}
|
||||||
@@ -277,8 +243,7 @@ static inline void codeblock_tree_delete(codeblock_t *block)
|
|||||||
while (highest->right)
|
while (highest->right)
|
||||||
highest = &codeblock[highest->right];
|
highest = &codeblock[highest->right];
|
||||||
|
|
||||||
if (block->right && block->right != lowest_nr)
|
if (block->right && block->right != lowest_nr) {
|
||||||
{
|
|
||||||
highest->right = block->right;
|
highest->right = block->right;
|
||||||
codeblock[block->right].parent = get_block_nr(highest);
|
codeblock[block->right].parent = get_block_nr(highest);
|
||||||
}
|
}
|
||||||
@@ -290,26 +255,20 @@ static inline void codeblock_tree_delete(codeblock_t *block)
|
|||||||
|
|
||||||
void codegen_mark_code_present_multibyte(codeblock_t *block, uint32_t start_pc, int len);
|
void codegen_mark_code_present_multibyte(codeblock_t *block, uint32_t start_pc, int len);
|
||||||
|
|
||||||
static inline void codegen_mark_code_present(codeblock_t *block, uint32_t start_pc, int len)
|
static inline void codegen_mark_code_present(codeblock_t *block, uint32_t start_pc, int len) {
|
||||||
{
|
if (len == 1) {
|
||||||
if (len == 1)
|
if (block->flags & CODEBLOCK_BYTE_MASK) {
|
||||||
{
|
|
||||||
if (block->flags & CODEBLOCK_BYTE_MASK)
|
|
||||||
{
|
|
||||||
if (!((start_pc ^ block->pc) & ~0x3f)) /*Starts in second page*/
|
if (!((start_pc ^ block->pc) & ~0x3f)) /*Starts in second page*/
|
||||||
block->page_mask |= ((uint64_t)1 << (start_pc & PAGE_MASK_MASK));
|
block->page_mask |= ((uint64_t)1 << (start_pc & PAGE_MASK_MASK));
|
||||||
else
|
else
|
||||||
block->page_mask2 |= ((uint64_t)1 << (start_pc & PAGE_MASK_MASK));
|
block->page_mask2 |= ((uint64_t)1 << (start_pc & PAGE_MASK_MASK));
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!((start_pc ^ block->pc) & ~0xfff)) /*Starts in second page*/
|
if (!((start_pc ^ block->pc) & ~0xfff)) /*Starts in second page*/
|
||||||
block->page_mask |= ((uint64_t)1 << ((start_pc >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK));
|
block->page_mask |= ((uint64_t)1 << ((start_pc >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK));
|
||||||
else
|
else
|
||||||
block->page_mask2 |= ((uint64_t)1 << ((start_pc >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK));
|
block->page_mask2 |= ((uint64_t)1 << ((start_pc >> PAGE_MASK_SHIFT) & PAGE_MASK_MASK));
|
||||||
}
|
}
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
codegen_mark_code_present_multibyte(block, start_pc, len);
|
codegen_mark_code_present_multibyte(block, start_pc, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +287,8 @@ void codegen_set_op32();
|
|||||||
void codegen_flush();
|
void codegen_flush();
|
||||||
void codegen_check_flush(struct page_t *page, uint64_t mask, uint32_t phys_addr);
|
void codegen_check_flush(struct page_t *page, uint64_t mask, uint32_t phys_addr);
|
||||||
struct ir_data_t;
|
struct ir_data_t;
|
||||||
x86seg *codegen_generate_ea(struct ir_data_t *ir, x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc, uint32_t op_32, int stack_offset);
|
x86seg *codegen_generate_ea(struct ir_data_t *ir, x86seg *op_ea_seg, uint32_t fetchdat, int op_ssegs, uint32_t *op_pc,
|
||||||
|
uint32_t op_32, int stack_offset);
|
||||||
void codegen_check_seg_read(codeblock_t *block, struct ir_data_t *ir, x86seg *seg);
|
void codegen_check_seg_read(codeblock_t *block, struct ir_data_t *ir, x86seg *seg);
|
||||||
void codegen_check_seg_write(codeblock_t *block, struct ir_data_t *ir, x86seg *seg);
|
void codegen_check_seg_write(codeblock_t *block, struct ir_data_t *ir, x86seg *seg);
|
||||||
|
|
||||||
@@ -359,8 +319,7 @@ extern void (*codegen_timing_block_start)();
|
|||||||
extern void (*codegen_timing_block_end)();
|
extern void (*codegen_timing_block_end)();
|
||||||
extern int (*codegen_timing_jump_cycles)();
|
extern int (*codegen_timing_jump_cycles)();
|
||||||
|
|
||||||
typedef struct codegen_timing_t
|
typedef struct codegen_timing_t {
|
||||||
{
|
|
||||||
void (*start)();
|
void (*start)();
|
||||||
void (*prefix)(uint8_t prefix, uint32_t fetchdat);
|
void (*prefix)(uint8_t prefix, uint32_t fetchdat);
|
||||||
void (*opcode)(uint8_t opcode, uint32_t fetchdat, int op_32, uint32_t op_pc);
|
void (*opcode)(uint8_t opcode, uint32_t fetchdat, int op_32, uint32_t op_pc);
|
||||||
@@ -410,7 +369,7 @@ int codegen_get_instruction_uop(codeblock_t *block, uint32_t pc, int *first_inst
|
|||||||
void codegen_set_loop_start(struct ir_data_t *ir, int first_instruction);
|
void codegen_set_loop_start(struct ir_data_t *ir, int first_instruction);
|
||||||
|
|
||||||
#ifdef DEBUG_EXTRA
|
#ifdef DEBUG_EXTRA
|
||||||
extern uint32_t instr_counts[256*256];
|
extern uint32_t instr_counts[256 * 256];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,8 +1,7 @@
|
|||||||
#ifndef _CODEGEN_ACCUMULATE_H_
|
#ifndef _CODEGEN_ACCUMULATE_H_
|
||||||
#define _CODEGEN_ACCUMULATE_H_
|
#define _CODEGEN_ACCUMULATE_H_
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
ACCREG_ins = 0,
|
ACCREG_ins = 0,
|
||||||
ACCREG_cycles = 1,
|
ACCREG_cycles = 1,
|
||||||
|
|
||||||
@@ -15,5 +14,4 @@ void codegen_accumulate(int acc_reg, int delta);
|
|||||||
void codegen_accumulate_flush(struct ir_data_t *ir);
|
void codegen_accumulate_flush(struct ir_data_t *ir);
|
||||||
void codegen_accumulate_reset();
|
void codegen_accumulate_reset();
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_ACCUMULATE_H_ */
|
#endif /* _CODEGEN_ACCUMULATE_H_ */
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
#define MEM_BLOCK_NR 131072
|
#define MEM_BLOCK_NR 131072
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MEM_BLOCK_MASK (MEM_BLOCK_NR-1)
|
#define MEM_BLOCK_MASK (MEM_BLOCK_NR - 1)
|
||||||
#define MEM_BLOCK_SIZE 0x3c0
|
#define MEM_BLOCK_SIZE 0x3c0
|
||||||
|
|
||||||
void codegen_allocator_init();
|
void codegen_allocator_init();
|
||||||
|
@@ -31,8 +31,7 @@ extern const uOpFn uop_handlers[];
|
|||||||
/*Register will not be preserved across function calls*/
|
/*Register will not be preserved across function calls*/
|
||||||
#define HOST_REG_FLAG_VOLATILE (1 << 0)
|
#define HOST_REG_FLAG_VOLATILE (1 << 0)
|
||||||
|
|
||||||
typedef struct host_reg_def_t
|
typedef struct host_reg_def_t {
|
||||||
{
|
|
||||||
int reg;
|
int reg;
|
||||||
int flags;
|
int flags;
|
||||||
} host_reg_def_t;
|
} host_reg_def_t;
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
#define HASH_SIZE 0x20000
|
#define HASH_SIZE 0x20000
|
||||||
#define HASH_MASK 0x1ffff
|
#define HASH_MASK 0x1ffff
|
||||||
|
|
||||||
#define HASH(l) ((l) & 0x1ffff)
|
#define HASH(l) ((l)&0x1ffff)
|
||||||
|
|
||||||
#define BLOCK_MAX 0x3c0
|
#define BLOCK_MAX 0x3c0
|
||||||
|
|
||||||
@@ -26,5 +26,4 @@ void host_arm_nop(codeblock_t *block);
|
|||||||
|
|
||||||
void codegen_alloc(codeblock_t *block, int size);
|
void codegen_alloc(codeblock_t *block, int size);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_ARM_H_ */
|
#endif /* _CODEGEN_BACKEND_ARM_H_ */
|
||||||
|
@@ -10,11 +10,10 @@
|
|||||||
#define HASH_SIZE 0x20000
|
#define HASH_SIZE 0x20000
|
||||||
#define HASH_MASK 0x1ffff
|
#define HASH_MASK 0x1ffff
|
||||||
|
|
||||||
#define HASH(l) ((l) & 0x1ffff)
|
#define HASH(l) ((l)&0x1ffff)
|
||||||
|
|
||||||
#define BLOCK_MAX 0x3c0
|
#define BLOCK_MAX 0x3c0
|
||||||
|
|
||||||
|
|
||||||
void host_arm64_BLR(codeblock_t *block, int addr_reg);
|
void host_arm64_BLR(codeblock_t *block, int addr_reg);
|
||||||
void host_arm64_CBNZ(codeblock_t *block, int reg, uintptr_t dest);
|
void host_arm64_CBNZ(codeblock_t *block, int reg, uintptr_t dest);
|
||||||
void host_arm64_MOVK_IMM(codeblock_t *block, int reg, uint32_t imm_data);
|
void host_arm64_MOVK_IMM(codeblock_t *block, int reg, uint32_t imm_data);
|
||||||
@@ -33,5 +32,4 @@ void host_arm64_mov_imm(codeblock_t *block, int reg, uint32_t imm_data);
|
|||||||
|
|
||||||
uint32_t host_arm64_find_imm(uint32_t data);
|
uint32_t host_arm64_find_imm(uint32_t data);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_ARM64_H_ */
|
#endif /* _CODEGEN_BACKEND_ARM64_H_ */
|
||||||
|
@@ -137,5 +137,4 @@ extern void *codegen_fp_round_quad;
|
|||||||
extern void *codegen_gpf_rout;
|
extern void *codegen_gpf_rout;
|
||||||
extern void *codegen_exit_rout;
|
extern void *codegen_exit_rout;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_ARM64_DEFS_H_ */
|
#endif /* _CODEGEN_BACKEND_ARM64_DEFS_H_ */
|
||||||
|
@@ -254,17 +254,14 @@ void host_arm64_call(codeblock_t *block, void *dst_addr);
|
|||||||
void host_arm64_jump(codeblock_t *block, uintptr_t dst_addr);
|
void host_arm64_jump(codeblock_t *block, uintptr_t dst_addr);
|
||||||
void host_arm64_mov_imm(codeblock_t *block, int reg, uint32_t imm_data);
|
void host_arm64_mov_imm(codeblock_t *block, int reg, uint32_t imm_data);
|
||||||
|
|
||||||
|
#define in_range7_x(offset) (((offset) >= -0x200) && ((offset) < (0x200)) && !((offset)&7))
|
||||||
#define in_range7_x(offset) (((offset) >= -0x200) && ((offset) < (0x200)) && !((offset) & 7))
|
|
||||||
#define in_range12_b(offset) (((offset) >= 0) && ((offset) < 0x1000))
|
#define in_range12_b(offset) (((offset) >= 0) && ((offset) < 0x1000))
|
||||||
#define in_range12_h(offset) (((offset) >= 0) && ((offset) < 0x2000) && !((offset) & 1))
|
#define in_range12_h(offset) (((offset) >= 0) && ((offset) < 0x2000) && !((offset)&1))
|
||||||
#define in_range12_w(offset) (((offset) >= 0) && ((offset) < 0x4000) && !((offset) & 3))
|
#define in_range12_w(offset) (((offset) >= 0) && ((offset) < 0x4000) && !((offset)&3))
|
||||||
#define in_range12_q(offset) (((offset) >= 0) && ((offset) < 0x8000) && !((offset) & 7))
|
#define in_range12_q(offset) (((offset) >= 0) && ((offset) < 0x8000) && !((offset)&7))
|
||||||
|
|
||||||
|
|
||||||
void codegen_direct_read_8(codeblock_t *block, int host_reg, void *p);
|
void codegen_direct_read_8(codeblock_t *block, int host_reg, void *p);
|
||||||
|
|
||||||
void codegen_alloc(codeblock_t *block, int size);
|
void codegen_alloc(codeblock_t *block, int size);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_ARM64_OPS_H_ */
|
#endif /* _CODEGEN_BACKEND_ARM64_OPS_H_ */
|
||||||
|
@@ -66,8 +66,8 @@
|
|||||||
#define REG_MASK_LR (1 << REG_LR)
|
#define REG_MASK_LR (1 << REG_LR)
|
||||||
#define REG_MASK_PC (1 << REG_PC)
|
#define REG_MASK_PC (1 << REG_PC)
|
||||||
|
|
||||||
#define REG_MASK_LOCAL (REG_MASK_R4 | REG_MASK_R5 | REG_MASK_R6 | REG_MASK_R7 | \
|
#define REG_MASK_LOCAL \
|
||||||
REG_MASK_R8 | REG_MASK_R9 | REG_MASK_R10 | REG_MASK_R11)
|
(REG_MASK_R4 | REG_MASK_R5 | REG_MASK_R6 | REG_MASK_R7 | REG_MASK_R8 | REG_MASK_R9 | REG_MASK_R10 | REG_MASK_R11)
|
||||||
|
|
||||||
#define CODEGEN_HOST_REGS 7
|
#define CODEGEN_HOST_REGS 7
|
||||||
#define CODEGEN_HOST_FP_REGS 8
|
#define CODEGEN_HOST_FP_REGS 8
|
||||||
@@ -91,5 +91,4 @@ extern void *codegen_fp_round;
|
|||||||
extern void *codegen_gpf_rout;
|
extern void *codegen_gpf_rout;
|
||||||
extern void *codegen_exit_rout;
|
extern void *codegen_exit_rout;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_ARM_DEFS_H_ */
|
#endif /* _CODEGEN_BACKEND_ARM_DEFS_H_ */
|
||||||
|
@@ -105,7 +105,8 @@ void host_arm_ORR_IMM_cond(codeblock_t *block, uint32_t cond, int dst_reg, int s
|
|||||||
void host_arm_ORR_REG_LSL_cond(codeblock_t *block, uint32_t cond, int dst_reg, int src_reg_n, int src_reg_m, int shift);
|
void host_arm_ORR_REG_LSL_cond(codeblock_t *block, uint32_t cond, int dst_reg, int src_reg_n, int src_reg_m, int shift);
|
||||||
|
|
||||||
#define host_arm_ORR_IMM(block, dst_reg, src_reg, imm) host_arm_ORR_IMM_cond(block, COND_AL, dst_reg, src_reg, imm)
|
#define host_arm_ORR_IMM(block, dst_reg, src_reg, imm) host_arm_ORR_IMM_cond(block, COND_AL, dst_reg, src_reg, imm)
|
||||||
#define host_arm_ORR_REG_LSL(block, dst_reg, src_reg_a, src_reg_b, shift) host_arm_ORR_REG_LSL_cond(block, COND_AL, dst_reg, src_reg_a, src_reg_b, shift)
|
#define host_arm_ORR_REG_LSL(block, dst_reg, src_reg_a, src_reg_b, shift) \
|
||||||
|
host_arm_ORR_REG_LSL_cond(block, COND_AL, dst_reg, src_reg_a, src_reg_b, shift)
|
||||||
|
|
||||||
#define host_arm_ORRCC_IMM(block, dst_reg, src_reg, imm) host_arm_ORR_IMM_cond(block, COND_CC, dst_reg, src_reg, imm)
|
#define host_arm_ORRCC_IMM(block, dst_reg, src_reg, imm) host_arm_ORR_IMM_cond(block, COND_CC, dst_reg, src_reg, imm)
|
||||||
#define host_arm_ORREQ_IMM(block, dst_reg, src_reg, imm) host_arm_ORR_IMM_cond(block, COND_EQ, dst_reg, src_reg, imm)
|
#define host_arm_ORREQ_IMM(block, dst_reg, src_reg, imm) host_arm_ORR_IMM_cond(block, COND_EQ, dst_reg, src_reg, imm)
|
||||||
@@ -254,5 +255,4 @@ void host_arm_VZIP_D8(codeblock_t *block, int d_reg, int m_reg);
|
|||||||
void host_arm_VZIP_D16(codeblock_t *block, int d_reg, int m_reg);
|
void host_arm_VZIP_D16(codeblock_t *block, int d_reg, int m_reg);
|
||||||
void host_arm_VZIP_D32(codeblock_t *block, int d_reg, int m_reg);
|
void host_arm_VZIP_D32(codeblock_t *block, int d_reg, int m_reg);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_ARM_OPS_H_ */
|
#endif /* _CODEGEN_BACKEND_ARM_OPS_H_ */
|
||||||
|
@@ -10,11 +10,10 @@
|
|||||||
#define HASH_SIZE 0x20000
|
#define HASH_SIZE 0x20000
|
||||||
#define HASH_MASK 0x1ffff
|
#define HASH_MASK 0x1ffff
|
||||||
|
|
||||||
#define HASH(l) ((l) & 0x1ffff)
|
#define HASH(l) ((l)&0x1ffff)
|
||||||
|
|
||||||
#define BLOCK_MAX 0x3c0
|
#define BLOCK_MAX 0x3c0
|
||||||
|
|
||||||
#define CODEGEN_BACKEND_HAS_MOV_IMM
|
#define CODEGEN_BACKEND_HAS_MOV_IMM
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_64_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_64_H_ */
|
||||||
|
@@ -70,5 +70,4 @@ extern void *codegen_mem_store_double;
|
|||||||
extern void *codegen_gpf_rout;
|
extern void *codegen_gpf_rout;
|
||||||
extern void *codegen_exit_rout;
|
extern void *codegen_exit_rout;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_64_DEFS_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_64_DEFS_H_ */
|
||||||
|
@@ -198,5 +198,4 @@ void host_x86_XOR8_REG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
|||||||
void host_x86_XOR16_REG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_XOR16_REG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
void host_x86_XOR32_REG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_XOR32_REG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_64_OPS_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_64_OPS_H_ */
|
||||||
|
@@ -3,29 +3,23 @@
|
|||||||
|
|
||||||
#define JMP_LEN_BYTES 5
|
#define JMP_LEN_BYTES 5
|
||||||
|
|
||||||
static inline void codegen_addbyte(codeblock_t *block, uint8_t val)
|
static inline void codegen_addbyte(codeblock_t *block, uint8_t val) {
|
||||||
{
|
if (block_pos >= BLOCK_MAX) {
|
||||||
if (block_pos >= BLOCK_MAX)
|
|
||||||
{
|
|
||||||
fatal("codegen_addbyte over! %i\n", block_pos);
|
fatal("codegen_addbyte over! %i\n", block_pos);
|
||||||
// CPU_BLOCK_END();
|
// CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
block_write_data[block_pos++] = val;
|
block_write_data[block_pos++] = val;
|
||||||
}
|
}
|
||||||
static inline void codegen_addbyte2(codeblock_t *block, uint8_t vala, uint8_t valb)
|
static inline void codegen_addbyte2(codeblock_t *block, uint8_t vala, uint8_t valb) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 2)) {
|
||||||
if (block_pos > (BLOCK_MAX-2))
|
|
||||||
{
|
|
||||||
fatal("codegen_addbyte2 over! %i\n", block_pos);
|
fatal("codegen_addbyte2 over! %i\n", block_pos);
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
block_write_data[block_pos++] = vala;
|
block_write_data[block_pos++] = vala;
|
||||||
block_write_data[block_pos++] = valb;
|
block_write_data[block_pos++] = valb;
|
||||||
}
|
}
|
||||||
static inline void codegen_addbyte3(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc)
|
static inline void codegen_addbyte3(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 3)) {
|
||||||
if (block_pos > (BLOCK_MAX-3))
|
|
||||||
{
|
|
||||||
fatal("codegen_addbyte3 over! %i\n", block_pos);
|
fatal("codegen_addbyte3 over! %i\n", block_pos);
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
@@ -33,10 +27,8 @@ static inline void codegen_addbyte3(codeblock_t *block, uint8_t vala, uint8_t va
|
|||||||
block_write_data[block_pos++] = valb;
|
block_write_data[block_pos++] = valb;
|
||||||
block_write_data[block_pos++] = valc;
|
block_write_data[block_pos++] = valc;
|
||||||
}
|
}
|
||||||
static inline void codegen_addbyte4(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc, uint8_t vald)
|
static inline void codegen_addbyte4(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc, uint8_t vald) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 4)) {
|
||||||
if (block_pos > (BLOCK_MAX-4))
|
|
||||||
{
|
|
||||||
fatal("codegen_addbyte4 over! %i\n", block_pos);
|
fatal("codegen_addbyte4 over! %i\n", block_pos);
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
@@ -46,10 +38,8 @@ static inline void codegen_addbyte4(codeblock_t *block, uint8_t vala, uint8_t va
|
|||||||
block_write_data[block_pos++] = vald;
|
block_write_data[block_pos++] = vald;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_addword(codeblock_t *block, uint16_t val)
|
static inline void codegen_addword(codeblock_t *block, uint16_t val) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 2)) {
|
||||||
if (block_pos > (BLOCK_MAX-2))
|
|
||||||
{
|
|
||||||
fatal("codegen_addword over! %i\n", block_pos);
|
fatal("codegen_addword over! %i\n", block_pos);
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
@@ -57,10 +47,8 @@ static inline void codegen_addword(codeblock_t *block, uint16_t val)
|
|||||||
block_pos += 2;
|
block_pos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_addlong(codeblock_t *block, uint32_t val)
|
static inline void codegen_addlong(codeblock_t *block, uint32_t val) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 4)) {
|
||||||
if (block_pos > (BLOCK_MAX-4))
|
|
||||||
{
|
|
||||||
fatal("codegen_addlong over! %i\n", block_pos);
|
fatal("codegen_addlong over! %i\n", block_pos);
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
@@ -68,10 +56,8 @@ static inline void codegen_addlong(codeblock_t *block, uint32_t val)
|
|||||||
block_pos += 4;
|
block_pos += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_addquad(codeblock_t *block, uint64_t val)
|
static inline void codegen_addquad(codeblock_t *block, uint64_t val) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 8)) {
|
||||||
if (block_pos > (BLOCK_MAX-8))
|
|
||||||
{
|
|
||||||
fatal("codegen_addquad over! %i\n", block_pos);
|
fatal("codegen_addquad over! %i\n", block_pos);
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
}
|
}
|
||||||
@@ -79,10 +65,8 @@ static inline void codegen_addquad(codeblock_t *block, uint64_t val)
|
|||||||
block_pos += 8;
|
block_pos += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_alloc_bytes(codeblock_t *block, int size)
|
static inline void codegen_alloc_bytes(codeblock_t *block, int size) {
|
||||||
{
|
if (block_pos > ((BLOCK_MAX - size) - JMP_LEN_BYTES)) {
|
||||||
if (block_pos > ((BLOCK_MAX - size) - JMP_LEN_BYTES))
|
|
||||||
{
|
|
||||||
/*Current block is full. Allocate a new block*/
|
/*Current block is full. Allocate a new block*/
|
||||||
struct mem_block_t *new_block = codegen_allocator_allocate(block->head_mem_block, get_block_nr(block));
|
struct mem_block_t *new_block = codegen_allocator_allocate(block->head_mem_block, get_block_nr(block));
|
||||||
uint8_t *new_ptr = codeblock_allocator_get_ptr(new_block);
|
uint8_t *new_ptr = codeblock_allocator_get_ptr(new_block);
|
||||||
@@ -97,12 +81,10 @@ static inline void codegen_alloc_bytes(codeblock_t *block, int size)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int is_imm8(uint32_t imm_data)
|
static inline int is_imm8(uint32_t imm_data) {
|
||||||
{
|
|
||||||
if (imm_data <= 0x7f || imm_data >= 0xffffff80)
|
if (imm_data <= 0x7f || imm_data >= 0xffffff80)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_64_OPS_HELPERS_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_64_OPS_HELPERS_H_ */
|
||||||
|
@@ -36,11 +36,13 @@ void host_x86_MOVD_XREG_BASE_INDEX(codeblock_t *block, int dst_reg, int base_reg
|
|||||||
void host_x86_MOVD_XREG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_MOVD_XREG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
|
|
||||||
void host_x86_MOVQ_ABS_XREG(codeblock_t *block, void *p, int src_reg);
|
void host_x86_MOVQ_ABS_XREG(codeblock_t *block, void *p, int src_reg);
|
||||||
void host_x86_MOVQ_ABS_REG_REG_SHIFT_XREG(codeblock_t *block, uint32_t addr, int src_reg_a, int src_reg_b, int shift, int src_reg);
|
void host_x86_MOVQ_ABS_REG_REG_SHIFT_XREG(codeblock_t *block, uint32_t addr, int src_reg_a, int src_reg_b, int shift,
|
||||||
|
int src_reg);
|
||||||
void host_x86_MOVQ_BASE_INDEX_XREG(codeblock_t *block, int base_reg, int idx_reg, int src_reg);
|
void host_x86_MOVQ_BASE_INDEX_XREG(codeblock_t *block, int base_reg, int idx_reg, int src_reg);
|
||||||
void host_x86_MOVQ_BASE_OFFSET_XREG(codeblock_t *block, int base_reg, int offset, int src_reg);
|
void host_x86_MOVQ_BASE_OFFSET_XREG(codeblock_t *block, int base_reg, int offset, int src_reg);
|
||||||
void host_x86_MOVQ_XREG_ABS(codeblock_t *block, int dst_reg, void *p);
|
void host_x86_MOVQ_XREG_ABS(codeblock_t *block, int dst_reg, void *p);
|
||||||
void host_x86_MOVQ_XREG_ABS_REG_REG_SHIFT(codeblock_t *block, int dst_reg, uint32_t addr, int src_reg_a, int src_reg_b, int shift);
|
void host_x86_MOVQ_XREG_ABS_REG_REG_SHIFT(codeblock_t *block, int dst_reg, uint32_t addr, int src_reg_a, int src_reg_b,
|
||||||
|
int shift);
|
||||||
void host_x86_MOVQ_XREG_BASE_INDEX(codeblock_t *block, int dst_reg, int base_reg, int idx_reg);
|
void host_x86_MOVQ_XREG_BASE_INDEX(codeblock_t *block, int dst_reg, int base_reg, int idx_reg);
|
||||||
void host_x86_MOVQ_XREG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, int offset);
|
void host_x86_MOVQ_XREG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, int offset);
|
||||||
|
|
||||||
@@ -116,5 +118,4 @@ void host_x86_SUBSD_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
|||||||
|
|
||||||
void host_x86_UNPCKLPS_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_UNPCKLPS_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_64_OPS_SSE_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_64_OPS_SSE_H_ */
|
||||||
|
@@ -10,11 +10,10 @@
|
|||||||
#define HASH_SIZE 0x20000
|
#define HASH_SIZE 0x20000
|
||||||
#define HASH_MASK 0x1ffff
|
#define HASH_MASK 0x1ffff
|
||||||
|
|
||||||
#define HASH(l) ((l) & 0x1ffff)
|
#define HASH(l) ((l)&0x1ffff)
|
||||||
|
|
||||||
#define BLOCK_MAX 0x3c0
|
#define BLOCK_MAX 0x3c0
|
||||||
|
|
||||||
#define CODEGEN_BACKEND_HAS_MOV_IMM
|
#define CODEGEN_BACKEND_HAS_MOV_IMM
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_H_ */
|
||||||
|
@@ -197,5 +197,4 @@ void host_x86_XOR8_REG_IMM(codeblock_t *block, int dst_reg, uint8_t imm_data);
|
|||||||
void host_x86_XOR16_REG_IMM(codeblock_t *block, int dst_reg, uint16_t imm_data);
|
void host_x86_XOR16_REG_IMM(codeblock_t *block, int dst_reg, uint16_t imm_data);
|
||||||
void host_x86_XOR32_REG_IMM(codeblock_t *block, int dst_reg, uint32_t imm_data);
|
void host_x86_XOR32_REG_IMM(codeblock_t *block, int dst_reg, uint32_t imm_data);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_OPS_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_OPS_H_ */
|
||||||
|
@@ -7,5 +7,4 @@ void host_x87_FLDCW(codeblock_t *block, void *p);
|
|||||||
void host_x87_FLDd_BASE(codeblock_t *block, int base_reg);
|
void host_x87_FLDd_BASE(codeblock_t *block, int base_reg);
|
||||||
void host_x87_FSTPd_BASE(codeblock_t *block, int base_reg);
|
void host_x87_FSTPd_BASE(codeblock_t *block, int base_reg);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_OPS_FPU_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_OPS_FPU_H_ */
|
||||||
|
@@ -3,30 +3,26 @@
|
|||||||
|
|
||||||
#define JMP_LEN_BYTES 5
|
#define JMP_LEN_BYTES 5
|
||||||
|
|
||||||
static inline void codegen_addbyte(codeblock_t *block, uint8_t val)
|
static inline void codegen_addbyte(codeblock_t *block, uint8_t val) {
|
||||||
{
|
|
||||||
if (block_pos >= BLOCK_MAX)
|
if (block_pos >= BLOCK_MAX)
|
||||||
fatal("codegen_addbyte over! %i\n", block_pos);
|
fatal("codegen_addbyte over! %i\n", block_pos);
|
||||||
block_write_data[block_pos++] = val;
|
block_write_data[block_pos++] = val;
|
||||||
}
|
}
|
||||||
static inline void codegen_addbyte2(codeblock_t *block, uint8_t vala, uint8_t valb)
|
static inline void codegen_addbyte2(codeblock_t *block, uint8_t vala, uint8_t valb) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 2))
|
||||||
if (block_pos > (BLOCK_MAX-2))
|
|
||||||
fatal("codegen_addbyte2 over! %i\n", block_pos);
|
fatal("codegen_addbyte2 over! %i\n", block_pos);
|
||||||
block_write_data[block_pos++] = vala;
|
block_write_data[block_pos++] = vala;
|
||||||
block_write_data[block_pos++] = valb;
|
block_write_data[block_pos++] = valb;
|
||||||
}
|
}
|
||||||
static inline void codegen_addbyte3(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc)
|
static inline void codegen_addbyte3(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 3))
|
||||||
if (block_pos > (BLOCK_MAX-3))
|
|
||||||
fatal("codegen_addbyte3 over! %i\n", block_pos);
|
fatal("codegen_addbyte3 over! %i\n", block_pos);
|
||||||
block_write_data[block_pos++] = vala;
|
block_write_data[block_pos++] = vala;
|
||||||
block_write_data[block_pos++] = valb;
|
block_write_data[block_pos++] = valb;
|
||||||
block_write_data[block_pos++] = valc;
|
block_write_data[block_pos++] = valc;
|
||||||
}
|
}
|
||||||
static inline void codegen_addbyte4(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc, uint8_t vald)
|
static inline void codegen_addbyte4(codeblock_t *block, uint8_t vala, uint8_t valb, uint8_t valc, uint8_t vald) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 4))
|
||||||
if (block_pos > (BLOCK_MAX-4))
|
|
||||||
fatal("codegen_addbyte4 over! %i\n", block_pos);
|
fatal("codegen_addbyte4 over! %i\n", block_pos);
|
||||||
block_write_data[block_pos++] = vala;
|
block_write_data[block_pos++] = vala;
|
||||||
block_write_data[block_pos++] = valb;
|
block_write_data[block_pos++] = valb;
|
||||||
@@ -34,32 +30,28 @@ static inline void codegen_addbyte4(codeblock_t *block, uint8_t vala, uint8_t va
|
|||||||
block_write_data[block_pos++] = vald;
|
block_write_data[block_pos++] = vald;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_addword(codeblock_t *block, uint16_t val)
|
static inline void codegen_addword(codeblock_t *block, uint16_t val) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 2))
|
||||||
if (block_pos > (BLOCK_MAX-2))
|
|
||||||
fatal("codegen_addword over! %i\n", block_pos);
|
fatal("codegen_addword over! %i\n", block_pos);
|
||||||
*(uint16_t *)&block_write_data[block_pos] = val;
|
*(uint16_t *)&block_write_data[block_pos] = val;
|
||||||
block_pos += 2;
|
block_pos += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_addlong(codeblock_t *block, uint32_t val)
|
static inline void codegen_addlong(codeblock_t *block, uint32_t val) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 4))
|
||||||
if (block_pos > (BLOCK_MAX-4))
|
|
||||||
fatal("codegen_addlong over! %i\n", block_pos);
|
fatal("codegen_addlong over! %i\n", block_pos);
|
||||||
*(uint32_t *)&block_write_data[block_pos] = val;
|
*(uint32_t *)&block_write_data[block_pos] = val;
|
||||||
block_pos += 4;
|
block_pos += 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_addquad(codeblock_t *block, uint64_t val)
|
static inline void codegen_addquad(codeblock_t *block, uint64_t val) {
|
||||||
{
|
if (block_pos > (BLOCK_MAX - 8))
|
||||||
if (block_pos > (BLOCK_MAX-8))
|
|
||||||
fatal("codegen_addquad over! %i\n", block_pos);
|
fatal("codegen_addquad over! %i\n", block_pos);
|
||||||
*(uint64_t *)&block_write_data[block_pos] = val;
|
*(uint64_t *)&block_write_data[block_pos] = val;
|
||||||
block_pos += 8;
|
block_pos += 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void codegen_allocate_new_block(codeblock_t *block)
|
static void codegen_allocate_new_block(codeblock_t *block) {
|
||||||
{
|
|
||||||
/*Current block is full. Allocate a new block*/
|
/*Current block is full. Allocate a new block*/
|
||||||
struct mem_block_t *new_block = codegen_allocator_allocate(block->head_mem_block, get_block_nr(block));
|
struct mem_block_t *new_block = codegen_allocator_allocate(block->head_mem_block, get_block_nr(block));
|
||||||
uint8_t *new_ptr = codeblock_allocator_get_ptr(new_block);
|
uint8_t *new_ptr = codeblock_allocator_get_ptr(new_block);
|
||||||
@@ -73,18 +65,15 @@ static void codegen_allocate_new_block(codeblock_t *block)
|
|||||||
block_write_data = new_ptr;
|
block_write_data = new_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void codegen_alloc_bytes(codeblock_t *block, int size)
|
static inline void codegen_alloc_bytes(codeblock_t *block, int size) {
|
||||||
{
|
|
||||||
if (block_pos > ((BLOCK_MAX - size) - JMP_LEN_BYTES))
|
if (block_pos > ((BLOCK_MAX - size) - JMP_LEN_BYTES))
|
||||||
codegen_allocate_new_block(block);
|
codegen_allocate_new_block(block);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int is_imm8(uint32_t imm_data)
|
static inline int is_imm8(uint32_t imm_data) {
|
||||||
{
|
|
||||||
if (imm_data <= 0x7f || imm_data >= 0xffffff80)
|
if (imm_data <= 0x7f || imm_data >= 0xffffff80)
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_OPS_HELPERS_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_OPS_HELPERS_H_ */
|
||||||
|
@@ -36,13 +36,15 @@ void host_x86_MOVD_XREG_BASE_INDEX(codeblock_t *block, int dst_reg, int base_reg
|
|||||||
void host_x86_MOVD_XREG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_MOVD_XREG_REG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
|
|
||||||
void host_x86_MOVQ_ABS_XREG(codeblock_t *block, void *p, int src_reg);
|
void host_x86_MOVQ_ABS_XREG(codeblock_t *block, void *p, int src_reg);
|
||||||
void host_x86_MOVQ_ABS_REG_REG_SHIFT_XREG(codeblock_t *block, uint32_t addr, int src_reg_a, int src_reg_b, int shift, int src_reg);
|
void host_x86_MOVQ_ABS_REG_REG_SHIFT_XREG(codeblock_t *block, uint32_t addr, int src_reg_a, int src_reg_b, int shift,
|
||||||
|
int src_reg);
|
||||||
void host_x86_MOVQ_BASE_INDEX_XREG(codeblock_t *block, int base_reg, int idx_reg, int src_reg);
|
void host_x86_MOVQ_BASE_INDEX_XREG(codeblock_t *block, int base_reg, int idx_reg, int src_reg);
|
||||||
void host_x86_MOVQ_BASE_OFFSET_XREG(codeblock_t *block, int base_reg, int offset, int src_reg);
|
void host_x86_MOVQ_BASE_OFFSET_XREG(codeblock_t *block, int base_reg, int offset, int src_reg);
|
||||||
void host_x86_MOVQ_STACK_OFFSET_XREG(codeblock_t *block, int offset, int src_reg);
|
void host_x86_MOVQ_STACK_OFFSET_XREG(codeblock_t *block, int offset, int src_reg);
|
||||||
|
|
||||||
void host_x86_MOVQ_XREG_ABS(codeblock_t *block, int dst_reg, void *p);
|
void host_x86_MOVQ_XREG_ABS(codeblock_t *block, int dst_reg, void *p);
|
||||||
void host_x86_MOVQ_XREG_ABS_REG_REG_SHIFT(codeblock_t *block, int dst_reg, uint32_t addr, int src_reg_a, int src_reg_b, int shift);
|
void host_x86_MOVQ_XREG_ABS_REG_REG_SHIFT(codeblock_t *block, int dst_reg, uint32_t addr, int src_reg_a, int src_reg_b,
|
||||||
|
int shift);
|
||||||
void host_x86_MOVQ_XREG_BASE_INDEX(codeblock_t *block, int dst_reg, int base_reg, int idx_reg);
|
void host_x86_MOVQ_XREG_BASE_INDEX(codeblock_t *block, int dst_reg, int base_reg, int idx_reg);
|
||||||
void host_x86_MOVQ_XREG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, int offset);
|
void host_x86_MOVQ_XREG_BASE_OFFSET(codeblock_t *block, int dst_reg, int base_reg, int offset);
|
||||||
void host_x86_MOVQ_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_MOVQ_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
@@ -113,5 +115,4 @@ void host_x86_SUBSD_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
|||||||
|
|
||||||
void host_x86_UNPCKLPS_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
void host_x86_UNPCKLPS_XREG_XREG(codeblock_t *block, int dst_reg, int src_reg);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_BACKEND_X86_OPS_SSE_H_ */
|
#endif /* _CODEGEN_BACKEND_X86_OPS_SSE_H_ */
|
||||||
|
@@ -8,5 +8,4 @@ ir_data_t *codegen_ir_init();
|
|||||||
void codegen_ir_set_unroll(int count, int start, int first_instruction);
|
void codegen_ir_set_unroll(int count, int start, int first_instruction);
|
||||||
void codegen_ir_compile(ir_data_t *ir, codeblock_t *block);
|
void codegen_ir_compile(ir_data_t *ir, codeblock_t *block);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_IR_H_ */
|
#endif /* _CODEGEN_IR_H_ */
|
||||||
|
@@ -32,7 +32,6 @@
|
|||||||
at compile time.*/
|
at compile time.*/
|
||||||
#define UOP_TYPE_JUMP_DEST (1 << 25)
|
#define UOP_TYPE_JUMP_DEST (1 << 25)
|
||||||
|
|
||||||
|
|
||||||
#define UOP_LOAD_FUNC_ARG_0 (UOP_TYPE_PARAMS_REGS | 0x00)
|
#define UOP_LOAD_FUNC_ARG_0 (UOP_TYPE_PARAMS_REGS | 0x00)
|
||||||
#define UOP_LOAD_FUNC_ARG_1 (UOP_TYPE_PARAMS_REGS | 0x01)
|
#define UOP_LOAD_FUNC_ARG_1 (UOP_TYPE_PARAMS_REGS | 0x01)
|
||||||
#define UOP_LOAD_FUNC_ARG_2 (UOP_TYPE_PARAMS_REGS | 0x02)
|
#define UOP_LOAD_FUNC_ARG_2 (UOP_TYPE_PARAMS_REGS | 0x02)
|
||||||
@@ -160,40 +159,55 @@
|
|||||||
#define UOP_ROR_IMM (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | 0x59)
|
#define UOP_ROR_IMM (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | 0x59)
|
||||||
|
|
||||||
/*UOP_CMP_IMM_JZ_DEST - if (src_reg_a == imm_data) then jump to ptr*/
|
/*UOP_CMP_IMM_JZ_DEST - if (src_reg_a == imm_data) then jump to ptr*/
|
||||||
#define UOP_CMP_IMM_JZ_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x60 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_IMM_JZ_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x60 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_IMM_JNZ_DEST - if (src_reg_a != imm_data) then jump to ptr*/
|
/*UOP_CMP_IMM_JNZ_DEST - if (src_reg_a != imm_data) then jump to ptr*/
|
||||||
#define UOP_CMP_IMM_JNZ_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x61 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_IMM_JNZ_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x61 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
|
|
||||||
/*UOP_CMP_JB_DEST - if (src_reg_a < src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JB_DEST - if (src_reg_a < src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JB_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x62 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JB_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x62 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JNB_DEST - if (src_reg_a >= src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JNB_DEST - if (src_reg_a >= src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JNB_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x63 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JNB_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x63 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JO_DEST - if (src_reg_a < src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JO_DEST - if (src_reg_a < src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JO_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x64 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JO_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x64 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JNO_DEST - if (src_reg_a >= src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JNO_DEST - if (src_reg_a >= src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JNO_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x65 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JNO_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x65 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JZ_DEST - if (src_reg_a == src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JZ_DEST - if (src_reg_a == src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JZ_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x66 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JZ_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x66 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JNZ_DEST - if (src_reg_a != src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JNZ_DEST - if (src_reg_a != src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JNZ_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x67 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JNZ_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x67 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JL_DEST - if (signed)(src_reg_a < src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JL_DEST - if (signed)(src_reg_a < src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JL_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x68 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JL_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x68 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JNL_DEST - if (signed)(src_reg_a >= src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JNL_DEST - if (signed)(src_reg_a >= src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JNL_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x69 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JNL_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x69 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JBE_DEST - if (src_reg_a <= src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JBE_DEST - if (src_reg_a <= src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JBE_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6a | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JBE_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6a | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JNBE_DEST - if (src_reg_a > src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JNBE_DEST - if (src_reg_a > src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JNBE_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6b | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JNBE_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6b | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JLE_DEST - if (signed)(src_reg_a <= src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JLE_DEST - if (signed)(src_reg_a <= src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JLE_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6c | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JLE_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6c | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_CMP_JNLE_DEST - if (signed)(src_reg_a > src_reg_b) then jump to ptr*/
|
/*UOP_CMP_JNLE_DEST - if (signed)(src_reg_a > src_reg_b) then jump to ptr*/
|
||||||
#define UOP_CMP_JNLE_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6d | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_CMP_JNLE_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x6d | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
|
|
||||||
/*UOP_TEST_JNS_DEST - if (src_reg_a positive) then jump to ptr*/
|
/*UOP_TEST_JNS_DEST - if (src_reg_a positive) then jump to ptr*/
|
||||||
#define UOP_TEST_JNS_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x70 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_TEST_JNS_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x70 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
/*UOP_TEST_JS_DEST - if (src_reg_a positive) then jump to ptr*/
|
/*UOP_TEST_JS_DEST - if (src_reg_a positive) then jump to ptr*/
|
||||||
#define UOP_TEST_JS_DEST (UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x71 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
#define UOP_TEST_JS_DEST \
|
||||||
|
(UOP_TYPE_PARAMS_REGS | UOP_TYPE_PARAMS_IMM | UOP_TYPE_PARAMS_POINTER | 0x71 | UOP_TYPE_ORDER_BARRIER | UOP_TYPE_JUMP)
|
||||||
|
|
||||||
/*UOP_FP_ENTER - must be called before any FPU register accessed*/
|
/*UOP_FP_ENTER - must be called before any FPU register accessed*/
|
||||||
#define UOP_FP_ENTER (UOP_TYPE_PARAMS_IMM | 0x80 | UOP_TYPE_BARRIER)
|
#define UOP_FP_ENTER (UOP_TYPE_PARAMS_IMM | 0x80 | UOP_TYPE_BARRIER)
|
||||||
@@ -332,8 +346,7 @@
|
|||||||
|
|
||||||
#define UOP_MASK 0xffff
|
#define UOP_MASK 0xffff
|
||||||
|
|
||||||
typedef struct uop_t
|
typedef struct uop_t {
|
||||||
{
|
|
||||||
uint32_t type;
|
uint32_t type;
|
||||||
ir_reg_t dest_reg_a;
|
ir_reg_t dest_reg_a;
|
||||||
ir_reg_t src_reg_a;
|
ir_reg_t src_reg_a;
|
||||||
@@ -351,15 +364,13 @@ typedef struct uop_t
|
|||||||
|
|
||||||
#define UOP_NR_MAX 4096
|
#define UOP_NR_MAX 4096
|
||||||
|
|
||||||
typedef struct ir_data_t
|
typedef struct ir_data_t {
|
||||||
{
|
|
||||||
uop_t uops[UOP_NR_MAX];
|
uop_t uops[UOP_NR_MAX];
|
||||||
int wr_pos;
|
int wr_pos;
|
||||||
struct codeblock_t *block;
|
struct codeblock_t *block;
|
||||||
} ir_data_t;
|
} ir_data_t;
|
||||||
|
|
||||||
static inline uop_t *uop_alloc(ir_data_t *ir, uint32_t uop_type)
|
static inline uop_t *uop_alloc(ir_data_t *ir, uint32_t uop_type) {
|
||||||
{
|
|
||||||
uop_t *uop;
|
uop_t *uop;
|
||||||
|
|
||||||
if (ir->wr_pos >= UOP_NR_MAX)
|
if (ir->wr_pos >= UOP_NR_MAX)
|
||||||
@@ -383,53 +394,47 @@ static inline uop_t *uop_alloc(ir_data_t *ir, uint32_t uop_type)
|
|||||||
return uop;
|
return uop;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_set_jump_dest(ir_data_t *ir, int jump_uop)
|
static inline void uop_set_jump_dest(ir_data_t *ir, int jump_uop) {
|
||||||
{
|
|
||||||
uop_t *uop = &ir->uops[jump_uop];
|
uop_t *uop = &ir->uops[jump_uop];
|
||||||
|
|
||||||
uop->jump_dest_uop = ir->wr_pos;
|
uop->jump_dest_uop = ir->wr_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int uop_gen(uint32_t uop_type, ir_data_t *ir)
|
static inline int uop_gen(uint32_t uop_type, ir_data_t *ir) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
|
|
||||||
return ir->wr_pos-1;
|
return ir->wr_pos - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int uop_gen_reg_src1(uint32_t uop_type, ir_data_t *ir, int src_reg_a)
|
static inline int uop_gen_reg_src1(uint32_t uop_type, ir_data_t *ir, int src_reg_a) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
uop->src_reg_a = codegen_reg_read(src_reg_a);
|
uop->src_reg_a = codegen_reg_read(src_reg_a);
|
||||||
|
|
||||||
return ir->wr_pos-1;
|
return ir->wr_pos - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src1_arg(uint32_t uop_type, ir_data_t *ir, int arg, int src_reg_a)
|
static inline void uop_gen_reg_src1_arg(uint32_t uop_type, ir_data_t *ir, int arg, int src_reg_a) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
uop->src_reg_a = codegen_reg_read(src_reg_a);
|
uop->src_reg_a = codegen_reg_read(src_reg_a);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int uop_gen_reg_src1_imm(uint32_t uop_type, ir_data_t *ir, int src_reg, uint32_t imm)
|
static inline int uop_gen_reg_src1_imm(uint32_t uop_type, ir_data_t *ir, int src_reg, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
uop->src_reg_a = codegen_reg_read(src_reg);
|
uop->src_reg_a = codegen_reg_read(src_reg);
|
||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
|
|
||||||
return ir->wr_pos-1;
|
return ir->wr_pos - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, uint32_t imm)
|
static inline void uop_gen_reg_dst_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -437,8 +442,7 @@ static inline void uop_gen_reg_dst_imm(uint32_t uop_type, ir_data_t *ir, int des
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_pointer(uint32_t uop_type, ir_data_t *ir, int dest_reg, void *p)
|
static inline void uop_gen_reg_dst_pointer(uint32_t uop_type, ir_data_t *ir, int dest_reg, void *p) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -446,8 +450,7 @@ static inline void uop_gen_reg_dst_pointer(uint32_t uop_type, ir_data_t *ir, int
|
|||||||
uop->p = p;
|
uop->p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_src1(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg)
|
static inline void uop_gen_reg_dst_src1(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -455,8 +458,7 @@ static inline void uop_gen_reg_dst_src1(uint32_t uop_type, ir_data_t *ir, int de
|
|||||||
uop->dest_reg_a = codegen_reg_write(dest_reg, ir->wr_pos - 1);
|
uop->dest_reg_a = codegen_reg_write(dest_reg, ir->wr_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_src1_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, uint32_t imm)
|
static inline void uop_gen_reg_dst_src1_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -465,8 +467,7 @@ static inline void uop_gen_reg_dst_src1_imm(uint32_t uop_type, ir_data_t *ir, in
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_src2(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, int src_reg_b)
|
static inline void uop_gen_reg_dst_src2(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, int src_reg_b) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -475,8 +476,8 @@ static inline void uop_gen_reg_dst_src2(uint32_t uop_type, ir_data_t *ir, int de
|
|||||||
uop->dest_reg_a = codegen_reg_write(dest_reg, ir->wr_pos - 1);
|
uop->dest_reg_a = codegen_reg_write(dest_reg, ir->wr_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_src2_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, int src_reg_b, uint32_t imm)
|
static inline void uop_gen_reg_dst_src2_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, int src_reg_b,
|
||||||
{
|
uint32_t imm) {
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -486,8 +487,8 @@ static inline void uop_gen_reg_dst_src2_imm(uint32_t uop_type, ir_data_t *ir, in
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_src3(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, int src_reg_b, int src_reg_c)
|
static inline void uop_gen_reg_dst_src3(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg_a, int src_reg_b,
|
||||||
{
|
int src_reg_c) {
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -497,8 +498,7 @@ static inline void uop_gen_reg_dst_src3(uint32_t uop_type, ir_data_t *ir, int de
|
|||||||
uop->dest_reg_a = codegen_reg_write(dest_reg, ir->wr_pos - 1);
|
uop->dest_reg_a = codegen_reg_write(dest_reg, ir->wr_pos - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_dst_src_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg, uint32_t imm)
|
static inline void uop_gen_reg_dst_src_imm(uint32_t uop_type, ir_data_t *ir, int dest_reg, int src_reg, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -507,19 +507,17 @@ static inline void uop_gen_reg_dst_src_imm(uint32_t uop_type, ir_data_t *ir, int
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int uop_gen_reg_src2(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b)
|
static inline int uop_gen_reg_src2(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
uop->src_reg_a = codegen_reg_read(src_reg_a);
|
uop->src_reg_a = codegen_reg_read(src_reg_a);
|
||||||
uop->src_reg_b = codegen_reg_read(src_reg_b);
|
uop->src_reg_b = codegen_reg_read(src_reg_b);
|
||||||
|
|
||||||
return ir->wr_pos-1;
|
return ir->wr_pos - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src2_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, uint32_t imm)
|
static inline void uop_gen_reg_src2_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -528,8 +526,7 @@ static inline void uop_gen_reg_src2_imm(uint32_t uop_type, ir_data_t *ir, int sr
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src3(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, int src_reg_c)
|
static inline void uop_gen_reg_src3(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, int src_reg_c) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -538,8 +535,8 @@ static inline void uop_gen_reg_src3(uint32_t uop_type, ir_data_t *ir, int src_re
|
|||||||
uop->src_reg_c = codegen_reg_read(src_reg_c);
|
uop->src_reg_c = codegen_reg_read(src_reg_c);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, int src_reg_c, uint32_t imm)
|
static inline void uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, int src_reg_c,
|
||||||
{
|
uint32_t imm) {
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -549,24 +546,21 @@ static inline void uop_gen_reg_src3_imm(uint32_t uop_type, ir_data_t *ir, int sr
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm)
|
static inline void uop_gen_imm(uint32_t uop_type, ir_data_t *ir, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_pointer(uint32_t uop_type, ir_data_t *ir, void *p)
|
static inline void uop_gen_pointer(uint32_t uop_type, ir_data_t *ir, void *p) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
uop->p = p;
|
uop->p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_pointer_imm(uint32_t uop_type, ir_data_t *ir, void *p, uint32_t imm)
|
static inline void uop_gen_pointer_imm(uint32_t uop_type, ir_data_t *ir, void *p, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -574,8 +568,7 @@ static inline void uop_gen_pointer_imm(uint32_t uop_type, ir_data_t *ir, void *p
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src_pointer(uint32_t uop_type, ir_data_t *ir, int src_reg_a, void *p)
|
static inline void uop_gen_reg_src_pointer(uint32_t uop_type, ir_data_t *ir, int src_reg_a, void *p) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -583,8 +576,7 @@ static inline void uop_gen_reg_src_pointer(uint32_t uop_type, ir_data_t *ir, int
|
|||||||
uop->p = p;
|
uop->p = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src_pointer_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, void *p, uint32_t imm)
|
static inline void uop_gen_reg_src_pointer_imm(uint32_t uop_type, ir_data_t *ir, int src_reg_a, void *p, uint32_t imm) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -593,8 +585,7 @@ static inline void uop_gen_reg_src_pointer_imm(uint32_t uop_type, ir_data_t *ir,
|
|||||||
uop->imm_data = imm;
|
uop->imm_data = imm;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, void *p)
|
static inline void uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, int src_reg_a, int src_reg_b, void *p) {
|
||||||
{
|
|
||||||
uop_t *uop = uop_alloc(ir, uop_type);
|
uop_t *uop = uop_alloc(ir, uop_type);
|
||||||
|
|
||||||
uop->type = uop_type;
|
uop->type = uop_type;
|
||||||
@@ -609,7 +600,8 @@ static inline void uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, in
|
|||||||
|
|
||||||
#define uop_ADD(ir, dst_reg, src_reg_a, src_reg_b) uop_gen_reg_dst_src2(UOP_ADD, ir, dst_reg, src_reg_a, src_reg_b)
|
#define uop_ADD(ir, dst_reg, src_reg_a, src_reg_b) uop_gen_reg_dst_src2(UOP_ADD, ir, dst_reg, src_reg_a, src_reg_b)
|
||||||
#define uop_ADD_IMM(ir, dst_reg, src_reg, imm) uop_gen_reg_dst_src_imm(UOP_ADD_IMM, ir, dst_reg, src_reg, imm)
|
#define uop_ADD_IMM(ir, dst_reg, src_reg, imm) uop_gen_reg_dst_src_imm(UOP_ADD_IMM, ir, dst_reg, src_reg, imm)
|
||||||
#define uop_ADD_LSHIFT(ir, dst_reg, src_reg_a, src_reg_b, shift) uop_gen_reg_dst_src2_imm(UOP_ADD_LSHIFT, ir, dst_reg, src_reg_a, src_reg_b, shift)
|
#define uop_ADD_LSHIFT(ir, dst_reg, src_reg_a, src_reg_b, shift) \
|
||||||
|
uop_gen_reg_dst_src2_imm(UOP_ADD_LSHIFT, ir, dst_reg, src_reg_a, src_reg_b, shift)
|
||||||
#define uop_AND(ir, dst_reg, src_reg_a, src_reg_b) uop_gen_reg_dst_src2(UOP_AND, ir, dst_reg, src_reg_a, src_reg_b)
|
#define uop_AND(ir, dst_reg, src_reg_a, src_reg_b) uop_gen_reg_dst_src2(UOP_AND, ir, dst_reg, src_reg_a, src_reg_b)
|
||||||
#define uop_AND_IMM(ir, dst_reg, src_reg, imm) uop_gen_reg_dst_src_imm(UOP_AND_IMM, ir, dst_reg, src_reg, imm)
|
#define uop_AND_IMM(ir, dst_reg, src_reg, imm) uop_gen_reg_dst_src_imm(UOP_AND_IMM, ir, dst_reg, src_reg, imm)
|
||||||
#define uop_ANDN(ir, dst_reg, src_reg_a, src_reg_b) uop_gen_reg_dst_src2(UOP_ANDN, ir, dst_reg, src_reg_a, src_reg_b)
|
#define uop_ANDN(ir, dst_reg, src_reg_a, src_reg_b) uop_gen_reg_dst_src2(UOP_ANDN, ir, dst_reg, src_reg_a, src_reg_b)
|
||||||
@@ -667,8 +659,20 @@ static inline void uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, in
|
|||||||
#define uop_FSQRT(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_FSQRT, ir, dst_reg, src_reg)
|
#define uop_FSQRT(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_FSQRT, ir, dst_reg, src_reg)
|
||||||
#define uop_FTST(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_FTST, ir, dst_reg, src_reg)
|
#define uop_FTST(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_FTST, ir, dst_reg, src_reg)
|
||||||
|
|
||||||
#define uop_FP_ENTER(ir) do { if (!codegen_fpu_entered) uop_gen_imm(UOP_FP_ENTER, ir, cpu_state.oldpc); codegen_fpu_entered = 1; codegen_mmx_entered = 0; } while (0)
|
#define uop_FP_ENTER(ir) \
|
||||||
#define uop_MMX_ENTER(ir) do { if (!codegen_mmx_entered) uop_gen_imm(UOP_MMX_ENTER, ir, cpu_state.oldpc); codegen_mmx_entered = 1; codegen_fpu_entered = 0; } while (0)
|
do { \
|
||||||
|
if (!codegen_fpu_entered) \
|
||||||
|
uop_gen_imm(UOP_FP_ENTER, ir, cpu_state.oldpc); \
|
||||||
|
codegen_fpu_entered = 1; \
|
||||||
|
codegen_mmx_entered = 0; \
|
||||||
|
} while (0)
|
||||||
|
#define uop_MMX_ENTER(ir) \
|
||||||
|
do { \
|
||||||
|
if (!codegen_mmx_entered) \
|
||||||
|
uop_gen_imm(UOP_MMX_ENTER, ir, cpu_state.oldpc); \
|
||||||
|
codegen_mmx_entered = 1; \
|
||||||
|
codegen_fpu_entered = 0; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
#define uop_JMP(ir, p) uop_gen_pointer(UOP_JMP, ir, p)
|
#define uop_JMP(ir, p) uop_gen_pointer(UOP_JMP, ir, p)
|
||||||
#define uop_JMP_DEST(ir) uop_gen(UOP_JMP_DEST, ir)
|
#define uop_JMP_DEST(ir) uop_gen(UOP_JMP_DEST, ir)
|
||||||
@@ -676,18 +680,26 @@ static inline void uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, in
|
|||||||
#define uop_LOAD_SEG(ir, p, src_reg) uop_gen_reg_src_pointer(UOP_LOAD_SEG, ir, src_reg, p)
|
#define uop_LOAD_SEG(ir, p, src_reg) uop_gen_reg_src_pointer(UOP_LOAD_SEG, ir, src_reg, p)
|
||||||
|
|
||||||
#define uop_MEM_LOAD_ABS(ir, dst_reg, seg_reg, imm) uop_gen_reg_dst_src_imm(UOP_MEM_LOAD_ABS, ir, dst_reg, seg_reg, imm)
|
#define uop_MEM_LOAD_ABS(ir, dst_reg, seg_reg, imm) uop_gen_reg_dst_src_imm(UOP_MEM_LOAD_ABS, ir, dst_reg, seg_reg, imm)
|
||||||
#define uop_MEM_LOAD_REG(ir, dst_reg, seg_reg, addr_reg) uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_REG, ir, dst_reg, seg_reg, addr_reg, 0)
|
#define uop_MEM_LOAD_REG(ir, dst_reg, seg_reg, addr_reg) \
|
||||||
#define uop_MEM_LOAD_REG_OFFSET(ir, dst_reg, seg_reg, addr_reg, offset) uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_REG, ir, dst_reg, seg_reg, addr_reg, offset)
|
uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_REG, ir, dst_reg, seg_reg, addr_reg, 0)
|
||||||
#define uop_MEM_LOAD_SINGLE(ir, dst_reg, seg_reg, addr_reg) uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_SINGLE, ir, dst_reg, seg_reg, addr_reg, 0)
|
#define uop_MEM_LOAD_REG_OFFSET(ir, dst_reg, seg_reg, addr_reg, offset) \
|
||||||
#define uop_MEM_LOAD_DOUBLE(ir, dst_reg, seg_reg, addr_reg) uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_DOUBLE, ir, dst_reg, seg_reg, addr_reg, 0)
|
uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_REG, ir, dst_reg, seg_reg, addr_reg, offset)
|
||||||
|
#define uop_MEM_LOAD_SINGLE(ir, dst_reg, seg_reg, addr_reg) \
|
||||||
|
uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_SINGLE, ir, dst_reg, seg_reg, addr_reg, 0)
|
||||||
|
#define uop_MEM_LOAD_DOUBLE(ir, dst_reg, seg_reg, addr_reg) \
|
||||||
|
uop_gen_reg_dst_src2_imm(UOP_MEM_LOAD_DOUBLE, ir, dst_reg, seg_reg, addr_reg, 0)
|
||||||
#define uop_MEM_STORE_ABS(ir, seg_reg, imm, src_reg) uop_gen_reg_src2_imm(UOP_MEM_STORE_ABS, ir, seg_reg, src_reg, imm)
|
#define uop_MEM_STORE_ABS(ir, seg_reg, imm, src_reg) uop_gen_reg_src2_imm(UOP_MEM_STORE_ABS, ir, seg_reg, src_reg, imm)
|
||||||
#define uop_MEM_STORE_REG(ir, seg_reg, addr_reg, src_reg) uop_gen_reg_src3_imm(UOP_MEM_STORE_REG, ir, seg_reg, addr_reg, src_reg, 0)
|
#define uop_MEM_STORE_REG(ir, seg_reg, addr_reg, src_reg) \
|
||||||
#define uop_MEM_STORE_REG_OFFSET(ir, seg_reg, addr_reg, offset, src_reg) uop_gen_reg_src3_imm(UOP_MEM_STORE_REG, ir, seg_reg, addr_reg, src_reg, offset)
|
uop_gen_reg_src3_imm(UOP_MEM_STORE_REG, ir, seg_reg, addr_reg, src_reg, 0)
|
||||||
|
#define uop_MEM_STORE_REG_OFFSET(ir, seg_reg, addr_reg, offset, src_reg) \
|
||||||
|
uop_gen_reg_src3_imm(UOP_MEM_STORE_REG, ir, seg_reg, addr_reg, src_reg, offset)
|
||||||
#define uop_MEM_STORE_IMM_8(ir, seg_reg, addr_reg, imm) uop_gen_reg_src2_imm(UOP_MEM_STORE_IMM_8, ir, seg_reg, addr_reg, imm)
|
#define uop_MEM_STORE_IMM_8(ir, seg_reg, addr_reg, imm) uop_gen_reg_src2_imm(UOP_MEM_STORE_IMM_8, ir, seg_reg, addr_reg, imm)
|
||||||
#define uop_MEM_STORE_IMM_16(ir, seg_reg, addr_reg, imm) uop_gen_reg_src2_imm(UOP_MEM_STORE_IMM_16, ir, seg_reg, addr_reg, imm)
|
#define uop_MEM_STORE_IMM_16(ir, seg_reg, addr_reg, imm) uop_gen_reg_src2_imm(UOP_MEM_STORE_IMM_16, ir, seg_reg, addr_reg, imm)
|
||||||
#define uop_MEM_STORE_IMM_32(ir, seg_reg, addr_reg, imm) uop_gen_reg_src2_imm(UOP_MEM_STORE_IMM_32, ir, seg_reg, addr_reg, imm)
|
#define uop_MEM_STORE_IMM_32(ir, seg_reg, addr_reg, imm) uop_gen_reg_src2_imm(UOP_MEM_STORE_IMM_32, ir, seg_reg, addr_reg, imm)
|
||||||
#define uop_MEM_STORE_SINGLE(ir, seg_reg, addr_reg, src_reg) uop_gen_reg_src3_imm(UOP_MEM_STORE_SINGLE, ir, seg_reg, addr_reg, src_reg, 0)
|
#define uop_MEM_STORE_SINGLE(ir, seg_reg, addr_reg, src_reg) \
|
||||||
#define uop_MEM_STORE_DOUBLE(ir, seg_reg, addr_reg, src_reg) uop_gen_reg_src3_imm(UOP_MEM_STORE_DOUBLE, ir, seg_reg, addr_reg, src_reg, 0)
|
uop_gen_reg_src3_imm(UOP_MEM_STORE_SINGLE, ir, seg_reg, addr_reg, src_reg, 0)
|
||||||
|
#define uop_MEM_STORE_DOUBLE(ir, seg_reg, addr_reg, src_reg) \
|
||||||
|
uop_gen_reg_src3_imm(UOP_MEM_STORE_DOUBLE, ir, seg_reg, addr_reg, src_reg, 0)
|
||||||
|
|
||||||
#define uop_MOV(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOV, ir, dst_reg, src_reg)
|
#define uop_MOV(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOV, ir, dst_reg, src_reg)
|
||||||
#define uop_MOV_IMM(ir, reg, imm) uop_gen_reg_dst_imm(UOP_MOV_IMM, ir, reg, imm)
|
#define uop_MOV_IMM(ir, reg, imm) uop_gen_reg_dst_imm(UOP_MOV_IMM, ir, reg, imm)
|
||||||
@@ -698,8 +710,10 @@ static inline void uop_gen_reg_src2_pointer(uint32_t uop_type, ir_data_t *ir, in
|
|||||||
#define uop_MOVSX(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOVSX, ir, dst_reg, src_reg)
|
#define uop_MOVSX(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOVSX, ir, dst_reg, src_reg)
|
||||||
#define uop_MOVZX(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOVZX, ir, dst_reg, src_reg)
|
#define uop_MOVZX(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOVZX, ir, dst_reg, src_reg)
|
||||||
#define uop_MOV_DOUBLE_INT(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOV_DOUBLE_INT, ir, dst_reg, src_reg)
|
#define uop_MOV_DOUBLE_INT(ir, dst_reg, src_reg) uop_gen_reg_dst_src1(UOP_MOV_DOUBLE_INT, ir, dst_reg, src_reg)
|
||||||
#define uop_MOV_INT_DOUBLE(ir, dst_reg, src_reg/*, nrc, orc*/) uop_gen_reg_dst_src1(UOP_MOV_INT_DOUBLE, ir, dst_reg, src_reg/*, nrc, orc*/)
|
#define uop_MOV_INT_DOUBLE(ir, dst_reg, src_reg /*, nrc, orc*/) \
|
||||||
#define uop_MOV_INT_DOUBLE_64(ir, dst_reg, src_reg_d, src_reg_q, tag) uop_gen_reg_dst_src3(UOP_MOV_INT_DOUBLE_64, ir, dst_reg, src_reg_d, src_reg_q, tag)
|
uop_gen_reg_dst_src1(UOP_MOV_INT_DOUBLE, ir, dst_reg, src_reg /*, nrc, orc*/)
|
||||||
|
#define uop_MOV_INT_DOUBLE_64(ir, dst_reg, src_reg_d, src_reg_q, tag) \
|
||||||
|
uop_gen_reg_dst_src3(UOP_MOV_INT_DOUBLE_64, ir, dst_reg, src_reg_d, src_reg_q, tag)
|
||||||
|
|
||||||
#define uop_NOP_BARRIER(ir) uop_gen(UOP_NOP_BARRIER, ir)
|
#define uop_NOP_BARRIER(ir) uop_gen(UOP_NOP_BARRIER, ir)
|
||||||
|
|
||||||
|
@@ -5,7 +5,8 @@
|
|||||||
|
|
||||||
struct ir_data_t;
|
struct ir_data_t;
|
||||||
|
|
||||||
typedef uint32_t (*RecompOpFn)(codeblock_t *block, struct ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
typedef uint32_t (*RecompOpFn)(codeblock_t *block, struct ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32,
|
||||||
|
uint32_t op_pc);
|
||||||
|
|
||||||
extern RecompOpFn recomp_opcodes[512];
|
extern RecompOpFn recomp_opcodes[512];
|
||||||
extern RecompOpFn recomp_opcodes_0f[512];
|
extern RecompOpFn recomp_opcodes_0f[512];
|
||||||
|
@@ -17,5 +17,4 @@ uint32_t ropPFSUB(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe
|
|||||||
uint32_t ropPFSUBR(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPFSUBR(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPI2FD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPI2FD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_3DNOW_H_ */
|
#endif /* _CODEGEN_OPS_3DNOW_H_ */
|
||||||
|
@@ -57,7 +57,6 @@ uint32_t rop81_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||||||
uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t rop83_w(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t rop83_l(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
uint32_t ropDEC_r16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropDEC_r16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropDEC_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropDEC_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
@@ -66,5 +65,4 @@ uint32_t ropINC_r32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
|
|
||||||
uint32_t ropINCDEC(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropINCDEC(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_ARITH_H_ */
|
#endif /* _CODEGEN_OPS_ARITH_H_ */
|
||||||
|
@@ -71,5 +71,4 @@ uint32_t ropLOOP(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||||||
uint32_t ropLOOPE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropLOOPE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropLOOPNE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropLOOPNE(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_BRANCH_H_ */
|
#endif /* _CODEGEN_OPS_BRANCH_H_ */
|
||||||
|
@@ -65,5 +65,4 @@ uint32_t ropFCHS(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fet
|
|||||||
uint32_t ropFSQRT(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFSQRT(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropFTST(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFTST(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_FPU_ARITH_H_ */
|
#endif /* _CODEGEN_OPS_FPU_ARITH_H_ */
|
||||||
|
@@ -4,5 +4,4 @@
|
|||||||
uint32_t ropFLD1(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFLD1(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropFLDZ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFLDZ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_FPU_CONSTANT_H_ */
|
#endif /* _CODEGEN_OPS_FPU_CONSTANT_H_ */
|
||||||
|
@@ -19,5 +19,4 @@ uint32_t ropFISTl(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe
|
|||||||
uint32_t ropFISTPl(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFISTPl(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropFISTPq(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFISTPq(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_FPU_LOADSTORE_H_ */
|
#endif /* _CODEGEN_OPS_FPU_LOADSTORE_H_ */
|
||||||
|
@@ -14,5 +14,4 @@ uint32_t ropFSTSW_AX(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
|
|
||||||
uint32_t ropFXCH(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropFXCH(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_FPU_MISC_H_ */
|
#endif /* _CODEGEN_OPS_FPU_MISC_H_ */
|
||||||
|
@@ -4,100 +4,78 @@
|
|||||||
#include "386_common.h"
|
#include "386_common.h"
|
||||||
#include "codegen_backend.h"
|
#include "codegen_backend.h"
|
||||||
|
|
||||||
static inline int LOAD_SP_WITH_OFFSET(ir_data_t *ir, int offset)
|
static inline int LOAD_SP_WITH_OFFSET(ir_data_t *ir, int offset) {
|
||||||
{
|
if (stack32) {
|
||||||
if (stack32)
|
if (offset) {
|
||||||
{
|
|
||||||
if (offset)
|
|
||||||
{
|
|
||||||
uop_ADD_IMM(ir, IREG_eaaddr, IREG_ESP, offset);
|
uop_ADD_IMM(ir, IREG_eaaddr, IREG_ESP, offset);
|
||||||
return IREG_eaaddr;
|
return IREG_eaaddr;
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
return IREG_ESP;
|
return IREG_ESP;
|
||||||
}
|
} else {
|
||||||
else
|
if (offset) {
|
||||||
{
|
|
||||||
if (offset)
|
|
||||||
{
|
|
||||||
uop_ADD_IMM(ir, IREG_eaaddr_W, IREG_SP, offset);
|
uop_ADD_IMM(ir, IREG_eaaddr_W, IREG_SP, offset);
|
||||||
uop_MOVZX(ir, IREG_eaaddr, IREG_eaaddr_W);
|
uop_MOVZX(ir, IREG_eaaddr, IREG_eaaddr_W);
|
||||||
return IREG_eaaddr;
|
return IREG_eaaddr;
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
uop_MOVZX(ir, IREG_eaaddr, IREG_SP);
|
uop_MOVZX(ir, IREG_eaaddr, IREG_SP);
|
||||||
return IREG_eaaddr;
|
return IREG_eaaddr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int LOAD_SP(ir_data_t *ir)
|
static inline int LOAD_SP(ir_data_t *ir) { return LOAD_SP_WITH_OFFSET(ir, 0); }
|
||||||
{
|
|
||||||
return LOAD_SP_WITH_OFFSET(ir, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void ADD_SP(ir_data_t *ir, int offset)
|
static inline void ADD_SP(ir_data_t *ir, int offset) {
|
||||||
{
|
|
||||||
if (stack32)
|
if (stack32)
|
||||||
uop_ADD_IMM(ir, IREG_ESP, IREG_ESP, offset);
|
uop_ADD_IMM(ir, IREG_ESP, IREG_ESP, offset);
|
||||||
else
|
else
|
||||||
uop_ADD_IMM(ir, IREG_SP, IREG_SP, offset);
|
uop_ADD_IMM(ir, IREG_SP, IREG_SP, offset);
|
||||||
}
|
}
|
||||||
static inline void SUB_SP(ir_data_t *ir, int offset)
|
static inline void SUB_SP(ir_data_t *ir, int offset) {
|
||||||
{
|
|
||||||
if (stack32)
|
if (stack32)
|
||||||
uop_SUB_IMM(ir, IREG_ESP, IREG_ESP, offset);
|
uop_SUB_IMM(ir, IREG_ESP, IREG_ESP, offset);
|
||||||
else
|
else
|
||||||
uop_SUB_IMM(ir, IREG_SP, IREG_SP, offset);
|
uop_SUB_IMM(ir, IREG_SP, IREG_SP, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void fpu_POP(codeblock_t *block, ir_data_t *ir)
|
static inline void fpu_POP(codeblock_t *block, ir_data_t *ir) {
|
||||||
{
|
|
||||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||||
uop_MOV_IMM(ir, IREG_FPU_TOP, cpu_state.TOP + 1);
|
uop_MOV_IMM(ir, IREG_FPU_TOP, cpu_state.TOP + 1);
|
||||||
else
|
else
|
||||||
uop_ADD_IMM(ir, IREG_FPU_TOP, IREG_FPU_TOP, 1);
|
uop_ADD_IMM(ir, IREG_FPU_TOP, IREG_FPU_TOP, 1);
|
||||||
}
|
}
|
||||||
static inline void fpu_POP2(codeblock_t *block, ir_data_t *ir)
|
static inline void fpu_POP2(codeblock_t *block, ir_data_t *ir) {
|
||||||
{
|
|
||||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||||
uop_MOV_IMM(ir, IREG_FPU_TOP, cpu_state.TOP + 2);
|
uop_MOV_IMM(ir, IREG_FPU_TOP, cpu_state.TOP + 2);
|
||||||
else
|
else
|
||||||
uop_ADD_IMM(ir, IREG_FPU_TOP, IREG_FPU_TOP, 2);
|
uop_ADD_IMM(ir, IREG_FPU_TOP, IREG_FPU_TOP, 2);
|
||||||
}
|
}
|
||||||
static inline void fpu_PUSH(codeblock_t *block, ir_data_t *ir)
|
static inline void fpu_PUSH(codeblock_t *block, ir_data_t *ir) {
|
||||||
{
|
|
||||||
if (block->flags & CODEBLOCK_STATIC_TOP)
|
if (block->flags & CODEBLOCK_STATIC_TOP)
|
||||||
uop_MOV_IMM(ir, IREG_FPU_TOP, cpu_state.TOP - 1);
|
uop_MOV_IMM(ir, IREG_FPU_TOP, cpu_state.TOP - 1);
|
||||||
else
|
else
|
||||||
uop_SUB_IMM(ir, IREG_FPU_TOP, IREG_FPU_TOP, 1);
|
uop_SUB_IMM(ir, IREG_FPU_TOP, IREG_FPU_TOP, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void CHECK_SEG_LIMITS(codeblock_t *block, ir_data_t *ir, x86seg *seg, int addr_reg, int end_offset)
|
static inline void CHECK_SEG_LIMITS(codeblock_t *block, ir_data_t *ir, x86seg *seg, int addr_reg, int end_offset) {
|
||||||
{
|
|
||||||
if ((seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) ||
|
if ((seg == &cpu_state.seg_ds && codegen_flat_ds && !(cpu_cur_status & CPU_STATUS_NOTFLATDS)) ||
|
||||||
(seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS)))
|
(seg == &cpu_state.seg_ss && codegen_flat_ss && !(cpu_cur_status & CPU_STATUS_NOTFLATSS)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
uop_CMP_JB(ir, addr_reg, ireg_seg_limit_low(seg), codegen_gpf_rout);
|
uop_CMP_JB(ir, addr_reg, ireg_seg_limit_low(seg), codegen_gpf_rout);
|
||||||
if (end_offset)
|
if (end_offset) {
|
||||||
{
|
|
||||||
uop_ADD_IMM(ir, IREG_temp3, addr_reg, end_offset);
|
uop_ADD_IMM(ir, IREG_temp3, addr_reg, end_offset);
|
||||||
uop_CMP_JNBE(ir, IREG_temp3, ireg_seg_limit_high(seg), codegen_gpf_rout);
|
uop_CMP_JNBE(ir, IREG_temp3, ireg_seg_limit_high(seg), codegen_gpf_rout);
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
uop_CMP_JNBE(ir, addr_reg, ireg_seg_limit_high(seg), codegen_gpf_rout);
|
uop_CMP_JNBE(ir, addr_reg, ireg_seg_limit_high(seg), codegen_gpf_rout);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void LOAD_IMMEDIATE_FROM_RAM_8(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr)
|
static inline void LOAD_IMMEDIATE_FROM_RAM_8(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr) {
|
||||||
{
|
|
||||||
uop_MOVZX_REG_PTR_8(ir, dest_reg, get_ram_ptr(addr));
|
uop_MOVZX_REG_PTR_8(ir, dest_reg, get_ram_ptr(addr));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOAD_IMMEDIATE_FROM_RAM_16_unaligned(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr);
|
void LOAD_IMMEDIATE_FROM_RAM_16_unaligned(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr);
|
||||||
static inline void LOAD_IMMEDIATE_FROM_RAM_16(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr)
|
static inline void LOAD_IMMEDIATE_FROM_RAM_16(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr) {
|
||||||
{
|
|
||||||
if ((addr & 0xfff) == 0xfff)
|
if ((addr & 0xfff) == 0xfff)
|
||||||
LOAD_IMMEDIATE_FROM_RAM_16_unaligned(block, ir, dest_reg, addr);
|
LOAD_IMMEDIATE_FROM_RAM_16_unaligned(block, ir, dest_reg, addr);
|
||||||
else
|
else
|
||||||
@@ -105,8 +83,7 @@ static inline void LOAD_IMMEDIATE_FROM_RAM_16(codeblock_t *block, ir_data_t *ir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
void LOAD_IMMEDIATE_FROM_RAM_32_unaligned(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr);
|
void LOAD_IMMEDIATE_FROM_RAM_32_unaligned(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr);
|
||||||
static inline void LOAD_IMMEDIATE_FROM_RAM_32(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr)
|
static inline void LOAD_IMMEDIATE_FROM_RAM_32(codeblock_t *block, ir_data_t *ir, int dest_reg, uint32_t addr) {
|
||||||
{
|
|
||||||
if ((addr & 0xfff) >= 0xffd)
|
if ((addr & 0xfff) >= 0xffd)
|
||||||
LOAD_IMMEDIATE_FROM_RAM_32_unaligned(block, ir, dest_reg, addr);
|
LOAD_IMMEDIATE_FROM_RAM_32_unaligned(block, ir, dest_reg, addr);
|
||||||
else
|
else
|
||||||
@@ -114,19 +91,17 @@ static inline void LOAD_IMMEDIATE_FROM_RAM_32(codeblock_t *block, ir_data_t *ir,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, uint32_t dest_addr);
|
int codegen_can_unroll_full(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, uint32_t dest_addr);
|
||||||
static inline int codegen_can_unroll(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, uint32_t dest_addr)
|
static inline int codegen_can_unroll(codeblock_t *block, ir_data_t *ir, uint32_t next_pc, uint32_t dest_addr) {
|
||||||
{
|
|
||||||
if (block->flags & CODEBLOCK_BYTE_MASK)
|
if (block->flags & CODEBLOCK_BYTE_MASK)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/*Is dest within block?*/
|
/*Is dest within block?*/
|
||||||
if (dest_addr > next_pc)
|
if (dest_addr > next_pc)
|
||||||
return 0;
|
return 0;
|
||||||
if ((cs+dest_addr) < block->pc)
|
if ((cs + dest_addr) < block->pc)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return codegen_can_unroll_full(block, ir, next_pc, dest_addr);
|
return codegen_can_unroll_full(block, ir, next_pc, dest_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_HELPERS_H_ */
|
#endif /* _CODEGEN_OPS_HELPERS_H_ */
|
||||||
|
@@ -23,5 +23,4 @@ uint32_t ropRETF_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
uint32_t ropRETF_imm_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropRETF_imm_16(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropRETF_imm_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropRETF_imm_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_JUMP_H_ */
|
#endif /* _CODEGEN_OPS_JUMP_H_ */
|
||||||
|
@@ -38,5 +38,4 @@ uint32_t ropXOR_w_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||||||
uint32_t ropXOR_l_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropXOR_l_rm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropXOR_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropXOR_l_rmw(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_LOGIC_H_ */
|
#endif /* _CODEGEN_OPS_LOGIC_H_ */
|
||||||
|
@@ -39,5 +39,4 @@ uint32_t ropSTD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetc
|
|||||||
uint32_t ropCLI(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropCLI(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropSTI(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropSTI(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MISC_H_ */
|
#endif /* _CODEGEN_OPS_MISC_H_ */
|
||||||
|
@@ -20,5 +20,4 @@ uint32_t ropPMADDWD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
uint32_t ropPMULHW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPMULHW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPMULLW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPMULLW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MMX_ARITH_H_ */
|
#endif /* _CODEGEN_OPS_MMX_ARITH_H_ */
|
||||||
|
@@ -7,5 +7,4 @@ uint32_t ropPCMPGTB(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
uint32_t ropPCMPGTW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPCMPGTW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPCMPGTD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPCMPGTD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MMX_CMP_H_ */
|
#endif /* _CODEGEN_OPS_MMX_CMP_H_ */
|
||||||
|
@@ -6,5 +6,4 @@ uint32_t ropMOVD_d_r(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
uint32_t ropMOVQ_r_q(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropMOVQ_r_q(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropMOVQ_q_r(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropMOVQ_q_r(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MMX_LOADSTORE_H_ */
|
#endif /* _CODEGEN_OPS_MMX_LOADSTORE_H_ */
|
||||||
|
@@ -5,5 +5,4 @@ uint32_t ropPANDN(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe
|
|||||||
uint32_t ropPOR(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPOR(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPXOR(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPXOR(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MMX_LOGIC_H_ */
|
#endif /* _CODEGEN_OPS_MMX_LOGIC_H_ */
|
||||||
|
@@ -10,5 +10,4 @@ uint32_t ropPUNPCKHBW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_
|
|||||||
uint32_t ropPUNPCKHWD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPUNPCKHWD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPUNPCKHDQ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPUNPCKHDQ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MMX_PACK_H_ */
|
#endif /* _CODEGEN_OPS_MMX_PACK_H_ */
|
||||||
|
@@ -8,5 +8,4 @@ uint32_t ropPSLLW(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fe
|
|||||||
uint32_t ropPSLLD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPSLLD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPSLLQ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPSLLQ(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MMX_SHIFT_H_ */
|
#endif /* _CODEGEN_OPS_MMX_SHIFT_H_ */
|
||||||
|
@@ -44,5 +44,4 @@ uint32_t ropXCHG_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
|
|
||||||
uint32_t ropXLAT(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropXLAT(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_MOV_H_ */
|
#endif /* _CODEGEN_OPS_MOV_H_ */
|
||||||
|
@@ -17,5 +17,4 @@ uint32_t ropSHLD_32_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint3
|
|||||||
uint32_t ropSHRD_16_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropSHRD_16_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropSHRD_32_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropSHRD_32_imm(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_SHIFT_H_ */
|
#endif /* _CODEGEN_OPS_SHIFT_H_ */
|
||||||
|
@@ -50,5 +50,4 @@ uint32_t ropPOPA_32(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t
|
|||||||
uint32_t ropPUSHF(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPUSHF(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
uint32_t ropPUSHFD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
uint32_t ropPUSHFD(codeblock_t *block, ir_data_t *ir, uint8_t opcode, uint32_t fetchdat, uint32_t op_32, uint32_t op_pc);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_OPS_STACK_H_ */
|
#endif /* _CODEGEN_OPS_STACK_H_ */
|
||||||
|
@@ -5,8 +5,8 @@
|
|||||||
#define IREG_SIZE_SHIFT 8
|
#define IREG_SIZE_SHIFT 8
|
||||||
#define IREG_SIZE_MASK (7 << IREG_SIZE_SHIFT)
|
#define IREG_SIZE_MASK (7 << IREG_SIZE_SHIFT)
|
||||||
|
|
||||||
#define IREG_GET_REG(reg) ((reg) & IREG_REG_MASK)
|
#define IREG_GET_REG(reg) ((reg)&IREG_REG_MASK)
|
||||||
#define IREG_GET_SIZE(reg) ((reg) & IREG_SIZE_MASK)
|
#define IREG_GET_SIZE(reg) ((reg)&IREG_SIZE_MASK)
|
||||||
|
|
||||||
#define IREG_SIZE_L (0 << IREG_SIZE_SHIFT)
|
#define IREG_SIZE_L (0 << IREG_SIZE_SHIFT)
|
||||||
#define IREG_SIZE_W (1 << IREG_SIZE_SHIFT)
|
#define IREG_SIZE_W (1 << IREG_SIZE_SHIFT)
|
||||||
@@ -15,8 +15,7 @@
|
|||||||
#define IREG_SIZE_D (4 << IREG_SIZE_SHIFT)
|
#define IREG_SIZE_D (4 << IREG_SIZE_SHIFT)
|
||||||
#define IREG_SIZE_Q (5 << IREG_SIZE_SHIFT)
|
#define IREG_SIZE_Q (5 << IREG_SIZE_SHIFT)
|
||||||
|
|
||||||
enum
|
enum {
|
||||||
{
|
|
||||||
IREG_EAX = 0,
|
IREG_EAX = 0,
|
||||||
IREG_ECX = 1,
|
IREG_ECX = 1,
|
||||||
IREG_EDX = 2,
|
IREG_EDX = 2,
|
||||||
@@ -207,7 +206,7 @@ enum
|
|||||||
IREG_eflags = IREG_eflagsx + IREG_SIZE_W
|
IREG_eflags = IREG_eflagsx + IREG_SIZE_W
|
||||||
};
|
};
|
||||||
|
|
||||||
#define IREG_8(reg) (((reg) & 4) ? (((reg) & 3) + IREG_AH) : ((reg) + IREG_AL))
|
#define IREG_8(reg) (((reg)&4) ? (((reg)&3) + IREG_AH) : ((reg) + IREG_AL))
|
||||||
#define IREG_16(reg) ((reg) + IREG_AX)
|
#define IREG_16(reg) ((reg) + IREG_AX)
|
||||||
#define IREG_32(reg) ((reg) + IREG_EAX)
|
#define IREG_32(reg) ((reg) + IREG_EAX)
|
||||||
|
|
||||||
@@ -220,8 +219,7 @@ enum
|
|||||||
|
|
||||||
#define IREG_TOP_diff_stack_offset 32
|
#define IREG_TOP_diff_stack_offset 32
|
||||||
|
|
||||||
static inline int ireg_seg_base(x86seg *seg)
|
static inline int ireg_seg_base(x86seg *seg) {
|
||||||
{
|
|
||||||
if (seg == &cpu_state.seg_cs)
|
if (seg == &cpu_state.seg_cs)
|
||||||
return IREG_CS_base;
|
return IREG_CS_base;
|
||||||
if (seg == &cpu_state.seg_ds)
|
if (seg == &cpu_state.seg_ds)
|
||||||
@@ -238,8 +236,7 @@ static inline int ireg_seg_base(x86seg *seg)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int ireg_seg_limit_low(x86seg *seg)
|
static inline int ireg_seg_limit_low(x86seg *seg) {
|
||||||
{
|
|
||||||
if (seg == &cpu_state.seg_cs)
|
if (seg == &cpu_state.seg_cs)
|
||||||
return IREG_CS_limit_low;
|
return IREG_CS_limit_low;
|
||||||
if (seg == &cpu_state.seg_ds)
|
if (seg == &cpu_state.seg_ds)
|
||||||
@@ -255,8 +252,7 @@ static inline int ireg_seg_limit_low(x86seg *seg)
|
|||||||
fatal("ireg_seg_limit_low : unknown segment\n");
|
fatal("ireg_seg_limit_low : unknown segment\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
static inline int ireg_seg_limit_high(x86seg *seg)
|
static inline int ireg_seg_limit_high(x86seg *seg) {
|
||||||
{
|
|
||||||
if (seg == &cpu_state.seg_cs)
|
if (seg == &cpu_state.seg_cs)
|
||||||
return IREG_CS_limit_high;
|
return IREG_CS_limit_high;
|
||||||
if (seg == &cpu_state.seg_ds)
|
if (seg == &cpu_state.seg_ds)
|
||||||
@@ -281,8 +277,7 @@ extern uint8_t reg_last_version[IREG_COUNT];
|
|||||||
/*This register and the parent uOP have been optimised out.*/
|
/*This register and the parent uOP have been optimised out.*/
|
||||||
#define REG_FLAGS_DEAD (1 << 1)
|
#define REG_FLAGS_DEAD (1 << 1)
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
/*Refcount of pending reads on this register version*/
|
/*Refcount of pending reads on this register version*/
|
||||||
uint8_t refcount;
|
uint8_t refcount;
|
||||||
/*Flags*/
|
/*Flags*/
|
||||||
@@ -299,14 +294,12 @@ extern reg_version_t reg_version[IREG_COUNT][256];
|
|||||||
can be optimised out*/
|
can be optimised out*/
|
||||||
extern uint16_t reg_dead_list;
|
extern uint16_t reg_dead_list;
|
||||||
|
|
||||||
static inline void add_to_dead_list(reg_version_t *regv, int reg, int version)
|
static inline void add_to_dead_list(reg_version_t *regv, int reg, int version) {
|
||||||
{
|
|
||||||
regv->next = reg_dead_list;
|
regv->next = reg_dead_list;
|
||||||
reg_dead_list = version | (reg << 8);
|
reg_dead_list = version | (reg << 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
|
||||||
uint16_t reg;
|
uint16_t reg;
|
||||||
uint16_t version;
|
uint16_t version;
|
||||||
} ir_reg_t;
|
} ir_reg_t;
|
||||||
@@ -320,8 +313,7 @@ extern int max_version_refcount;
|
|||||||
#define REG_VERSION_MAX 250
|
#define REG_VERSION_MAX 250
|
||||||
#define REG_REFCOUNT_MAX 250
|
#define REG_REFCOUNT_MAX 250
|
||||||
|
|
||||||
static inline ir_reg_t codegen_reg_read(int reg)
|
static inline ir_reg_t codegen_reg_read(int reg) {
|
||||||
{
|
|
||||||
ir_reg_t ireg;
|
ir_reg_t ireg;
|
||||||
reg_version_t *version;
|
reg_version_t *version;
|
||||||
|
|
||||||
@@ -343,14 +335,14 @@ static inline ir_reg_t codegen_reg_read(int reg)
|
|||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
if (version->refcount > max_version_refcount)
|
if (version->refcount > max_version_refcount)
|
||||||
max_version_refcount = version->refcount;
|
max_version_refcount = version->refcount;
|
||||||
// pclog("codegen_reg_read: %i %i %i\n", reg & IREG_REG_MASK, ireg.version, reg_version_refcount[IREG_GET_REG(ireg.reg)][ireg.version]);
|
// pclog("codegen_reg_read: %i %i %i\n", reg & IREG_REG_MASK, ireg.version,
|
||||||
|
// reg_version_refcount[IREG_GET_REG(ireg.reg)][ireg.version]);
|
||||||
return ireg;
|
return ireg;
|
||||||
}
|
}
|
||||||
|
|
||||||
int reg_is_native_size(ir_reg_t ir_reg);
|
int reg_is_native_size(ir_reg_t ir_reg);
|
||||||
|
|
||||||
static inline ir_reg_t codegen_reg_write(int reg, int uop_nr)
|
static inline ir_reg_t codegen_reg_write(int reg, int uop_nr) {
|
||||||
{
|
|
||||||
ir_reg_t ireg;
|
ir_reg_t ireg;
|
||||||
int last_version = reg_last_version[IREG_GET_REG(reg)];
|
int last_version = reg_last_version[IREG_GET_REG(reg)];
|
||||||
reg_version_t *version;
|
reg_version_t *version;
|
||||||
@@ -363,9 +355,9 @@ static inline ir_reg_t codegen_reg_write(int reg, int uop_nr)
|
|||||||
ireg.version = last_version + 1;
|
ireg.version = last_version + 1;
|
||||||
|
|
||||||
if (IREG_GET_REG(reg) > IREG_EBX && last_version && !reg_version[IREG_GET_REG(reg)][last_version].refcount &&
|
if (IREG_GET_REG(reg) > IREG_EBX && last_version && !reg_version[IREG_GET_REG(reg)][last_version].refcount &&
|
||||||
!(reg_version[IREG_GET_REG(reg)][last_version].flags & REG_FLAGS_REQUIRED))
|
!(reg_version[IREG_GET_REG(reg)][last_version].flags & REG_FLAGS_REQUIRED)) {
|
||||||
{
|
if (reg_is_native_size(ireg)) /*Non-native size registers have an implicit dependency on the previous version, so
|
||||||
if (reg_is_native_size(ireg)) /*Non-native size registers have an implicit dependency on the previous version, so don't add to dead list*/
|
don't add to dead list*/
|
||||||
add_to_dead_list(®_version[IREG_GET_REG(reg)][last_version], IREG_GET_REG(reg), last_version);
|
add_to_dead_list(®_version[IREG_GET_REG(reg)][last_version], IREG_GET_REG(reg), last_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -384,14 +376,11 @@ static inline ir_reg_t codegen_reg_write(int reg, int uop_nr)
|
|||||||
version->refcount = 0;
|
version->refcount = 0;
|
||||||
version->flags = 0;
|
version->flags = 0;
|
||||||
version->parent_uop = uop_nr;
|
version->parent_uop = uop_nr;
|
||||||
// pclog("codegen_reg_write: %i\n", reg & IREG_REG_MASK);
|
// pclog("codegen_reg_write: %i\n", reg & IREG_REG_MASK);
|
||||||
return ireg;
|
return ireg;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int ir_reg_is_invalid(ir_reg_t ir_reg)
|
static inline int ir_reg_is_invalid(ir_reg_t ir_reg) { return (IREG_GET_REG(ir_reg.reg) == IREG_INVALID); }
|
||||||
{
|
|
||||||
return (IREG_GET_REG(ir_reg.reg) == IREG_INVALID);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ir_data_t;
|
struct ir_data_t;
|
||||||
|
|
||||||
|
@@ -77,12 +77,10 @@
|
|||||||
#define HAS_IMM8 (1ull << 34)
|
#define HAS_IMM8 (1ull << 34)
|
||||||
#define HAS_IMM1632 (1ull << 35)
|
#define HAS_IMM1632 (1ull << 35)
|
||||||
|
|
||||||
|
|
||||||
#define REGMASK_IMPL_ESP (1 << 8)
|
#define REGMASK_IMPL_ESP (1 << 8)
|
||||||
#define REGMASK_SHIFTPACK (1 << 9)
|
#define REGMASK_SHIFTPACK (1 << 9)
|
||||||
#define REGMASK_MULTIPLY (1 << 9)
|
#define REGMASK_MULTIPLY (1 << 9)
|
||||||
|
|
||||||
|
|
||||||
extern uint64_t opcode_deps[256];
|
extern uint64_t opcode_deps[256];
|
||||||
extern uint64_t opcode_deps_mod3[256];
|
extern uint64_t opcode_deps_mod3[256];
|
||||||
extern uint64_t opcode_deps_0f[256];
|
extern uint64_t opcode_deps_0f[256];
|
||||||
@@ -120,50 +118,52 @@ extern uint64_t opcode_deps_81_mod3[8];
|
|||||||
extern uint64_t opcode_deps_8x[8];
|
extern uint64_t opcode_deps_8x[8];
|
||||||
extern uint64_t opcode_deps_8x_mod3[8];
|
extern uint64_t opcode_deps_8x_mod3[8];
|
||||||
|
|
||||||
|
static inline uint32_t get_addr_regmask(uint64_t data, uint32_t fetchdat, int op_32) {
|
||||||
|
|
||||||
static inline uint32_t get_addr_regmask(uint64_t data, uint32_t fetchdat, int op_32)
|
|
||||||
{
|
|
||||||
uint32_t addr_regmask = 0;
|
uint32_t addr_regmask = 0;
|
||||||
|
|
||||||
if (data & MODRM)
|
if (data & MODRM) {
|
||||||
{
|
|
||||||
uint8_t modrm = fetchdat & 0xff;
|
uint8_t modrm = fetchdat & 0xff;
|
||||||
|
|
||||||
if ((modrm & 0xc0) != 0xc0)
|
if ((modrm & 0xc0) != 0xc0) {
|
||||||
{
|
if (op_32 & 0x200) {
|
||||||
if (op_32 & 0x200)
|
if ((modrm & 0x7) == 4) {
|
||||||
{
|
|
||||||
if ((modrm & 0x7) == 4)
|
|
||||||
{
|
|
||||||
uint8_t sib = (fetchdat >> 8) & 0xff;
|
uint8_t sib = (fetchdat >> 8) & 0xff;
|
||||||
|
|
||||||
if ((modrm & 0xc0) != 0xc0 && (sib & 7) != 5)
|
if ((modrm & 0xc0) != 0xc0 && (sib & 7) != 5) {
|
||||||
{
|
|
||||||
addr_regmask = 1 << (sib & 7);
|
addr_regmask = 1 << (sib & 7);
|
||||||
if ((sib & 0x38) != 0x20)
|
if ((sib & 0x38) != 0x20)
|
||||||
addr_regmask |= 1 << ((sib >> 3) & 7);
|
addr_regmask |= 1 << ((sib >> 3) & 7);
|
||||||
}
|
}
|
||||||
}
|
} else if ((modrm & 0xc7) != 5) {
|
||||||
else if ((modrm & 0xc7) != 5)
|
|
||||||
{
|
|
||||||
addr_regmask = 1 << (modrm & 7);
|
addr_regmask = 1 << (modrm & 7);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
if ((modrm & 0xc7) != 0x06) {
|
||||||
{
|
switch (modrm & 7) {
|
||||||
if ((modrm & 0xc7) != 0x06)
|
case 0:
|
||||||
{
|
addr_regmask = REG_BX | REG_SI;
|
||||||
switch (modrm & 7)
|
break;
|
||||||
{
|
case 1:
|
||||||
case 0: addr_regmask = REG_BX | REG_SI; break;
|
addr_regmask = REG_BX | REG_DI;
|
||||||
case 1: addr_regmask = REG_BX | REG_DI; break;
|
break;
|
||||||
case 2: addr_regmask = REG_BP | REG_SI; break;
|
case 2:
|
||||||
case 3: addr_regmask = REG_BP | REG_DI; break;
|
addr_regmask = REG_BP | REG_SI;
|
||||||
case 4: addr_regmask = REG_SI; break;
|
break;
|
||||||
case 5: addr_regmask = REG_DI; break;
|
case 3:
|
||||||
case 6: addr_regmask = REG_BP; break;
|
addr_regmask = REG_BP | REG_DI;
|
||||||
case 7: addr_regmask = REG_BX; break;
|
break;
|
||||||
|
case 4:
|
||||||
|
addr_regmask = REG_SI;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
addr_regmask = REG_DI;
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
addr_regmask = REG_BP;
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
addr_regmask = REG_BX;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -176,18 +176,15 @@ static inline uint32_t get_addr_regmask(uint64_t data, uint32_t fetchdat, int op
|
|||||||
return addr_regmask;
|
return addr_regmask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t get_srcdep_mask(uint64_t data, uint32_t fetchdat, int bit8, int op_32)
|
static inline uint32_t get_srcdep_mask(uint64_t data, uint32_t fetchdat, int bit8, int op_32) {
|
||||||
{
|
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
if (data & SRCDEP_REG)
|
if (data & SRCDEP_REG) {
|
||||||
{
|
|
||||||
int reg = (fetchdat >> 3) & 7;
|
int reg = (fetchdat >> 3) & 7;
|
||||||
if (bit8)
|
if (bit8)
|
||||||
reg &= 3;
|
reg &= 3;
|
||||||
mask |= (1 << reg);
|
mask |= (1 << reg);
|
||||||
}
|
}
|
||||||
if (data & SRCDEP_RM)
|
if (data & SRCDEP_RM) {
|
||||||
{
|
|
||||||
int reg = fetchdat & 7;
|
int reg = fetchdat & 7;
|
||||||
if (bit8)
|
if (bit8)
|
||||||
reg &= 3;
|
reg &= 3;
|
||||||
@@ -204,18 +201,15 @@ static inline uint32_t get_srcdep_mask(uint64_t data, uint32_t fetchdat, int bit
|
|||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t get_dstdep_mask(uint64_t data, uint32_t fetchdat, int bit8)
|
static inline uint32_t get_dstdep_mask(uint64_t data, uint32_t fetchdat, int bit8) {
|
||||||
{
|
|
||||||
uint32_t mask = 0;
|
uint32_t mask = 0;
|
||||||
if (data & DSTDEP_REG)
|
if (data & DSTDEP_REG) {
|
||||||
{
|
|
||||||
int reg = (fetchdat >> 3) & 7;
|
int reg = (fetchdat >> 3) & 7;
|
||||||
if (bit8)
|
if (bit8)
|
||||||
reg &= 3;
|
reg &= 3;
|
||||||
mask |= (1 << reg);
|
mask |= (1 << reg);
|
||||||
}
|
}
|
||||||
if (data & DSTDEP_RM)
|
if (data & DSTDEP_RM) {
|
||||||
{
|
|
||||||
int reg = fetchdat & 7;
|
int reg = fetchdat & 7;
|
||||||
if (bit8)
|
if (bit8)
|
||||||
reg &= 3;
|
reg &= 3;
|
||||||
@@ -232,5 +226,4 @@ static inline uint32_t get_dstdep_mask(uint64_t data, uint32_t fetchdat, int bit
|
|||||||
return mask;
|
return mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_TIMING_COMMON_H_ */
|
#endif /* _CODEGEN_TIMING_COMMON_H_ */
|
||||||
|
@@ -7,22 +7,18 @@
|
|||||||
#define HASH_SIZE 0x20000
|
#define HASH_SIZE 0x20000
|
||||||
#define HASH_MASK 0x1ffff
|
#define HASH_MASK 0x1ffff
|
||||||
|
|
||||||
#define HASH(l) ((l) & 0x1ffff)
|
#define HASH(l) ((l)&0x1ffff)
|
||||||
|
|
||||||
#define BLOCK_EXIT_OFFSET 0x7e0
|
#define BLOCK_EXIT_OFFSET 0x7e0
|
||||||
#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 20)
|
#define BLOCK_GPF_OFFSET (BLOCK_EXIT_OFFSET - 20)
|
||||||
|
|
||||||
#define BLOCK_MAX 1620
|
#define BLOCK_MAX 1620
|
||||||
|
|
||||||
enum
|
enum { OP_RET = 0xc3 };
|
||||||
{
|
|
||||||
OP_RET = 0xc3
|
|
||||||
};
|
|
||||||
|
|
||||||
#define NR_HOST_REGS 4
|
#define NR_HOST_REGS 4
|
||||||
extern int host_reg_mapping[NR_HOST_REGS];
|
extern int host_reg_mapping[NR_HOST_REGS];
|
||||||
#define NR_HOST_XMM_REGS 7
|
#define NR_HOST_XMM_REGS 7
|
||||||
extern int host_reg_xmm_mapping[NR_HOST_XMM_REGS];
|
extern int host_reg_xmm_mapping[NR_HOST_XMM_REGS];
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CODEGEN_X86_64_H_ */
|
#endif /* _CODEGEN_X86_64_H_ */
|
||||||
|
@@ -1,75 +1,98 @@
|
|||||||
#ifndef _386_COMMON_H_
|
#ifndef _386_COMMON_H_
|
||||||
#define _386_COMMON_H_
|
#define _386_COMMON_H_
|
||||||
|
|
||||||
#define readmemb(s, a) ((readlookup2[(uint32_t)((s)+(a))>>12]==-1)?readmembl((s)+(a)): *(uint8_t *)(readlookup2[(uint32_t)((s)+(a))>>12] + (uint32_t)((s) + (a))) )
|
#define readmemb(s, a) \
|
||||||
#define readmemw(s, a) ((readlookup2[(uint32_t)((s)+(a))>>12]==-1 || (((s)+(a)) & 1))?readmemwl((s)+(a)):*(uint16_t *)(readlookup2[(uint32_t)((s)+(a))>>12]+(uint32_t)((s)+(a))))
|
((readlookup2[(uint32_t)((s) + (a)) >> 12] == -1) \
|
||||||
#define readmeml(s, a) ((readlookup2[(uint32_t)((s)+(a))>>12]==-1 || (((s)+(a)) & 3))?readmemll((s)+(a)):*(uint32_t *)(readlookup2[(uint32_t)((s)+(a))>>12]+(uint32_t)((s)+(a))))
|
? readmembl((s) + (a)) \
|
||||||
#define readmemq(s, a) ((readlookup2[(uint32_t)((s)+(a))>>12]==-1 || (((s)+(a)) & 7))?readmemql((s)+(a)):*(uint64_t *)(readlookup2[(uint32_t)((s)+(a))>>12]+(uint32_t)((s)+(a))))
|
: *(uint8_t *)(readlookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))))
|
||||||
|
#define readmemw(s, a) \
|
||||||
|
((readlookup2[(uint32_t)((s) + (a)) >> 12] == -1 || (((s) + (a)) & 1)) \
|
||||||
|
? readmemwl((s) + (a)) \
|
||||||
|
: *(uint16_t *)(readlookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))))
|
||||||
|
#define readmeml(s, a) \
|
||||||
|
((readlookup2[(uint32_t)((s) + (a)) >> 12] == -1 || (((s) + (a)) & 3)) \
|
||||||
|
? readmemll((s) + (a)) \
|
||||||
|
: *(uint32_t *)(readlookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))))
|
||||||
|
#define readmemq(s, a) \
|
||||||
|
((readlookup2[(uint32_t)((s) + (a)) >> 12] == -1 || (((s) + (a)) & 7)) \
|
||||||
|
? readmemql((s) + (a)) \
|
||||||
|
: *(uint64_t *)(readlookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))))
|
||||||
|
|
||||||
#define writememb(s, a, v) if (writelookup2[(uint32_t)((s)+(a))>>12]==-1) writemembl((s)+(a),v); else *(uint8_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
#define writememb(s, a, v) \
|
||||||
#define writememw(s, a, v) if (writelookup2[(uint32_t)((s)+(a))>>12]==-1 || (((s)+(a)) & 1)) writememwl((s)+(a),v); else *(uint16_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
if (writelookup2[(uint32_t)((s) + (a)) >> 12] == -1) \
|
||||||
#define writememl(s, a, v) if (writelookup2[(uint32_t)((s)+(a))>>12]==-1 || (((s)+(a)) & 3)) writememll((s)+(a),v); else *(uint32_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
writemembl((s) + (a), v); \
|
||||||
#define writememq(s, a, v) if (writelookup2[(uint32_t)((s)+(a))>>12]==-1 || (((s)+(a)) & 7)) writememql((s)+(a),v); else *(uint64_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
else \
|
||||||
|
*(uint8_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
||||||
|
#define writememw(s, a, v) \
|
||||||
|
if (writelookup2[(uint32_t)((s) + (a)) >> 12] == -1 || (((s) + (a)) & 1)) \
|
||||||
|
writememwl((s) + (a), v); \
|
||||||
|
else \
|
||||||
|
*(uint16_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
||||||
|
#define writememl(s, a, v) \
|
||||||
|
if (writelookup2[(uint32_t)((s) + (a)) >> 12] == -1 || (((s) + (a)) & 3)) \
|
||||||
|
writememll((s) + (a), v); \
|
||||||
|
else \
|
||||||
|
*(uint32_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
||||||
|
#define writememq(s, a, v) \
|
||||||
|
if (writelookup2[(uint32_t)((s) + (a)) >> 12] == -1 || (((s) + (a)) & 7)) \
|
||||||
|
writememql((s) + (a), v); \
|
||||||
|
else \
|
||||||
|
*(uint64_t *)(writelookup2[(uint32_t)((s) + (a)) >> 12] + (uint32_t)((s) + (a))) = v
|
||||||
|
|
||||||
int checkio(int port);
|
int checkio(int port);
|
||||||
|
|
||||||
#define check_io_perm(port) if (!IOPLp || (cpu_state.eflags&VM_FLAG)) \
|
#define check_io_perm(port) \
|
||||||
{ \
|
if (!IOPLp || (cpu_state.eflags & VM_FLAG)) { \
|
||||||
int tempi = checkio(port); \
|
int tempi = checkio(port); \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (tempi) \
|
return 1; \
|
||||||
{ \
|
if (tempi) { \
|
||||||
if (cpu_state.eflags & VM_FLAG) \
|
if (cpu_state.eflags & VM_FLAG) \
|
||||||
x86gpf_expected(NULL,0); \
|
x86gpf_expected(NULL, 0); \
|
||||||
else \
|
else \
|
||||||
x86gpf(NULL,0); \
|
x86gpf(NULL, 0); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SEG_CHECK_READ(seg) \
|
#define SEG_CHECK_READ(seg) \
|
||||||
do \
|
do { \
|
||||||
{ \
|
if ((seg)->base == 0xffffffff) { \
|
||||||
if ((seg)->base == 0xffffffff) \
|
x86gpf("Segment can't read", 0); \
|
||||||
{ \
|
|
||||||
x86gpf("Segment can't read", 0);\
|
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SEG_CHECK_WRITE(seg) \
|
#define SEG_CHECK_WRITE(seg) \
|
||||||
do \
|
do { \
|
||||||
{ \
|
if ((seg)->base == 0xffffffff) { \
|
||||||
if ((seg)->base == 0xffffffff) \
|
x86gpf("Segment can't write", 0); \
|
||||||
{ \
|
|
||||||
x86gpf("Segment can't write", 0);\
|
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define CHECK_READ(seg, low, high) \
|
#define CHECK_READ(seg, low, high) \
|
||||||
if ((low < (seg)->limit_low) || (high > (seg)->limit_high) || ((msw & 1) && !(cpu_state.eflags & VM_FLAG) && (((seg)->access & 10) == 8))) \
|
if ((low < (seg)->limit_low) || (high > (seg)->limit_high) || \
|
||||||
{ \
|
((msw & 1) && !(cpu_state.eflags & VM_FLAG) && (((seg)->access & 10) == 8))) { \
|
||||||
x86gpf("Limit check", 0); \
|
x86gpf("Limit check", 0); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_WRITE(seg, low, high) \
|
#define CHECK_WRITE(seg, low, high) \
|
||||||
if ((low < (seg)->limit_low) || (high > (seg)->limit_high) || !((seg)->access & 2) || ((msw & 1) && !(cpu_state.eflags & VM_FLAG) && ((seg)->access & 8))) \
|
if ((low < (seg)->limit_low) || (high > (seg)->limit_high) || !((seg)->access & 2) || \
|
||||||
{ \
|
((msw & 1) && !(cpu_state.eflags & VM_FLAG) && ((seg)->access & 8))) { \
|
||||||
x86gpf("Limit check", 0); \
|
x86gpf("Limit check", 0); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CHECK_WRITE_REP(seg, low, high) \
|
#define CHECK_WRITE_REP(seg, low, high) \
|
||||||
if ((low < (seg)->limit_low) || (high > (seg)->limit_high)) \
|
if ((low < (seg)->limit_low) || (high > (seg)->limit_high)) { \
|
||||||
{ \
|
|
||||||
x86gpf("Limit check", 0); \
|
x86gpf("Limit check", 0); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define NOTRM if (!(msw & 1) || (cpu_state.eflags & VM_FLAG))\
|
#define NOTRM \
|
||||||
{ \
|
if (!(msw & 1) || (cpu_state.eflags & VM_FLAG)) { \
|
||||||
x86_int(6); \
|
x86_int(6); \
|
||||||
return 1; \
|
return 1; \
|
||||||
}
|
}
|
||||||
@@ -116,7 +139,7 @@ static inline uint32_t fastreadl(uint32_t a) {
|
|||||||
return 0;
|
return 0;
|
||||||
pccache2 = t;
|
pccache2 = t;
|
||||||
pccache = a >> 12;
|
pccache = a >> 12;
|
||||||
//return *((uint32_t *)&pccache2[a]);
|
// return *((uint32_t *)&pccache2[a]);
|
||||||
}
|
}
|
||||||
return *((uint32_t *)&pccache2[a]);
|
return *((uint32_t *)&pccache2[a]);
|
||||||
}
|
}
|
||||||
@@ -178,9 +201,7 @@ static inline uint32_t geteal() {
|
|||||||
return readmeml(easeg, cpu_state.eaaddr);
|
return readmeml(easeg, cpu_state.eaaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint64_t geteaq() {
|
static inline uint64_t geteaq() { return readmemq(easeg, cpu_state.eaaddr); }
|
||||||
return readmemq(easeg, cpu_state.eaaddr);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline uint8_t geteab_mem() {
|
static inline uint8_t geteab_mem() {
|
||||||
if (eal_r)
|
if (eal_r)
|
||||||
@@ -198,21 +219,62 @@ static inline uint32_t geteal_mem() {
|
|||||||
return readmeml(easeg, cpu_state.eaaddr);
|
return readmeml(easeg, cpu_state.eaaddr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void seteaq(uint64_t v) {
|
static inline void seteaq(uint64_t v) { writememql(easeg + cpu_state.eaaddr, v); }
|
||||||
writememql(easeg + cpu_state.eaaddr, v);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define seteab(v) if (cpu_mod!=3) { if (eal_w) *(uint8_t *)eal_w=v; else writemembl(easeg+cpu_state.eaaddr,v); } else if (cpu_rm&4) cpu_state.regs[cpu_rm&3].b.h=v; else cpu_state.regs[cpu_rm].b.l=v
|
#define seteab(v) \
|
||||||
#define seteaw(v) if (cpu_mod!=3) { if (eal_w) *(uint16_t *)eal_w=v; else writememwl(easeg+cpu_state.eaaddr,v); } else cpu_state.regs[cpu_rm].w=v
|
if (cpu_mod != 3) { \
|
||||||
#define seteal(v) if (cpu_mod!=3) { if (eal_w) *eal_w=v; else writememll(easeg+cpu_state.eaaddr,v); } else cpu_state.regs[cpu_rm].l=v
|
if (eal_w) \
|
||||||
|
*(uint8_t *)eal_w = v; \
|
||||||
|
else \
|
||||||
|
writemembl(easeg + cpu_state.eaaddr, v); \
|
||||||
|
} else if (cpu_rm & 4) \
|
||||||
|
cpu_state.regs[cpu_rm & 3].b.h = v; \
|
||||||
|
else \
|
||||||
|
cpu_state.regs[cpu_rm].b.l = v
|
||||||
|
#define seteaw(v) \
|
||||||
|
if (cpu_mod != 3) { \
|
||||||
|
if (eal_w) \
|
||||||
|
*(uint16_t *)eal_w = v; \
|
||||||
|
else \
|
||||||
|
writememwl(easeg + cpu_state.eaaddr, v); \
|
||||||
|
} else \
|
||||||
|
cpu_state.regs[cpu_rm].w = v
|
||||||
|
#define seteal(v) \
|
||||||
|
if (cpu_mod != 3) { \
|
||||||
|
if (eal_w) \
|
||||||
|
*eal_w = v; \
|
||||||
|
else \
|
||||||
|
writememll(easeg + cpu_state.eaaddr, v); \
|
||||||
|
} else \
|
||||||
|
cpu_state.regs[cpu_rm].l = v
|
||||||
|
|
||||||
#define seteab_mem(v) if (eal_w) *(uint8_t *)eal_w=v; else writemembl(easeg+cpu_state.eaaddr,v);
|
#define seteab_mem(v) \
|
||||||
#define seteaw_mem(v) if (eal_w) *(uint16_t *)eal_w=v; else writememwl(easeg+cpu_state.eaaddr,v);
|
if (eal_w) \
|
||||||
#define seteal_mem(v) if (eal_w) *eal_w=v; else writememll(easeg+cpu_state.eaaddr,v);
|
*(uint8_t *)eal_w = v; \
|
||||||
|
else \
|
||||||
|
writemembl(easeg + cpu_state.eaaddr, v);
|
||||||
|
#define seteaw_mem(v) \
|
||||||
|
if (eal_w) \
|
||||||
|
*(uint16_t *)eal_w = v; \
|
||||||
|
else \
|
||||||
|
writememwl(easeg + cpu_state.eaaddr, v);
|
||||||
|
#define seteal_mem(v) \
|
||||||
|
if (eal_w) \
|
||||||
|
*eal_w = v; \
|
||||||
|
else \
|
||||||
|
writememll(easeg + cpu_state.eaaddr, v);
|
||||||
|
|
||||||
#define getbytef() ((uint8_t)(fetchdat)); cpu_state.pc++
|
#define getbytef() \
|
||||||
#define getwordf() ((uint16_t)(fetchdat)); cpu_state.pc+=2
|
((uint8_t)(fetchdat)); \
|
||||||
#define getbyte2f() ((uint8_t)(fetchdat>>8)); cpu_state.pc++
|
cpu_state.pc++
|
||||||
#define getword2f() ((uint16_t)(fetchdat>>8)); cpu_state.pc+=2
|
#define getwordf() \
|
||||||
|
((uint16_t)(fetchdat)); \
|
||||||
|
cpu_state.pc += 2
|
||||||
|
#define getbyte2f() \
|
||||||
|
((uint8_t)(fetchdat >> 8)); \
|
||||||
|
cpu_state.pc++
|
||||||
|
#define getword2f() \
|
||||||
|
((uint16_t)(fetchdat >> 8)); \
|
||||||
|
cpu_state.pc += 2
|
||||||
|
|
||||||
#endif /* _386_COMMON_H_ */
|
#endif /* _386_COMMON_H_ */
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@
|
|||||||
/*This file is a series of macros to get the 386+ based x87 emulation working with
|
/*This file is a series of macros to get the 386+ based x87 emulation working with
|
||||||
the 808x emulation*/
|
the 808x emulation*/
|
||||||
#define X8087
|
#define X8087
|
||||||
#define OP_TABLE(name) ops_808x_ ## name
|
#define OP_TABLE(name) ops_808x_##name
|
||||||
|
|
||||||
#define CLOCK_CYCLES(c) cycles -= (c)
|
#define CLOCK_CYCLES(c) cycles -= (c)
|
||||||
#define CLOCK_CYCLES_ALWAYS(c) cycles -= (c)
|
#define CLOCK_CYCLES_ALWAYS(c) cycles -= (c)
|
||||||
@@ -16,18 +16,13 @@
|
|||||||
#define CHECK_WRITE(seg, addr_lo, addr_hi)
|
#define CHECK_WRITE(seg, addr_lo, addr_hi)
|
||||||
#define PREFETCH_RUN(timing, bytes, rmdat, a, b, c, d, e)
|
#define PREFETCH_RUN(timing, bytes, rmdat, a, b, c, d, e)
|
||||||
|
|
||||||
static uint32_t readmeml(uint32_t seg, uint32_t addr) {
|
static uint32_t readmeml(uint32_t seg, uint32_t addr) { return readmemw(seg, addr) | (readmemw(seg, addr + 2) << 16); }
|
||||||
return readmemw(seg, addr) | (readmemw(seg, addr + 2) << 16);
|
|
||||||
}
|
|
||||||
static uint64_t readmemq(uint32_t seg, uint32_t addr) {
|
static uint64_t readmemq(uint32_t seg, uint32_t addr) {
|
||||||
return (uint64_t)readmemw(seg, addr) | ((uint64_t)readmemw(seg, addr + 2) << 16) |
|
return (uint64_t)readmemw(seg, addr) | ((uint64_t)readmemw(seg, addr + 2) << 16) |
|
||||||
((uint64_t)readmemw(seg, addr + 4) << 32) |
|
((uint64_t)readmemw(seg, addr + 4) << 32) | ((uint64_t)readmemw(seg, addr + 6) << 48);
|
||||||
((uint64_t)readmemw(seg, addr + 6) << 48);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void writememb_8087(uint32_t seg, uint32_t addr, uint8_t val) {
|
static void writememb_8087(uint32_t seg, uint32_t addr, uint8_t val) { writememb(seg + addr, val); }
|
||||||
writememb(seg + addr, val);
|
|
||||||
}
|
|
||||||
static void writememl(uint32_t seg, uint32_t addr, uint32_t val) {
|
static void writememl(uint32_t seg, uint32_t addr, uint32_t val) {
|
||||||
writememw(seg, addr, val & 0xffff);
|
writememw(seg, addr, val & 0xffff);
|
||||||
writememw(seg, addr + 2, (val >> 16) & 0xffff);
|
writememw(seg, addr + 2, (val >> 16) & 0xffff);
|
||||||
@@ -70,17 +65,17 @@ static inline void seteaq(uint64_t val) {
|
|||||||
#define VF_SET() (cpu_state.flags & V_FLAG)
|
#define VF_SET() (cpu_state.flags & V_FLAG)
|
||||||
#define ZF_SET() (cpu_state.flags & Z_FLAG)
|
#define ZF_SET() (cpu_state.flags & Z_FLAG)
|
||||||
|
|
||||||
#define cond_O ( VF_SET())
|
#define cond_O (VF_SET())
|
||||||
#define cond_NO (!VF_SET())
|
#define cond_NO (!VF_SET())
|
||||||
#define cond_B ( CF_SET())
|
#define cond_B (CF_SET())
|
||||||
#define cond_NB (!CF_SET())
|
#define cond_NB (!CF_SET())
|
||||||
#define cond_E ( ZF_SET())
|
#define cond_E (ZF_SET())
|
||||||
#define cond_NE (!ZF_SET())
|
#define cond_NE (!ZF_SET())
|
||||||
#define cond_BE ( CF_SET() || ZF_SET())
|
#define cond_BE (CF_SET() || ZF_SET())
|
||||||
#define cond_NBE (!CF_SET() && !ZF_SET())
|
#define cond_NBE (!CF_SET() && !ZF_SET())
|
||||||
#define cond_S ( NF_SET())
|
#define cond_S (NF_SET())
|
||||||
#define cond_NS (!NF_SET())
|
#define cond_NS (!NF_SET())
|
||||||
#define cond_P ( PF_SET())
|
#define cond_P (PF_SET())
|
||||||
#define cond_NP (!PF_SET())
|
#define cond_NP (!PF_SET())
|
||||||
#define cond_L (((NF_SET()) ? 1 : 0) != ((VF_SET()) ? 1 : 0))
|
#define cond_L (((NF_SET()) ? 1 : 0) != ((VF_SET()) ? 1 : 0))
|
||||||
#define cond_NL (((NF_SET()) ? 1 : 0) == ((VF_SET()) ? 1 : 0))
|
#define cond_NL (((NF_SET()) ? 1 : 0) == ((VF_SET()) ? 1 : 0))
|
||||||
|
@@ -69,14 +69,7 @@ extern int timing_jmp_rm, timing_jmp_pm, timing_jmp_pm_gate;
|
|||||||
|
|
||||||
extern int timing_misaligned;
|
extern int timing_misaligned;
|
||||||
|
|
||||||
enum {
|
enum { FPU_NONE, FPU_8087, FPU_287, FPU_287XL, FPU_387, FPU_BUILTIN };
|
||||||
FPU_NONE,
|
|
||||||
FPU_8087,
|
|
||||||
FPU_287,
|
|
||||||
FPU_287XL,
|
|
||||||
FPU_387,
|
|
||||||
FPU_BUILTIN
|
|
||||||
};
|
|
||||||
|
|
||||||
extern CPU *cpu_s;
|
extern CPU *cpu_s;
|
||||||
|
|
||||||
@@ -132,9 +125,7 @@ extern int cpu_cyrix_alignment;
|
|||||||
#define CPU_FEATURE_SYSCALL (1 << 7)
|
#define CPU_FEATURE_SYSCALL (1 << 7)
|
||||||
|
|
||||||
extern uint32_t cpu_features;
|
extern uint32_t cpu_features;
|
||||||
static inline int cpu_has_feature(int feature) {
|
static inline int cpu_has_feature(int feature) { return cpu_features & feature; }
|
||||||
return cpu_features & feature;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define CR4_TSD (1 << 2)
|
#define CR4_TSD (1 << 2)
|
||||||
#define CR4_DE (1 << 3)
|
#define CR4_DE (1 << 3)
|
||||||
|
@@ -140,7 +140,7 @@ extern int cycles_main;
|
|||||||
//#define seg_fs _fs.base
|
//#define seg_fs _fs.base
|
||||||
#define gs cpu_state.seg_gs.base
|
#define gs cpu_state.seg_gs.base
|
||||||
|
|
||||||
#define CPL ((cpu_state.seg_cs.access>>5)&3)
|
#define CPL ((cpu_state.seg_cs.access >> 5) & 3)
|
||||||
|
|
||||||
#define C_FLAG 0x0001
|
#define C_FLAG 0x0001
|
||||||
#define P_FLAG 0x0004
|
#define P_FLAG 0x0004
|
||||||
@@ -164,7 +164,7 @@ extern int cycles_main;
|
|||||||
|
|
||||||
#define IOPL ((cpu_state.flags >> 12) & 3)
|
#define IOPL ((cpu_state.flags >> 12) & 3)
|
||||||
|
|
||||||
#define IOPLp ((!(msw&1)) || (CPL<=IOPL))
|
#define IOPLp ((!(msw & 1)) || (CPL <= IOPL))
|
||||||
|
|
||||||
extern x86seg gdt, ldt, idt, tr;
|
extern x86seg gdt, ldt, idt, tr;
|
||||||
|
|
||||||
@@ -222,20 +222,28 @@ extern float mips, flops;
|
|||||||
|
|
||||||
#define setznp168 setznp16
|
#define setznp168 setznp16
|
||||||
|
|
||||||
#define getr8(r) ((r&4)?cpu_state.regs[r&3].b.h:cpu_state.regs[r&3].b.l)
|
#define getr8(r) ((r & 4) ? cpu_state.regs[r & 3].b.h : cpu_state.regs[r & 3].b.l)
|
||||||
#define getr16(r) cpu_state.regs[r].w
|
#define getr16(r) cpu_state.regs[r].w
|
||||||
#define getr32(r) cpu_state.regs[r].l
|
#define getr32(r) cpu_state.regs[r].l
|
||||||
|
|
||||||
#define setr8(r, v) if (r&4) cpu_state.regs[r&3].b.h=v; \
|
#define setr8(r, v) \
|
||||||
else cpu_state.regs[r&3].b.l=v;
|
if (r & 4) \
|
||||||
#define setr16(r, v) cpu_state.regs[r].w=v
|
cpu_state.regs[r & 3].b.h = v; \
|
||||||
#define setr32(r, v) cpu_state.regs[r].l=v
|
else \
|
||||||
|
cpu_state.regs[r & 3].b.l = v;
|
||||||
|
#define setr16(r, v) cpu_state.regs[r].w = v
|
||||||
|
#define setr32(r, v) cpu_state.regs[r].l = v
|
||||||
|
|
||||||
#define fetchea() { rmdat=readmemb(cs+pc); pc++; \
|
#define fetchea() \
|
||||||
reg=(rmdat>>3)&7; \
|
{ \
|
||||||
mod=(rmdat>>6)&3; \
|
rmdat = readmemb(cs + pc); \
|
||||||
rm=rmdat&7; \
|
pc++; \
|
||||||
if (mod!=3) fetcheal(); }
|
reg = (rmdat >> 3) & 7; \
|
||||||
|
mod = (rmdat >> 6) & 3; \
|
||||||
|
rm = rmdat & 7; \
|
||||||
|
if (mod != 3) \
|
||||||
|
fetcheal(); \
|
||||||
|
}
|
||||||
|
|
||||||
extern int optype;
|
extern int optype;
|
||||||
#define JMP 1
|
#define JMP 1
|
||||||
@@ -243,15 +251,7 @@ extern int optype;
|
|||||||
#define IRET 3
|
#define IRET 3
|
||||||
#define OPTYPE_INT 4
|
#define OPTYPE_INT 4
|
||||||
|
|
||||||
enum {
|
enum { ABRT_NONE = 0, ABRT_GEN, ABRT_TS = 0xA, ABRT_NP = 0xB, ABRT_SS = 0xC, ABRT_GPF = 0xD, ABRT_PF = 0xE };
|
||||||
ABRT_NONE = 0,
|
|
||||||
ABRT_GEN,
|
|
||||||
ABRT_TS = 0xA,
|
|
||||||
ABRT_NP = 0xB,
|
|
||||||
ABRT_SS = 0xC,
|
|
||||||
ABRT_GPF = 0xD,
|
|
||||||
ABRT_PF = 0xE
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ABRT_MASK 0x7f
|
#define ABRT_MASK 0x7f
|
||||||
/*An 'expected' exception is one that would be expected to occur on every execution
|
/*An 'expected' exception is one that would be expected to occur on every execution
|
||||||
|
@@ -85,7 +85,8 @@ static inline int ZF_SET() {
|
|||||||
case FLAGS_ADC32:
|
case FLAGS_ADC32:
|
||||||
case FLAGS_SBC8:
|
case FLAGS_SBC8:
|
||||||
case FLAGS_SBC16:
|
case FLAGS_SBC16:
|
||||||
case FLAGS_SBC32:return !cpu_state.flags_res;
|
case FLAGS_SBC32:
|
||||||
|
return !cpu_state.flags_res;
|
||||||
|
|
||||||
case FLAGS_ROL8:
|
case FLAGS_ROL8:
|
||||||
case FLAGS_ROL16:
|
case FLAGS_ROL16:
|
||||||
@@ -93,7 +94,8 @@ static inline int ZF_SET() {
|
|||||||
case FLAGS_ROR8:
|
case FLAGS_ROR8:
|
||||||
case FLAGS_ROR16:
|
case FLAGS_ROR16:
|
||||||
case FLAGS_ROR32:
|
case FLAGS_ROR32:
|
||||||
case FLAGS_UNKNOWN:return cpu_state.flags & Z_FLAG;
|
case FLAGS_UNKNOWN:
|
||||||
|
return cpu_state.flags & Z_FLAG;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -109,7 +111,8 @@ static inline int NF_SET() {
|
|||||||
case FLAGS_INC8:
|
case FLAGS_INC8:
|
||||||
case FLAGS_DEC8:
|
case FLAGS_DEC8:
|
||||||
case FLAGS_ADC8:
|
case FLAGS_ADC8:
|
||||||
case FLAGS_SBC8:return cpu_state.flags_res & 0x80;
|
case FLAGS_SBC8:
|
||||||
|
return cpu_state.flags_res & 0x80;
|
||||||
|
|
||||||
case FLAGS_ZN16:
|
case FLAGS_ZN16:
|
||||||
case FLAGS_ADD16:
|
case FLAGS_ADD16:
|
||||||
@@ -120,7 +123,8 @@ static inline int NF_SET() {
|
|||||||
case FLAGS_INC16:
|
case FLAGS_INC16:
|
||||||
case FLAGS_DEC16:
|
case FLAGS_DEC16:
|
||||||
case FLAGS_ADC16:
|
case FLAGS_ADC16:
|
||||||
case FLAGS_SBC16:return cpu_state.flags_res & 0x8000;
|
case FLAGS_SBC16:
|
||||||
|
return cpu_state.flags_res & 0x8000;
|
||||||
|
|
||||||
case FLAGS_ZN32:
|
case FLAGS_ZN32:
|
||||||
case FLAGS_ADD32:
|
case FLAGS_ADD32:
|
||||||
@@ -131,7 +135,8 @@ static inline int NF_SET() {
|
|||||||
case FLAGS_INC32:
|
case FLAGS_INC32:
|
||||||
case FLAGS_DEC32:
|
case FLAGS_DEC32:
|
||||||
case FLAGS_ADC32:
|
case FLAGS_ADC32:
|
||||||
case FLAGS_SBC32:return cpu_state.flags_res & 0x80000000;
|
case FLAGS_SBC32:
|
||||||
|
return cpu_state.flags_res & 0x80000000;
|
||||||
|
|
||||||
case FLAGS_ROL8:
|
case FLAGS_ROL8:
|
||||||
case FLAGS_ROL16:
|
case FLAGS_ROL16:
|
||||||
@@ -139,7 +144,8 @@ static inline int NF_SET() {
|
|||||||
case FLAGS_ROR8:
|
case FLAGS_ROR8:
|
||||||
case FLAGS_ROR16:
|
case FLAGS_ROR16:
|
||||||
case FLAGS_ROR32:
|
case FLAGS_ROR32:
|
||||||
case FLAGS_UNKNOWN:return cpu_state.flags & N_FLAG;
|
case FLAGS_UNKNOWN:
|
||||||
|
return cpu_state.flags & N_FLAG;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -175,7 +181,8 @@ static inline int PF_SET() {
|
|||||||
case FLAGS_ADC32:
|
case FLAGS_ADC32:
|
||||||
case FLAGS_SBC8:
|
case FLAGS_SBC8:
|
||||||
case FLAGS_SBC16:
|
case FLAGS_SBC16:
|
||||||
case FLAGS_SBC32:return znptable8[cpu_state.flags_res & 0xff] & P_FLAG;
|
case FLAGS_SBC32:
|
||||||
|
return znptable8[cpu_state.flags_res & 0xff] & P_FLAG;
|
||||||
|
|
||||||
case FLAGS_ROL8:
|
case FLAGS_ROL8:
|
||||||
case FLAGS_ROL16:
|
case FLAGS_ROL16:
|
||||||
@@ -183,7 +190,8 @@ static inline int PF_SET() {
|
|||||||
case FLAGS_ROR8:
|
case FLAGS_ROR8:
|
||||||
case FLAGS_ROR16:
|
case FLAGS_ROR16:
|
||||||
case FLAGS_ROR32:
|
case FLAGS_ROR32:
|
||||||
case FLAGS_UNKNOWN:return cpu_state.flags & P_FLAG;
|
case FLAGS_UNKNOWN:
|
||||||
|
return cpu_state.flags & P_FLAG;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -195,45 +203,71 @@ static inline int VF_SET() {
|
|||||||
case FLAGS_ZN32:
|
case FLAGS_ZN32:
|
||||||
case FLAGS_SAR8:
|
case FLAGS_SAR8:
|
||||||
case FLAGS_SAR16:
|
case FLAGS_SAR16:
|
||||||
case FLAGS_SAR32:return 0;
|
case FLAGS_SAR32:
|
||||||
|
return 0;
|
||||||
|
|
||||||
case FLAGS_ADC8:
|
case FLAGS_ADC8:
|
||||||
case FLAGS_ADD8:
|
case FLAGS_ADD8:
|
||||||
case FLAGS_INC8:return !((cpu_state.flags_op1 ^ cpu_state.flags_op2) & 0x80) && ((cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80);
|
case FLAGS_INC8:
|
||||||
|
return !((cpu_state.flags_op1 ^ cpu_state.flags_op2) & 0x80) &&
|
||||||
|
((cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80);
|
||||||
case FLAGS_ADC16:
|
case FLAGS_ADC16:
|
||||||
case FLAGS_ADD16:
|
case FLAGS_ADD16:
|
||||||
case FLAGS_INC16:return !((cpu_state.flags_op1 ^ cpu_state.flags_op2) & 0x8000) && ((cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x8000);
|
case FLAGS_INC16:
|
||||||
|
return !((cpu_state.flags_op1 ^ cpu_state.flags_op2) & 0x8000) &&
|
||||||
|
((cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x8000);
|
||||||
case FLAGS_ADC32:
|
case FLAGS_ADC32:
|
||||||
case FLAGS_ADD32:
|
case FLAGS_ADD32:
|
||||||
case FLAGS_INC32:return !((cpu_state.flags_op1 ^ cpu_state.flags_op2) & 0x80000000) && ((cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80000000);
|
case FLAGS_INC32:
|
||||||
|
return !((cpu_state.flags_op1 ^ cpu_state.flags_op2) & 0x80000000) &&
|
||||||
|
((cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80000000);
|
||||||
|
|
||||||
case FLAGS_SBC8:
|
case FLAGS_SBC8:
|
||||||
case FLAGS_SUB8:
|
case FLAGS_SUB8:
|
||||||
case FLAGS_DEC8:return ((cpu_state.flags_op1 ^ cpu_state.flags_op2) & (cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80);
|
case FLAGS_DEC8:
|
||||||
|
return ((cpu_state.flags_op1 ^ cpu_state.flags_op2) & (cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80);
|
||||||
case FLAGS_SBC16:
|
case FLAGS_SBC16:
|
||||||
case FLAGS_SUB16:
|
case FLAGS_SUB16:
|
||||||
case FLAGS_DEC16:return ((cpu_state.flags_op1 ^ cpu_state.flags_op2) & (cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x8000);
|
case FLAGS_DEC16:
|
||||||
|
return ((cpu_state.flags_op1 ^ cpu_state.flags_op2) & (cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x8000);
|
||||||
case FLAGS_SBC32:
|
case FLAGS_SBC32:
|
||||||
case FLAGS_SUB32:
|
case FLAGS_SUB32:
|
||||||
case FLAGS_DEC32:return ((cpu_state.flags_op1 ^ cpu_state.flags_op2) & (cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80000000);
|
case FLAGS_DEC32:
|
||||||
|
return ((cpu_state.flags_op1 ^ cpu_state.flags_op2) & (cpu_state.flags_op1 ^ cpu_state.flags_res) & 0x80000000);
|
||||||
|
|
||||||
case FLAGS_SHL8:return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) & 0x80);
|
case FLAGS_SHL8:
|
||||||
case FLAGS_SHL16:return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) & 0x8000);
|
return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) &
|
||||||
case FLAGS_SHL32:return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) & 0x80000000);
|
0x80);
|
||||||
|
case FLAGS_SHL16:
|
||||||
|
return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) &
|
||||||
|
0x8000);
|
||||||
|
case FLAGS_SHL32:
|
||||||
|
return (((cpu_state.flags_op1 << cpu_state.flags_op2) ^ (cpu_state.flags_op1 << (cpu_state.flags_op2 - 1))) &
|
||||||
|
0x80000000);
|
||||||
|
|
||||||
case FLAGS_SHR8:return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x80));
|
case FLAGS_SHR8:
|
||||||
case FLAGS_SHR16:return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x8000));
|
return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x80));
|
||||||
case FLAGS_SHR32:return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x80000000));
|
case FLAGS_SHR16:
|
||||||
|
return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x8000));
|
||||||
|
case FLAGS_SHR32:
|
||||||
|
return ((cpu_state.flags_op2 == 1) && (cpu_state.flags_op1 & 0x80000000));
|
||||||
|
|
||||||
case FLAGS_ROL8:return (cpu_state.flags_res ^ (cpu_state.flags_res >> 7)) & 1;
|
case FLAGS_ROL8:
|
||||||
case FLAGS_ROL16:return (cpu_state.flags_res ^ (cpu_state.flags_res >> 15)) & 1;
|
return (cpu_state.flags_res ^ (cpu_state.flags_res >> 7)) & 1;
|
||||||
case FLAGS_ROL32:return (cpu_state.flags_res ^ (cpu_state.flags_res >> 31)) & 1;
|
case FLAGS_ROL16:
|
||||||
|
return (cpu_state.flags_res ^ (cpu_state.flags_res >> 15)) & 1;
|
||||||
|
case FLAGS_ROL32:
|
||||||
|
return (cpu_state.flags_res ^ (cpu_state.flags_res >> 31)) & 1;
|
||||||
|
|
||||||
case FLAGS_ROR8:return (cpu_state.flags_res ^ (cpu_state.flags_res >> 1)) & 0x40;
|
case FLAGS_ROR8:
|
||||||
case FLAGS_ROR16:return (cpu_state.flags_res ^ (cpu_state.flags_res >> 1)) & 0x4000;
|
return (cpu_state.flags_res ^ (cpu_state.flags_res >> 1)) & 0x40;
|
||||||
case FLAGS_ROR32:return (cpu_state.flags_res ^ (cpu_state.flags_res >> 1)) & 0x40000000;
|
case FLAGS_ROR16:
|
||||||
|
return (cpu_state.flags_res ^ (cpu_state.flags_res >> 1)) & 0x4000;
|
||||||
|
case FLAGS_ROR32:
|
||||||
|
return (cpu_state.flags_res ^ (cpu_state.flags_res >> 1)) & 0x40000000;
|
||||||
|
|
||||||
case FLAGS_UNKNOWN:return cpu_state.flags & V_FLAG;
|
case FLAGS_UNKNOWN:
|
||||||
|
return cpu_state.flags & V_FLAG;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -251,14 +285,16 @@ static inline int AF_SET() {
|
|||||||
case FLAGS_SHR32:
|
case FLAGS_SHR32:
|
||||||
case FLAGS_SAR8:
|
case FLAGS_SAR8:
|
||||||
case FLAGS_SAR16:
|
case FLAGS_SAR16:
|
||||||
case FLAGS_SAR32:return 0;
|
case FLAGS_SAR32:
|
||||||
|
return 0;
|
||||||
|
|
||||||
case FLAGS_ADD8:
|
case FLAGS_ADD8:
|
||||||
case FLAGS_ADD16:
|
case FLAGS_ADD16:
|
||||||
case FLAGS_ADD32:
|
case FLAGS_ADD32:
|
||||||
case FLAGS_INC8:
|
case FLAGS_INC8:
|
||||||
case FLAGS_INC16:
|
case FLAGS_INC16:
|
||||||
case FLAGS_INC32:return ((cpu_state.flags_op1 & 0xF) + (cpu_state.flags_op2 & 0xF)) & 0x10;
|
case FLAGS_INC32:
|
||||||
|
return ((cpu_state.flags_op1 & 0xF) + (cpu_state.flags_op2 & 0xF)) & 0x10;
|
||||||
|
|
||||||
case FLAGS_ADC8:
|
case FLAGS_ADC8:
|
||||||
return ((cpu_state.flags_res & 0xf) < (cpu_state.flags_op1 & 0xf)) ||
|
return ((cpu_state.flags_res & 0xf) < (cpu_state.flags_op1 & 0xf)) ||
|
||||||
@@ -275,7 +311,8 @@ static inline int AF_SET() {
|
|||||||
case FLAGS_SUB32:
|
case FLAGS_SUB32:
|
||||||
case FLAGS_DEC8:
|
case FLAGS_DEC8:
|
||||||
case FLAGS_DEC16:
|
case FLAGS_DEC16:
|
||||||
case FLAGS_DEC32:return ((cpu_state.flags_op1 & 0xF) - (cpu_state.flags_op2 & 0xF)) & 0x10;
|
case FLAGS_DEC32:
|
||||||
|
return ((cpu_state.flags_op1 & 0xF) - (cpu_state.flags_op2 & 0xF)) & 0x10;
|
||||||
|
|
||||||
case FLAGS_SBC8:
|
case FLAGS_SBC8:
|
||||||
case FLAGS_SBC16:
|
case FLAGS_SBC16:
|
||||||
@@ -289,16 +326,20 @@ static inline int AF_SET() {
|
|||||||
case FLAGS_ROR8:
|
case FLAGS_ROR8:
|
||||||
case FLAGS_ROR16:
|
case FLAGS_ROR16:
|
||||||
case FLAGS_ROR32:
|
case FLAGS_ROR32:
|
||||||
case FLAGS_UNKNOWN:return cpu_state.flags & A_FLAG;
|
case FLAGS_UNKNOWN:
|
||||||
|
return cpu_state.flags & A_FLAG;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline int CF_SET() {
|
static inline int CF_SET() {
|
||||||
switch (cpu_state.flags_op) {
|
switch (cpu_state.flags_op) {
|
||||||
case FLAGS_ADD8:return ((cpu_state.flags_op1 + cpu_state.flags_op2) & 0x100) ? 1 : 0;
|
case FLAGS_ADD8:
|
||||||
case FLAGS_ADD16:return ((cpu_state.flags_op1 + cpu_state.flags_op2) & 0x10000) ? 1 : 0;
|
return ((cpu_state.flags_op1 + cpu_state.flags_op2) & 0x100) ? 1 : 0;
|
||||||
case FLAGS_ADD32:return (cpu_state.flags_res < cpu_state.flags_op1);
|
case FLAGS_ADD16:
|
||||||
|
return ((cpu_state.flags_op1 + cpu_state.flags_op2) & 0x10000) ? 1 : 0;
|
||||||
|
case FLAGS_ADD32:
|
||||||
|
return (cpu_state.flags_res < cpu_state.flags_op1);
|
||||||
|
|
||||||
case FLAGS_ADC8:
|
case FLAGS_ADC8:
|
||||||
return (cpu_state.flags_res < cpu_state.flags_op1) ||
|
return (cpu_state.flags_res < cpu_state.flags_op1) ||
|
||||||
@@ -312,7 +353,8 @@ static inline int CF_SET() {
|
|||||||
|
|
||||||
case FLAGS_SUB8:
|
case FLAGS_SUB8:
|
||||||
case FLAGS_SUB16:
|
case FLAGS_SUB16:
|
||||||
case FLAGS_SUB32:return (cpu_state.flags_op1 < cpu_state.flags_op2);
|
case FLAGS_SUB32:
|
||||||
|
return (cpu_state.flags_op1 < cpu_state.flags_op2);
|
||||||
|
|
||||||
case FLAGS_SBC8:
|
case FLAGS_SBC8:
|
||||||
case FLAGS_SBC16:
|
case FLAGS_SBC16:
|
||||||
@@ -320,29 +362,41 @@ static inline int CF_SET() {
|
|||||||
return (cpu_state.flags_op1 < cpu_state.flags_op2) ||
|
return (cpu_state.flags_op1 < cpu_state.flags_op2) ||
|
||||||
(cpu_state.flags_op1 == cpu_state.flags_op2 && cpu_state.flags_res != 0);
|
(cpu_state.flags_op1 == cpu_state.flags_op2 && cpu_state.flags_res != 0);
|
||||||
|
|
||||||
case FLAGS_SHL8:return ((cpu_state.flags_op1 << (cpu_state.flags_op2 - 1)) & 0x80) ? 1 : 0;
|
case FLAGS_SHL8:
|
||||||
case FLAGS_SHL16:return ((cpu_state.flags_op1 << (cpu_state.flags_op2 - 1)) & 0x8000) ? 1 : 0;
|
return ((cpu_state.flags_op1 << (cpu_state.flags_op2 - 1)) & 0x80) ? 1 : 0;
|
||||||
case FLAGS_SHL32:return ((cpu_state.flags_op1 << (cpu_state.flags_op2 - 1)) & 0x80000000) ? 1 : 0;
|
case FLAGS_SHL16:
|
||||||
|
return ((cpu_state.flags_op1 << (cpu_state.flags_op2 - 1)) & 0x8000) ? 1 : 0;
|
||||||
|
case FLAGS_SHL32:
|
||||||
|
return ((cpu_state.flags_op1 << (cpu_state.flags_op2 - 1)) & 0x80000000) ? 1 : 0;
|
||||||
|
|
||||||
case FLAGS_SHR8:
|
case FLAGS_SHR8:
|
||||||
case FLAGS_SHR16:
|
case FLAGS_SHR16:
|
||||||
case FLAGS_SHR32:return (cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
case FLAGS_SHR32:
|
||||||
|
return (cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
||||||
|
|
||||||
case FLAGS_SAR8:return ((int8_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
case FLAGS_SAR8:
|
||||||
case FLAGS_SAR16:return ((int16_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
return ((int8_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
||||||
case FLAGS_SAR32:return ((int32_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
case FLAGS_SAR16:
|
||||||
|
return ((int16_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
||||||
|
case FLAGS_SAR32:
|
||||||
|
return ((int32_t)cpu_state.flags_op1 >> (cpu_state.flags_op2 - 1)) & 1;
|
||||||
|
|
||||||
case FLAGS_ZN8:
|
case FLAGS_ZN8:
|
||||||
case FLAGS_ZN16:
|
case FLAGS_ZN16:
|
||||||
case FLAGS_ZN32:return 0;
|
case FLAGS_ZN32:
|
||||||
|
return 0;
|
||||||
|
|
||||||
case FLAGS_ROL8:
|
case FLAGS_ROL8:
|
||||||
case FLAGS_ROL16:
|
case FLAGS_ROL16:
|
||||||
case FLAGS_ROL32:return cpu_state.flags_res & 1;
|
case FLAGS_ROL32:
|
||||||
|
return cpu_state.flags_res & 1;
|
||||||
|
|
||||||
case FLAGS_ROR8:return (cpu_state.flags_res & 0x80) ? 1 : 0;
|
case FLAGS_ROR8:
|
||||||
case FLAGS_ROR16:return (cpu_state.flags_res & 0x8000) ? 1 : 0;
|
return (cpu_state.flags_res & 0x80) ? 1 : 0;
|
||||||
case FLAGS_ROR32:return (cpu_state.flags_res & 0x80000000) ? 1 : 0;
|
case FLAGS_ROR16:
|
||||||
|
return (cpu_state.flags_res & 0x8000) ? 1 : 0;
|
||||||
|
case FLAGS_ROR32:
|
||||||
|
return (cpu_state.flags_res & 0x80000000) ? 1 : 0;
|
||||||
|
|
||||||
case FLAGS_DEC8:
|
case FLAGS_DEC8:
|
||||||
case FLAGS_DEC16:
|
case FLAGS_DEC16:
|
||||||
@@ -350,7 +404,8 @@ static inline int CF_SET() {
|
|||||||
case FLAGS_INC8:
|
case FLAGS_INC8:
|
||||||
case FLAGS_INC16:
|
case FLAGS_INC16:
|
||||||
case FLAGS_INC32:
|
case FLAGS_INC32:
|
||||||
case FLAGS_UNKNOWN:return cpu_state.flags & C_FLAG;
|
case FLAGS_UNKNOWN:
|
||||||
|
return cpu_state.flags & C_FLAG;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -382,9 +437,7 @@ static inline void flags_rebuild() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void flags_extract() {
|
static inline void flags_extract() { cpu_state.flags_op = FLAGS_UNKNOWN; }
|
||||||
cpu_state.flags_op = FLAGS_UNKNOWN;
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void flags_rebuild_c() {
|
static inline void flags_rebuild_c() {
|
||||||
if (cpu_state.flags_op != FLAGS_UNKNOWN) {
|
if (cpu_state.flags_op != FLAGS_UNKNOWN) {
|
||||||
@@ -396,8 +449,7 @@ static inline void flags_rebuild_c() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static inline int flags_res_valid() {
|
static inline int flags_res_valid() {
|
||||||
if (cpu_state.flags_op == FLAGS_UNKNOWN ||
|
if (cpu_state.flags_op == FLAGS_UNKNOWN || (cpu_state.flags_op >= FLAGS_ROL8 && cpu_state.flags_op <= FLAGS_ROR32))
|
||||||
(cpu_state.flags_op >= FLAGS_ROL8 && cpu_state.flags_op <= FLAGS_ROR32))
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -246,10 +246,14 @@ static int opPI2FD(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
static int opPMULHRW(uint32_t fetchdat) {
|
static int opPMULHRW(uint32_t fetchdat) {
|
||||||
if (cpu_mod == 3) {
|
if (cpu_mod == 3) {
|
||||||
cpu_state.MM[cpu_reg].w[0] = (((int32_t)cpu_state.MM[cpu_reg].sw[0] * (int32_t)cpu_state.MM[cpu_rm].sw[0]) + 0x8000) >> 16;
|
cpu_state.MM[cpu_reg].w[0] =
|
||||||
cpu_state.MM[cpu_reg].w[1] = (((int32_t)cpu_state.MM[cpu_reg].sw[1] * (int32_t)cpu_state.MM[cpu_rm].sw[1]) + 0x8000) >> 16;
|
(((int32_t)cpu_state.MM[cpu_reg].sw[0] * (int32_t)cpu_state.MM[cpu_rm].sw[0]) + 0x8000) >> 16;
|
||||||
cpu_state.MM[cpu_reg].w[2] = (((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)cpu_state.MM[cpu_rm].sw[2]) + 0x8000) >> 16;
|
cpu_state.MM[cpu_reg].w[1] =
|
||||||
cpu_state.MM[cpu_reg].w[3] = (((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)cpu_state.MM[cpu_rm].sw[3]) + 0x8000) >> 16;
|
(((int32_t)cpu_state.MM[cpu_reg].sw[1] * (int32_t)cpu_state.MM[cpu_rm].sw[1]) + 0x8000) >> 16;
|
||||||
|
cpu_state.MM[cpu_reg].w[2] =
|
||||||
|
(((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)cpu_state.MM[cpu_rm].sw[2]) + 0x8000) >> 16;
|
||||||
|
cpu_state.MM[cpu_reg].w[3] =
|
||||||
|
(((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)cpu_state.MM[cpu_rm].sw[3]) + 0x8000) >> 16;
|
||||||
CLOCK_CYCLES(1);
|
CLOCK_CYCLES(1);
|
||||||
} else {
|
} else {
|
||||||
MMX_REG src;
|
MMX_REG src;
|
||||||
@@ -268,29 +272,45 @@ static int opPMULHRW(uint32_t fetchdat) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpFn OP_TABLE(3DNOW)[256] =
|
OpFn OP_TABLE(3DNOW)[256] = {
|
||||||
{
|
/* 00 01 02 03 04 05 06 07
|
||||||
/* 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f*/
|
08 09 0a 0b 0c 0d 0e 0f*/
|
||||||
/*00*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPI2FD, ILLEGAL, ILLEGAL,
|
/*00*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPF2ID, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPI2FD, ILLEGAL, ILLEGAL,
|
||||||
/*20*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
/*10*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*30*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPF2ID, ILLEGAL, ILLEGAL,
|
||||||
|
/*20*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
/*30*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
|
||||||
/*40*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
/*40*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*50*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*60*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
/*50*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*70*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
/*60*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
/*70*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
|
||||||
/*80*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
/*80*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*90*/ opPFCMPGE, ILLEGAL, ILLEGAL, ILLEGAL, opPFMIN, ILLEGAL, opPFRCP, opPFRSQRT, ILLEGAL, ILLEGAL, opPFSUB, ILLEGAL, ILLEGAL, ILLEGAL, opPFADD, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*a0*/ opPFCMPGT, ILLEGAL, ILLEGAL, ILLEGAL, opPFMAX, ILLEGAL, opPFRCPIT1, opPFRSQIT1, ILLEGAL, ILLEGAL, opPFSUBR, ILLEGAL, ILLEGAL, ILLEGAL, opPFACC, ILLEGAL,
|
/*90*/ opPFCMPGE, ILLEGAL, ILLEGAL, ILLEGAL, opPFMIN, ILLEGAL, opPFRCP, opPFRSQRT,
|
||||||
/*b0*/ opPFCMPEQ, ILLEGAL, ILLEGAL, ILLEGAL, opPFMUL, ILLEGAL, opPFRCPIT2, opPMULHRW, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPAVGUSB,
|
ILLEGAL, ILLEGAL, opPFSUB, ILLEGAL, ILLEGAL, ILLEGAL, opPFADD, ILLEGAL,
|
||||||
|
/*a0*/ opPFCMPGT, ILLEGAL, ILLEGAL, ILLEGAL, opPFMAX, ILLEGAL, opPFRCPIT1, opPFRSQIT1,
|
||||||
|
ILLEGAL, ILLEGAL, opPFSUBR, ILLEGAL, ILLEGAL, ILLEGAL, opPFACC, ILLEGAL,
|
||||||
|
/*b0*/ opPFCMPEQ, ILLEGAL, ILLEGAL, ILLEGAL, opPFMUL, ILLEGAL, opPFRCPIT2, opPMULHRW,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, opPAVGUSB,
|
||||||
|
|
||||||
/*c0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
/*c0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*d0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*e0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
/*d0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
/*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
/*e0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
/*f0*/ ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
|
};
|
||||||
|
|
||||||
static int op3DNOW_a16(uint32_t fetchdat) {
|
static int op3DNOW_a16(uint32_t fetchdat) {
|
||||||
uint8_t opcode;
|
uint8_t opcode;
|
||||||
|
@@ -1,291 +1,311 @@
|
|||||||
#ifndef _X86_OPS_ARITH_H_
|
#ifndef _X86_OPS_ARITH_H_
|
||||||
#define _X86_OPS_ARITH_H_
|
#define _X86_OPS_ARITH_H_
|
||||||
#define OP_ARITH(name, operation, setflags, flagops, gettempc) \
|
#define OP_ARITH(name, operation, setflags, flagops, gettempc) \
|
||||||
static int op ## name ## _b_rmw_a16(uint32_t fetchdat) \
|
static int op##name##_b_rmw_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
if (gettempc) \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
uint8_t dst = getr8(cpu_rm); \
|
uint8_t dst = getr8(cpu_rm); \
|
||||||
uint8_t src = getr8(cpu_reg); \
|
uint8_t src = getr8(cpu_reg); \
|
||||||
setflags ## 8 flagops; \
|
setflags##8 flagops; \
|
||||||
setr8(cpu_rm, operation); \
|
setr8(cpu_rm, operation); \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 0, 0, 0, 0); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
uint8_t dst; \
|
uint8_t dst; \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
dst = geteab(); if (cpu_state.abrt) return 1; \
|
dst = geteab(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
uint8_t src = getr8(cpu_reg); \
|
uint8_t src = getr8(cpu_reg); \
|
||||||
seteab(operation); if (cpu_state.abrt) return 1; \
|
seteab(operation); \
|
||||||
setflags ## 8 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##8 flagops; \
|
||||||
CLOCK_CYCLES(timing_mr); \
|
CLOCK_CYCLES(timing_mr); \
|
||||||
PREFETCH_RUN(timing_mr, 2, rmdat, 1,0,1,0, 0); \
|
PREFETCH_RUN(timing_mr, 2, rmdat, 1, 0, 1, 0, 0); \
|
||||||
} \
|
} \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## name ## _b_rmw_a32(uint32_t fetchdat) \
|
static int op##name##_b_rmw_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
if (gettempc) \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
uint8_t dst = getr8(cpu_rm); \
|
uint8_t dst = getr8(cpu_rm); \
|
||||||
uint8_t src = getr8(cpu_reg); \
|
uint8_t src = getr8(cpu_reg); \
|
||||||
setflags ## 8 flagops; \
|
setflags##8 flagops; \
|
||||||
setr8(cpu_rm, operation); \
|
setr8(cpu_rm, operation); \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 1); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 0, 0, 0, 1); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
uint8_t dst; \
|
uint8_t dst; \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
dst = geteab(); if (cpu_state.abrt) return 1; \
|
dst = geteab(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
uint8_t src = getr8(cpu_reg); \
|
uint8_t src = getr8(cpu_reg); \
|
||||||
seteab(operation); if (cpu_state.abrt) return 1; \
|
seteab(operation); \
|
||||||
setflags ## 8 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##8 flagops; \
|
||||||
CLOCK_CYCLES(timing_mr); \
|
CLOCK_CYCLES(timing_mr); \
|
||||||
PREFETCH_RUN(timing_mr, 2, rmdat, 1,0,1,0, 1); \
|
PREFETCH_RUN(timing_mr, 2, rmdat, 1, 0, 1, 0, 1); \
|
||||||
} \
|
} \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _w_rmw_a16(uint32_t fetchdat) \
|
static int op##name##_w_rmw_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
if (gettempc) \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
uint16_t dst = cpu_state.regs[cpu_rm].w; \
|
uint16_t dst = cpu_state.regs[cpu_rm].w; \
|
||||||
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
||||||
setflags ## 16 flagops; \
|
setflags##16 flagops; \
|
||||||
cpu_state.regs[cpu_rm].w = operation; \
|
cpu_state.regs[cpu_rm].w = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 0, 0, 0, 0); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
uint16_t dst; \
|
uint16_t dst; \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
dst = geteaw(); if (cpu_state.abrt) return 1; \
|
dst = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
||||||
seteaw(operation); if (cpu_state.abrt) return 1; \
|
seteaw(operation); \
|
||||||
setflags ## 16 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##16 flagops; \
|
||||||
CLOCK_CYCLES(timing_mr); \
|
CLOCK_CYCLES(timing_mr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 1,0,1,0, 0); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 1, 0, 1, 0, 0); \
|
||||||
} \
|
} \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## name ## _w_rmw_a32(uint32_t fetchdat) \
|
static int op##name##_w_rmw_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
if (gettempc) \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
uint16_t dst = cpu_state.regs[cpu_rm].w; \
|
uint16_t dst = cpu_state.regs[cpu_rm].w; \
|
||||||
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
||||||
setflags ## 16 flagops; \
|
setflags##16 flagops; \
|
||||||
cpu_state.regs[cpu_rm].w = operation; \
|
cpu_state.regs[cpu_rm].w = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 1); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 0, 0, 0, 1); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
uint16_t dst; \
|
uint16_t dst; \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
dst = geteaw(); if (cpu_state.abrt) return 1; \
|
dst = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
uint16_t src = cpu_state.regs[cpu_reg].w; \
|
||||||
seteaw(operation); if (cpu_state.abrt) return 1; \
|
seteaw(operation); \
|
||||||
setflags ## 16 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##16 flagops; \
|
||||||
CLOCK_CYCLES(timing_mr); \
|
CLOCK_CYCLES(timing_mr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 1,0,1,0, 1); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 1, 0, 1, 0, 1); \
|
||||||
} \
|
} \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _l_rmw_a16(uint32_t fetchdat) \
|
static int op##name##_l_rmw_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
if (gettempc) \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
uint32_t dst = cpu_state.regs[cpu_rm].l; \
|
uint32_t dst = cpu_state.regs[cpu_rm].l; \
|
||||||
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
||||||
setflags ## 32 flagops; \
|
setflags##32 flagops; \
|
||||||
cpu_state.regs[cpu_rm].l = operation; \
|
cpu_state.regs[cpu_rm].l = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 0, 0, 0, 0); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
uint32_t dst; \
|
uint32_t dst; \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
dst = geteal(); if (cpu_state.abrt) return 1; \
|
dst = geteal(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
||||||
seteal(operation); if (cpu_state.abrt) return 1; \
|
seteal(operation); \
|
||||||
setflags ## 32 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##32 flagops; \
|
||||||
CLOCK_CYCLES(timing_mr); \
|
CLOCK_CYCLES(timing_mr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,1,0,1, 0); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 1, 0, 1, 0); \
|
||||||
} \
|
} \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## name ## _l_rmw_a32(uint32_t fetchdat) \
|
static int op##name##_l_rmw_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
if (gettempc) \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
uint32_t dst = cpu_state.regs[cpu_rm].l; \
|
uint32_t dst = cpu_state.regs[cpu_rm].l; \
|
||||||
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
||||||
setflags ## 32 flagops; \
|
setflags##32 flagops; \
|
||||||
cpu_state.regs[cpu_rm].l = operation; \
|
cpu_state.regs[cpu_rm].l = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,0,0,0, 1); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 0, 0, 0, 1); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
uint32_t dst; \
|
uint32_t dst; \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
dst = geteal(); if (cpu_state.abrt) return 1; \
|
dst = geteal(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
uint32_t src = cpu_state.regs[cpu_reg].l; \
|
||||||
seteal(operation); if (cpu_state.abrt) return 1; \
|
seteal(operation); \
|
||||||
setflags ## 32 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##32 flagops; \
|
||||||
CLOCK_CYCLES(timing_mr); \
|
CLOCK_CYCLES(timing_mr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, rmdat, 0,1,0,1, 1); \
|
PREFETCH_RUN(timing_rr, 2, rmdat, 0, 1, 0, 1, 1); \
|
||||||
} \
|
} \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _b_rm_a16(uint32_t fetchdat) \
|
static int op##name##_b_rm_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint8_t dst, src; \
|
uint8_t dst, src; \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
dst = getr8(cpu_reg); \
|
dst = getr8(cpu_reg); \
|
||||||
src = geteab(); if (cpu_state.abrt) return 1; \
|
src = geteab(); \
|
||||||
setflags ## 8 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##8 flagops; \
|
||||||
setr8(cpu_reg, operation); \
|
setr8(cpu_reg, operation); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0); \
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## name ## _b_rm_a32(uint32_t fetchdat) \
|
static int op##name##_b_rm_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint8_t dst, src; \
|
uint8_t dst, src; \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
dst = getr8(cpu_reg); \
|
dst = getr8(cpu_reg); \
|
||||||
src = geteab(); if (cpu_state.abrt) return 1; \
|
src = geteab(); \
|
||||||
setflags ## 8 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##8 flagops; \
|
||||||
setr8(cpu_reg, operation); \
|
setr8(cpu_reg, operation); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1); \
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _w_rm_a16(uint32_t fetchdat) \
|
static int op##name##_w_rm_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint16_t dst, src; \
|
uint16_t dst, src; \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
dst = cpu_state.regs[cpu_reg].w; \
|
dst = cpu_state.regs[cpu_reg].w; \
|
||||||
src = geteaw(); if (cpu_state.abrt) return 1; \
|
src = geteaw(); \
|
||||||
setflags ## 16 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##16 flagops; \
|
||||||
cpu_state.regs[cpu_reg].w = operation; \
|
cpu_state.regs[cpu_reg].w = operation; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 0); \
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## name ## _w_rm_a32(uint32_t fetchdat) \
|
static int op##name##_w_rm_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint16_t dst, src; \
|
uint16_t dst, src; \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
dst = cpu_state.regs[cpu_reg].w; \
|
dst = cpu_state.regs[cpu_reg].w; \
|
||||||
src = geteaw(); if (cpu_state.abrt) return 1; \
|
src = geteaw(); \
|
||||||
setflags ## 16 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##16 flagops; \
|
||||||
cpu_state.regs[cpu_reg].w = operation; \
|
cpu_state.regs[cpu_reg].w = operation; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rm); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1,0,0,0, 1); \
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _l_rm_a16(uint32_t fetchdat) \
|
static int op##name##_l_rm_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint32_t dst, src; \
|
uint32_t dst, src; \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
dst = cpu_state.regs[cpu_reg].l; \
|
dst = cpu_state.regs[cpu_reg].l; \
|
||||||
src = geteal(); if (cpu_state.abrt) return 1; \
|
src = geteal(); \
|
||||||
setflags ## 32 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##32 flagops; \
|
||||||
cpu_state.regs[cpu_reg].l = operation; \
|
cpu_state.regs[cpu_reg].l = operation; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 0); \
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## name ## _l_rm_a32(uint32_t fetchdat) \
|
static int op##name##_l_rm_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint32_t dst, src; \
|
uint32_t dst, src; \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
dst = cpu_state.regs[cpu_reg].l; \
|
dst = cpu_state.regs[cpu_reg].l; \
|
||||||
src = geteal(); if (cpu_state.abrt) return 1; \
|
src = geteal(); \
|
||||||
setflags ## 32 flagops; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setflags##32 flagops; \
|
||||||
cpu_state.regs[cpu_reg].l = operation; \
|
cpu_state.regs[cpu_reg].l = operation; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_rml); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1,0,0, 1); \
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _AL_imm(uint32_t fetchdat) \
|
static int op##name##_AL_imm(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint8_t dst = AL; \
|
uint8_t dst = AL; \
|
||||||
uint8_t src = getbytef(); \
|
uint8_t src = getbytef(); \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
setflags ## 8 flagops; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
|
setflags##8 flagops; \
|
||||||
AL = operation; \
|
AL = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 2, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 2, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _AX_imm(uint32_t fetchdat) \
|
static int op##name##_AX_imm(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint16_t dst = AX; \
|
uint16_t dst = AX; \
|
||||||
uint16_t src = getwordf(); \
|
uint16_t src = getwordf(); \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (gettempc) \
|
||||||
setflags ## 16 flagops; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
|
setflags##16 flagops; \
|
||||||
AX = operation; \
|
AX = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 3, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 3, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _EAX_imm(uint32_t fetchdat) \
|
static int op##name##_EAX_imm(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint32_t dst = EAX; \
|
uint32_t dst = EAX; \
|
||||||
uint32_t src = getlong(); if (cpu_state.abrt) return 1; \
|
uint32_t src = getlong(); \
|
||||||
if (gettempc) tempc = CF_SET() ? 1 : 0; \
|
if (cpu_state.abrt) \
|
||||||
setflags ## 32 flagops; \
|
return 1; \
|
||||||
|
if (gettempc) \
|
||||||
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
|
setflags##32 flagops; \
|
||||||
EAX = operation; \
|
EAX = operation; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 5, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 5, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -294,7 +314,7 @@ OP_ARITH(ADC, dst + src + tempc, setadc, (dst, src), 1)
|
|||||||
OP_ARITH(SUB, dst - src, setsub, (dst, src), 0)
|
OP_ARITH(SUB, dst - src, setsub, (dst, src), 0)
|
||||||
OP_ARITH(SBB, dst - (src + tempc), setsbc, (dst, src), 1)
|
OP_ARITH(SBB, dst - (src + tempc), setsbc, (dst, src), 1)
|
||||||
OP_ARITH(OR, dst | src, setznp, (dst | src), 0)
|
OP_ARITH(OR, dst | src, setznp, (dst | src), 0)
|
||||||
OP_ARITH(AND, dst & src, setznp, (dst & src), 0)
|
OP_ARITH(AND, dst &src, setznp, (dst & src), 0)
|
||||||
OP_ARITH(XOR, dst ^ src, setznp, (dst ^ src), 0)
|
OP_ARITH(XOR, dst ^ src, setznp, (dst ^ src), 0)
|
||||||
|
|
||||||
static int opCMP_b_rmw_a16(uint32_t fetchdat) {
|
static int opCMP_b_rmw_a16(uint32_t fetchdat) {
|
||||||
@@ -633,53 +653,70 @@ static int opTEST_EAX(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ARITH_MULTI(ea_width, flag_width) \
|
#define ARITH_MULTI(ea_width, flag_width) \
|
||||||
dst = getea ## ea_width(); if (cpu_state.abrt) return 1; \
|
dst = getea##ea_width(); \
|
||||||
switch (rmdat&0x38) \
|
if (cpu_state.abrt) \
|
||||||
{ \
|
return 1; \
|
||||||
|
switch (rmdat & 0x38) { \
|
||||||
case 0x00: /*ADD ea, #*/ \
|
case 0x00: /*ADD ea, #*/ \
|
||||||
setea ## ea_width(dst + src); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst + src); \
|
||||||
setadd ## flag_width(dst, src); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setadd##flag_width(dst, src); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x08: /*OR ea, #*/ \
|
case 0x08: /*OR ea, #*/ \
|
||||||
dst |= src; \
|
dst |= src; \
|
||||||
setea ## ea_width(dst); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst); \
|
||||||
setznp ## flag_width(dst); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setznp##flag_width(dst); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x10: /*ADC ea, #*/ \
|
case 0x10: /*ADC ea, #*/ \
|
||||||
tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
setea ## ea_width(dst + src + tempc); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst + src + tempc); \
|
||||||
setadc ## flag_width(dst, src); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setadc##flag_width(dst, src); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x18: /*SBB ea, #*/ \
|
case 0x18: /*SBB ea, #*/ \
|
||||||
tempc = CF_SET() ? 1 : 0; \
|
tempc = CF_SET() ? 1 : 0; \
|
||||||
setea ## ea_width(dst - (src + tempc)); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst - (src + tempc)); \
|
||||||
setsbc ## flag_width(dst, src); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setsbc##flag_width(dst, src); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x20: /*AND ea, #*/ \
|
case 0x20: /*AND ea, #*/ \
|
||||||
dst &= src; \
|
dst &= src; \
|
||||||
setea ## ea_width(dst); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst); \
|
||||||
setznp ## flag_width(dst); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setznp##flag_width(dst); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x28: /*SUB ea, #*/ \
|
case 0x28: /*SUB ea, #*/ \
|
||||||
setea ## ea_width(dst - src); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst - src); \
|
||||||
setsub ## flag_width(dst, src); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setsub##flag_width(dst, src); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x30: /*XOR ea, #*/ \
|
case 0x30: /*XOR ea, #*/ \
|
||||||
dst ^= src; \
|
dst ^= src; \
|
||||||
setea ## ea_width(dst); if (cpu_state.abrt) return 1; \
|
setea##ea_width(dst); \
|
||||||
setznp ## flag_width(dst); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
setznp##flag_width(dst); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mr); \
|
||||||
break; \
|
break; \
|
||||||
case 0x38: /*CMP ea, #*/ \
|
case 0x38: /*CMP ea, #*/ \
|
||||||
setsub ## flag_width(dst, src); \
|
setsub##flag_width(dst, src); \
|
||||||
if (is486) CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2); \
|
if (is486) \
|
||||||
else CLOCK_CYCLES((cpu_mod == 3) ? 2 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 1 : 2); \
|
||||||
|
else \
|
||||||
|
CLOCK_CYCLES((cpu_mod == 3) ? 2 : 7); \
|
||||||
break; \
|
break; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -696,7 +733,8 @@ static int op80_a16(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -713,7 +751,8 @@ static int op80_a32(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -730,7 +769,8 @@ static int op81_w_a16(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -747,7 +787,8 @@ static int op81_w_a32(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 4, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -764,7 +805,8 @@ static int op81_l_a16(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -781,7 +823,8 @@ static int op81_l_a32(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 6, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -801,7 +844,8 @@ static int op83_w_a16(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -820,7 +864,8 @@ static int op83_w_a32(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -840,7 +885,8 @@ static int op83_l_a16(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -859,7 +905,8 @@ static int op83_l_a32(uint32_t fetchdat) {
|
|||||||
if ((rmdat & 0x38) == 0x38)
|
if ((rmdat & 0x38) == 0x38)
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mr, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1);
|
||||||
else
|
else
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_rm, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -82,96 +82,118 @@ static int opBT_l_r_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define opBT(name, operation) \
|
#define opBT(name, operation) \
|
||||||
static int opBT ## name ## _w_r_a16(uint32_t fetchdat) \
|
static int opBT##name##_w_r_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int tempc; \
|
int tempc; \
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
\
|
\
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].w / 16) * 2); eal_r = eal_w = 0; \
|
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].w / 16) * 2); \
|
||||||
temp = geteaw(); if (cpu_state.abrt) return 1; \
|
eal_r = eal_w = 0; \
|
||||||
|
temp = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].w & 15))) ? 1 : 0; \
|
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].w & 15))) ? 1 : 0; \
|
||||||
temp operation (1 << (cpu_state.regs[cpu_reg].w & 15)); \
|
temp operation(1 << (cpu_state.regs[cpu_reg].w & 15)); \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
else cpu_state.flags &= ~C_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
else \
|
||||||
|
cpu_state.flags &= ~C_FLAG; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(6); \
|
CLOCK_CYCLES(6); \
|
||||||
PREFETCH_RUN(6, 2, rmdat, 1,0,1,0, 0); \
|
PREFETCH_RUN(6, 2, rmdat, 1, 0, 1, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opBT ## name ## _w_r_a32(uint32_t fetchdat) \
|
static int opBT##name##_w_r_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int tempc; \
|
int tempc; \
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
\
|
\
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].w / 16) * 2); eal_r = eal_w = 0; \
|
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].w / 16) * 2); \
|
||||||
temp = geteaw(); if (cpu_state.abrt) return 1; \
|
eal_r = eal_w = 0; \
|
||||||
|
temp = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].w & 15))) ? 1 : 0; \
|
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].w & 15))) ? 1 : 0; \
|
||||||
temp operation (1 << (cpu_state.regs[cpu_reg].w & 15)); \
|
temp operation(1 << (cpu_state.regs[cpu_reg].w & 15)); \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
else cpu_state.flags &= ~C_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
else \
|
||||||
|
cpu_state.flags &= ~C_FLAG; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(6); \
|
CLOCK_CYCLES(6); \
|
||||||
PREFETCH_RUN(6, 2, rmdat, 1,0,1,0, 1); \
|
PREFETCH_RUN(6, 2, rmdat, 1, 0, 1, 0, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opBT ## name ## _l_r_a16(uint32_t fetchdat) \
|
static int opBT##name##_l_r_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int tempc; \
|
int tempc; \
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
\
|
\
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].l / 32) * 4); eal_r = eal_w = 0; \
|
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].l / 32) * 4); \
|
||||||
temp = geteal(); if (cpu_state.abrt) return 1; \
|
eal_r = eal_w = 0; \
|
||||||
|
temp = geteal(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].l & 31))) ? 1 : 0; \
|
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].l & 31))) ? 1 : 0; \
|
||||||
temp operation (1 << (cpu_state.regs[cpu_reg].l & 31)); \
|
temp operation(1 << (cpu_state.regs[cpu_reg].l & 31)); \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
else cpu_state.flags &= ~C_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
else \
|
||||||
|
cpu_state.flags &= ~C_FLAG; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(6); \
|
CLOCK_CYCLES(6); \
|
||||||
PREFETCH_RUN(6, 2, rmdat, 0,1,0,1, 0); \
|
PREFETCH_RUN(6, 2, rmdat, 0, 1, 0, 1, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opBT ## name ## _l_r_a32(uint32_t fetchdat) \
|
static int opBT##name##_l_r_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int tempc; \
|
int tempc; \
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
\
|
\
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
SEG_CHECK_WRITE(cpu_state.ea_seg); \
|
||||||
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].l / 32) * 4); eal_r = eal_w = 0; \
|
cpu_state.eaaddr += ((cpu_state.regs[cpu_reg].l / 32) * 4); \
|
||||||
temp = geteal(); if (cpu_state.abrt) return 1; \
|
eal_r = eal_w = 0; \
|
||||||
|
temp = geteal(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].l & 31))) ? 1 : 0; \
|
tempc = (temp & (1 << (cpu_state.regs[cpu_reg].l & 31))) ? 1 : 0; \
|
||||||
temp operation (1 << (cpu_state.regs[cpu_reg].l & 31)); \
|
temp operation(1 << (cpu_state.regs[cpu_reg].l & 31)); \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
else cpu_state.flags &= ~C_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
else \
|
||||||
|
cpu_state.flags &= ~C_FLAG; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(6); \
|
CLOCK_CYCLES(6); \
|
||||||
PREFETCH_RUN(6, 2, rmdat, 0,1,0,1, 1); \
|
PREFETCH_RUN(6, 2, rmdat, 0, 1, 0, 1, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opBT(C, ^=)
|
opBT(C, ^=) opBT(R, &= ~) opBT(S, |=)
|
||||||
opBT(R, &=~)
|
|
||||||
opBT(S, |=)
|
|
||||||
|
|
||||||
static int opBA_w_a16(uint32_t fetchdat) {
|
static int opBA_w_a16(uint32_t fetchdat) {
|
||||||
int tempc, count;
|
int tempc, count;
|
||||||
uint16_t temp;
|
uint16_t temp;
|
||||||
|
|
||||||
@@ -204,7 +226,8 @@ static int opBA_w_a16(uint32_t fetchdat) {
|
|||||||
temp ^= (1 << count);
|
temp ^= (1 << count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -253,7 +276,8 @@ static int opBA_w_a32(uint32_t fetchdat) {
|
|||||||
temp ^= (1 << count);
|
temp ^= (1 << count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -303,7 +327,8 @@ static int opBA_l_a16(uint32_t fetchdat) {
|
|||||||
temp ^= (1 << count);
|
temp ^= (1 << count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -352,7 +377,8 @@ static int opBA_l_a32(uint32_t fetchdat) {
|
|||||||
temp ^= (1 << count);
|
temp ^= (1 << count);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad 0F BA opcode %02X\n", rmdat & 0x38);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
|
@@ -3,22 +3,18 @@
|
|||||||
#define BS_common(start, end, dir, dest, time) \
|
#define BS_common(start, end, dir, dest, time) \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
instr_cycles = 0; \
|
instr_cycles = 0; \
|
||||||
if (temp) \
|
if (temp) { \
|
||||||
{ \
|
|
||||||
int c; \
|
int c; \
|
||||||
cpu_state.flags &= ~Z_FLAG; \
|
cpu_state.flags &= ~Z_FLAG; \
|
||||||
for (c = start; c != end; c += dir) \
|
for (c = start; c != end; c += dir) { \
|
||||||
{ \
|
|
||||||
CLOCK_CYCLES(time); \
|
CLOCK_CYCLES(time); \
|
||||||
instr_cycles += time; \
|
instr_cycles += time; \
|
||||||
if (temp & (1 << c)) \
|
if (temp & (1 << c)) { \
|
||||||
{ \
|
|
||||||
dest = c; \
|
dest = c; \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
} \
|
} else \
|
||||||
else \
|
|
||||||
cpu_state.flags |= Z_FLAG;
|
cpu_state.flags |= Z_FLAG;
|
||||||
|
|
||||||
static int opBSF_w_a16(uint32_t fetchdat) {
|
static int opBSF_w_a16(uint32_t fetchdat) {
|
||||||
|
@@ -6,26 +6,46 @@
|
|||||||
cpu_state.pc = new_pc; \
|
cpu_state.pc = new_pc; \
|
||||||
optype = CALL; \
|
optype = CALL; \
|
||||||
cgate16 = cgate32 = 0; \
|
cgate16 = cgate32 = 0; \
|
||||||
if (msw & 1) loadcscall(new_seg, old_pc); \
|
if (msw & 1) \
|
||||||
else \
|
loadcscall(new_seg, old_pc); \
|
||||||
{ \
|
else { \
|
||||||
loadcs(new_seg); \
|
loadcs(new_seg); \
|
||||||
cycles -= timing_call_rm; \
|
cycles -= timing_call_rm; \
|
||||||
} \
|
} \
|
||||||
optype = 0; \
|
optype = 0; \
|
||||||
if (cpu_state.abrt) { cgate16 = cgate32 = 0; return 1; } \
|
if (cpu_state.abrt) { \
|
||||||
oldss = ss; \
|
cgate16 = cgate32 = 0; \
|
||||||
if (cgate32) \
|
return 1; \
|
||||||
{ \
|
|
||||||
uint32_t old_esp = ESP; \
|
|
||||||
PUSH_L(old_cs); if (cpu_state.abrt) { CS = old_cs; cgate16 = cgate32 = 0; return 1; } \
|
|
||||||
PUSH_L(old_pc); if (cpu_state.abrt) { CS = old_cs; ESP = old_esp; return 1; } \
|
|
||||||
} \
|
} \
|
||||||
else \
|
oldss = ss; \
|
||||||
{ \
|
if (cgate32) { \
|
||||||
uint32_t old_esp = ESP; \
|
uint32_t old_esp = ESP; \
|
||||||
PUSH_W(old_cs); if (cpu_state.abrt) { CS = old_cs; cgate16 = cgate32 = 0; return 1; } \
|
PUSH_L(old_cs); \
|
||||||
PUSH_W(old_pc); if (cpu_state.abrt) { CS = old_cs; ESP = old_esp; return 1; } \
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
cgate16 = cgate32 = 0; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
PUSH_L(old_pc); \
|
||||||
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
ESP = old_esp; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
uint32_t old_esp = ESP; \
|
||||||
|
PUSH_W(old_cs); \
|
||||||
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
cgate16 = cgate32 = 0; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
PUSH_W(old_pc); \
|
||||||
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
ESP = old_esp; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define CALL_FAR_l(new_seg, new_pc) \
|
#define CALL_FAR_l(new_seg, new_pc) \
|
||||||
@@ -34,26 +54,46 @@
|
|||||||
cpu_state.pc = new_pc; \
|
cpu_state.pc = new_pc; \
|
||||||
optype = CALL; \
|
optype = CALL; \
|
||||||
cgate16 = cgate32 = 0; \
|
cgate16 = cgate32 = 0; \
|
||||||
if (msw & 1) loadcscall(new_seg, old_pc); \
|
if (msw & 1) \
|
||||||
else \
|
loadcscall(new_seg, old_pc); \
|
||||||
{ \
|
else { \
|
||||||
loadcs(new_seg); \
|
loadcs(new_seg); \
|
||||||
cycles -= timing_call_rm; \
|
cycles -= timing_call_rm; \
|
||||||
} \
|
} \
|
||||||
optype = 0; \
|
optype = 0; \
|
||||||
if (cpu_state.abrt) { cgate16 = cgate32 = 0; return 1; } \
|
if (cpu_state.abrt) { \
|
||||||
oldss = ss; \
|
cgate16 = cgate32 = 0; \
|
||||||
if (cgate16) \
|
return 1; \
|
||||||
{ \
|
|
||||||
uint32_t old_esp = ESP; \
|
|
||||||
PUSH_W(old_cs); if (cpu_state.abrt) { CS = old_cs; cgate16 = cgate32 = 0; return 1; } \
|
|
||||||
PUSH_W(old_pc); if (cpu_state.abrt) { CS = old_cs; ESP = old_esp; return 1; } \
|
|
||||||
} \
|
} \
|
||||||
else \
|
oldss = ss; \
|
||||||
{ \
|
if (cgate16) { \
|
||||||
uint32_t old_esp = ESP; \
|
uint32_t old_esp = ESP; \
|
||||||
PUSH_L(old_cs); if (cpu_state.abrt) { CS = old_cs; cgate16 = cgate32 = 0; return 1; } \
|
PUSH_W(old_cs); \
|
||||||
PUSH_L(old_pc); if (cpu_state.abrt) { CS = old_cs; ESP = old_esp; return 1; } \
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
cgate16 = cgate32 = 0; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
PUSH_W(old_pc); \
|
||||||
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
ESP = old_esp; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
uint32_t old_esp = ESP; \
|
||||||
|
PUSH_L(old_cs); \
|
||||||
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
cgate16 = cgate32 = 0; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
PUSH_L(old_pc); \
|
||||||
|
if (cpu_state.abrt) { \
|
||||||
|
CS = old_cs; \
|
||||||
|
ESP = old_esp; \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
static int opCALL_far_w(uint32_t fetchdat) {
|
static int opCALL_far_w(uint32_t fetchdat) {
|
||||||
@@ -115,7 +155,8 @@ static int opFF_w_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setadd16nc(temp, 1);
|
setadd16nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
break;
|
break;
|
||||||
case 0x08: /*DEC w*/
|
case 0x08: /*DEC w*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -128,7 +169,8 @@ static int opFF_w_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub16nc(temp, 1);
|
setsub16nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
break;
|
break;
|
||||||
case 0x10: /*CALL*/
|
case 0x10: /*CALL*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -202,7 +244,7 @@ static int opFF_w_a16(uint32_t fetchdat) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return cpu_state.abrt;
|
return cpu_state.abrt;
|
||||||
@@ -229,7 +271,8 @@ static int opFF_w_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setadd16nc(temp, 1);
|
setadd16nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
break;
|
break;
|
||||||
case 0x08: /*DEC w*/
|
case 0x08: /*DEC w*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -242,7 +285,8 @@ static int opFF_w_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub16nc(temp, 1);
|
setsub16nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
break;
|
break;
|
||||||
case 0x10: /*CALL*/
|
case 0x10: /*CALL*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -316,7 +360,7 @@ static int opFF_w_a32(uint32_t fetchdat) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return cpu_state.abrt;
|
return cpu_state.abrt;
|
||||||
@@ -344,7 +388,8 @@ static int opFF_l_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setadd32nc(temp, 1);
|
setadd32nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 0);
|
||||||
break;
|
break;
|
||||||
case 0x08: /*DEC l*/
|
case 0x08: /*DEC l*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -357,7 +402,8 @@ static int opFF_l_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub32nc(temp, 1);
|
setsub32nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 0);
|
||||||
break;
|
break;
|
||||||
case 0x10: /*CALL*/
|
case 0x10: /*CALL*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -431,7 +477,7 @@ static int opFF_l_a16(uint32_t fetchdat) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return cpu_state.abrt;
|
return cpu_state.abrt;
|
||||||
@@ -458,7 +504,8 @@ static int opFF_l_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setadd32nc(temp, 1);
|
setadd32nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 1);
|
||||||
break;
|
break;
|
||||||
case 0x08: /*DEC l*/
|
case 0x08: /*DEC l*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -471,7 +518,8 @@ static int opFF_l_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub32nc(temp, 1);
|
setsub32nc(temp, 1);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 1);
|
||||||
break;
|
break;
|
||||||
case 0x10: /*CALL*/
|
case 0x10: /*CALL*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -546,7 +594,7 @@ static int opFF_l_a32(uint32_t fetchdat) {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
// fatal("Bad FF opcode %02X\n",rmdat&0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return cpu_state.abrt;
|
return cpu_state.abrt;
|
||||||
|
@@ -29,7 +29,8 @@ static void opSVDC_common(uint32_t fetchdat) {
|
|||||||
cyrix_write_seg_descriptor(easeg + cpu_state.eaaddr, &cpu_state.seg_gs);
|
cyrix_write_seg_descriptor(easeg + cpu_state.eaaddr, &cpu_state.seg_gs);
|
||||||
writememw(0, easeg + cpu_state.eaaddr + 8, GS);
|
writememw(0, easeg + cpu_state.eaaddr + 8, GS);
|
||||||
break;
|
break;
|
||||||
default:pclog("opSVDC: unknown rmdat %02x\n", rmdat);
|
default:
|
||||||
|
pclog("opSVDC: unknown rmdat %02x\n", rmdat);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -71,7 +72,8 @@ static void opRSDC_common(uint32_t fetchdat) {
|
|||||||
case 0x28: /*GS*/
|
case 0x28: /*GS*/
|
||||||
cyrix_load_seg_descriptor(easeg + cpu_state.eaaddr, &cpu_state.seg_gs);
|
cyrix_load_seg_descriptor(easeg + cpu_state.eaaddr, &cpu_state.seg_gs);
|
||||||
break;
|
break;
|
||||||
default:pclog("opRSDC: unknown rmdat %02x\n", rmdat);
|
default:
|
||||||
|
pclog("opRSDC: unknown rmdat %02x\n", rmdat);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,8 +23,7 @@ static int opCLD(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
static int opCLI(uint32_t fetchdat) {
|
static int opCLI(uint32_t fetchdat) {
|
||||||
if (!IOPLp) {
|
if (!IOPLp) {
|
||||||
if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) ||
|
if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) || ((cpu_state.eflags & VM_FLAG) && (cr4 & CR4_VME))) {
|
||||||
((cpu_state.eflags & VM_FLAG) && (cr4 & CR4_VME))) {
|
|
||||||
cpu_state.eflags &= ~VIF_FLAG;
|
cpu_state.eflags &= ~VIF_FLAG;
|
||||||
} else {
|
} else {
|
||||||
x86gpf(NULL, 0);
|
x86gpf(NULL, 0);
|
||||||
@@ -53,8 +52,7 @@ static int opSTD(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
static int opSTI(uint32_t fetchdat) {
|
static int opSTI(uint32_t fetchdat) {
|
||||||
if (!IOPLp) {
|
if (!IOPLp) {
|
||||||
if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) ||
|
if ((!(cpu_state.eflags & VM_FLAG) && (cr4 & CR4_PVI)) || ((cpu_state.eflags & VM_FLAG) && (cr4 & CR4_VME))) {
|
||||||
((cpu_state.eflags & VM_FLAG) && (cr4 & CR4_VME))) {
|
|
||||||
if (cpu_state.eflags & VIP_FLAG) {
|
if (cpu_state.eflags & VIP_FLAG) {
|
||||||
x86gpf(NULL, 0);
|
x86gpf(NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
|
@@ -1,60 +1,28 @@
|
|||||||
#ifndef _X86_OPS_FPU_H_
|
#ifndef _X86_OPS_FPU_H_
|
||||||
#define _X86_OPS_FPU_H_
|
#define _X86_OPS_FPU_H_
|
||||||
static int opESCAPE_d8_a16(uint32_t fetchdat) {
|
static int opESCAPE_d8_a16(uint32_t fetchdat) { return x86_opcodes_d8_a16[(fetchdat >> 3) & 0x1f](fetchdat); }
|
||||||
return x86_opcodes_d8_a16[(fetchdat >> 3) & 0x1f](fetchdat);
|
static int opESCAPE_d8_a32(uint32_t fetchdat) { return x86_opcodes_d8_a32[(fetchdat >> 3) & 0x1f](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_d8_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_d8_a32[(fetchdat >> 3) & 0x1f](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_d9_a16(uint32_t fetchdat) {
|
static int opESCAPE_d9_a16(uint32_t fetchdat) { return x86_opcodes_d9_a16[fetchdat & 0xff](fetchdat); }
|
||||||
return x86_opcodes_d9_a16[fetchdat & 0xff](fetchdat);
|
static int opESCAPE_d9_a32(uint32_t fetchdat) { return x86_opcodes_d9_a32[fetchdat & 0xff](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_d9_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_d9_a32[fetchdat & 0xff](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_da_a16(uint32_t fetchdat) {
|
static int opESCAPE_da_a16(uint32_t fetchdat) { return x86_opcodes_da_a16[fetchdat & 0xff](fetchdat); }
|
||||||
return x86_opcodes_da_a16[fetchdat & 0xff](fetchdat);
|
static int opESCAPE_da_a32(uint32_t fetchdat) { return x86_opcodes_da_a32[fetchdat & 0xff](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_da_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_da_a32[fetchdat & 0xff](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_db_a16(uint32_t fetchdat) {
|
static int opESCAPE_db_a16(uint32_t fetchdat) { return x86_opcodes_db_a16[fetchdat & 0xff](fetchdat); }
|
||||||
return x86_opcodes_db_a16[fetchdat & 0xff](fetchdat);
|
static int opESCAPE_db_a32(uint32_t fetchdat) { return x86_opcodes_db_a32[fetchdat & 0xff](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_db_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_db_a32[fetchdat & 0xff](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_dc_a16(uint32_t fetchdat) {
|
static int opESCAPE_dc_a16(uint32_t fetchdat) { return x86_opcodes_dc_a16[(fetchdat >> 3) & 0x1f](fetchdat); }
|
||||||
return x86_opcodes_dc_a16[(fetchdat >> 3) & 0x1f](fetchdat);
|
static int opESCAPE_dc_a32(uint32_t fetchdat) { return x86_opcodes_dc_a32[(fetchdat >> 3) & 0x1f](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_dc_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_dc_a32[(fetchdat >> 3) & 0x1f](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_dd_a16(uint32_t fetchdat) {
|
static int opESCAPE_dd_a16(uint32_t fetchdat) { return x86_opcodes_dd_a16[fetchdat & 0xff](fetchdat); }
|
||||||
return x86_opcodes_dd_a16[fetchdat & 0xff](fetchdat);
|
static int opESCAPE_dd_a32(uint32_t fetchdat) { return x86_opcodes_dd_a32[fetchdat & 0xff](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_dd_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_dd_a32[fetchdat & 0xff](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_de_a16(uint32_t fetchdat) {
|
static int opESCAPE_de_a16(uint32_t fetchdat) { return x86_opcodes_de_a16[fetchdat & 0xff](fetchdat); }
|
||||||
return x86_opcodes_de_a16[fetchdat & 0xff](fetchdat);
|
static int opESCAPE_de_a32(uint32_t fetchdat) { return x86_opcodes_de_a32[fetchdat & 0xff](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_de_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_de_a32[fetchdat & 0xff](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opESCAPE_df_a16(uint32_t fetchdat) {
|
static int opESCAPE_df_a16(uint32_t fetchdat) { return x86_opcodes_df_a16[fetchdat & 0xff](fetchdat); }
|
||||||
return x86_opcodes_df_a16[fetchdat & 0xff](fetchdat);
|
static int opESCAPE_df_a32(uint32_t fetchdat) { return x86_opcodes_df_a32[fetchdat & 0xff](fetchdat); }
|
||||||
}
|
|
||||||
static int opESCAPE_df_a32(uint32_t fetchdat) {
|
|
||||||
return x86_opcodes_df_a32[fetchdat & 0xff](fetchdat);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int opWAIT(uint32_t fetchdat) {
|
static int opWAIT(uint32_t fetchdat) {
|
||||||
if ((cr0 & 0xa) == 0xa) {
|
if ((cr0 & 0xa) == 0xa) {
|
||||||
|
@@ -1,12 +1,11 @@
|
|||||||
#ifndef _X86_OPS_INC_DEC_H_
|
#ifndef _X86_OPS_INC_DEC_H_
|
||||||
#define _X86_OPS_INC_DEC_H_
|
#define _X86_OPS_INC_DEC_H_
|
||||||
#define INC_DEC_OP(name, reg, inc, setflags) \
|
#define INC_DEC_OP(name, reg, inc, setflags) \
|
||||||
static int op ## name (uint32_t fetchdat) \
|
static int op##name(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
setflags(reg, 1); \
|
setflags(reg, 1); \
|
||||||
reg += inc; \
|
reg += inc; \
|
||||||
CLOCK_CYCLES(timing_rr); \
|
CLOCK_CYCLES(timing_rr); \
|
||||||
PREFETCH_RUN(timing_rr, 1, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_rr, 1, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,7 +45,7 @@ static int opINT(uint32_t fetchdat) {
|
|||||||
t += (temp >> 3);
|
t += (temp >> 3);
|
||||||
if (t <= tr.limit) {
|
if (t <= tr.limit) {
|
||||||
cpl_override = 1;
|
cpl_override = 1;
|
||||||
d = readmemb(tr.base, t);// + (temp >> 3));
|
d = readmemb(tr.base, t); // + (temp >> 3));
|
||||||
cpl_override = 0;
|
cpl_override = 0;
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -60,10 +60,10 @@ static int opINT(uint32_t fetchdat) {
|
|||||||
x86gpf_expected(NULL, 0);
|
x86gpf_expected(NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// /*if (temp == 0x10 && AH == 0xe) */pclog("INT %02X : %04X %04X %04X %04X %c %04X:%04X\n", temp, AX, BX, CX, DX, (AL < 32) ? ' ' : AL, CS, pc);
|
// /*if (temp == 0x10 && AH == 0xe) */pclog("INT %02X : %04X %04X %04X %04X %c %04X:%04X\n", temp, AX, BX, CX,
|
||||||
// if (CS == 0x0028 && pc == 0xC03813C0)
|
// DX, (AL < 32) ? ' ' : AL, CS, pc); if (CS == 0x0028 && pc == 0xC03813C0)
|
||||||
// output = 3;
|
// output = 3;
|
||||||
/* if (pc == 0x8028009A)
|
/* if (pc == 0x8028009A)
|
||||||
output = 3;
|
output = 3;
|
||||||
if (pc == 0x80282B6F)
|
if (pc == 0x80282B6F)
|
||||||
{
|
{
|
||||||
@@ -73,20 +73,20 @@ static int opINT(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
if (pc == 0x802809CE)
|
if (pc == 0x802809CE)
|
||||||
fatal("RIGHT\n");*/
|
fatal("RIGHT\n");*/
|
||||||
// if (CS == 0x0028 && pc == 0x80037FE9)
|
// if (CS == 0x0028 && pc == 0x80037FE9)
|
||||||
// output = 3;
|
// output = 3;
|
||||||
//if (CS == 0x9087 && pc == 0x3763)
|
// if (CS == 0x9087 && pc == 0x3763)
|
||||||
// fatal("Here\n");
|
// fatal("Here\n");
|
||||||
//if (CS==0x9087 && pc == 0x0850)
|
// if (CS==0x9087 && pc == 0x0850)
|
||||||
// output = 1;
|
// output = 1;
|
||||||
|
|
||||||
/* if (output && pc == 0x80033008)
|
/* if (output && pc == 0x80033008)
|
||||||
{
|
{
|
||||||
__times++;
|
__times++;
|
||||||
if (__times == 2)
|
if (__times == 2)
|
||||||
fatal("WRONG\n");
|
fatal("WRONG\n");
|
||||||
}*/
|
}*/
|
||||||
/* if (output && pc == 0x80D8)
|
/* if (output && pc == 0x80D8)
|
||||||
{
|
{
|
||||||
__times++;
|
__times++;
|
||||||
if (__times == 2)
|
if (__times == 2)
|
||||||
|
@@ -134,7 +134,7 @@ static int opOUT_AL_DX(uint32_t fetchdat) {
|
|||||||
return x86_was_reset;
|
return x86_was_reset;
|
||||||
}
|
}
|
||||||
static int opOUT_AX_DX(uint32_t fetchdat) {
|
static int opOUT_AX_DX(uint32_t fetchdat) {
|
||||||
//pclog("OUT_AX_DX %04X %04X\n", DX, AX);
|
// pclog("OUT_AX_DX %04X %04X\n", DX, AX);
|
||||||
check_io_perm(DX);
|
check_io_perm(DX);
|
||||||
check_io_perm(DX + 1);
|
check_io_perm(DX + 1);
|
||||||
outw(DX, AX);
|
outw(DX, AX);
|
||||||
|
@@ -1,16 +1,16 @@
|
|||||||
#ifndef _X86_OPS_JUMP_H_
|
#ifndef _X86_OPS_JUMP_H_
|
||||||
#define _X86_OPS_JUMP_H_
|
#define _X86_OPS_JUMP_H_
|
||||||
#define cond_O ( VF_SET())
|
#define cond_O (VF_SET())
|
||||||
#define cond_NO (!VF_SET())
|
#define cond_NO (!VF_SET())
|
||||||
#define cond_B ( CF_SET())
|
#define cond_B (CF_SET())
|
||||||
#define cond_NB (!CF_SET())
|
#define cond_NB (!CF_SET())
|
||||||
#define cond_E ( ZF_SET())
|
#define cond_E (ZF_SET())
|
||||||
#define cond_NE (!ZF_SET())
|
#define cond_NE (!ZF_SET())
|
||||||
#define cond_BE ( CF_SET() || ZF_SET())
|
#define cond_BE (CF_SET() || ZF_SET())
|
||||||
#define cond_NBE (!CF_SET() && !ZF_SET())
|
#define cond_NBE (!CF_SET() && !ZF_SET())
|
||||||
#define cond_S ( NF_SET())
|
#define cond_S (NF_SET())
|
||||||
#define cond_NS (!NF_SET())
|
#define cond_NS (!NF_SET())
|
||||||
#define cond_P ( PF_SET())
|
#define cond_P (PF_SET())
|
||||||
#define cond_NP (!PF_SET())
|
#define cond_NP (!PF_SET())
|
||||||
#define cond_L (((NF_SET()) ? 1 : 0) != ((VF_SET()) ? 1 : 0))
|
#define cond_L (((NF_SET()) ? 1 : 0) != ((VF_SET()) ? 1 : 0))
|
||||||
#define cond_NL (((NF_SET()) ? 1 : 0) == ((VF_SET()) ? 1 : 0))
|
#define cond_NL (((NF_SET()) ? 1 : 0) == ((VF_SET()) ? 1 : 0))
|
||||||
@@ -18,78 +18,59 @@
|
|||||||
#define cond_NLE (((NF_SET()) ? 1 : 0) == ((VF_SET()) ? 1 : 0) && (!ZF_SET()))
|
#define cond_NLE (((NF_SET()) ? 1 : 0) == ((VF_SET()) ? 1 : 0) && (!ZF_SET()))
|
||||||
|
|
||||||
#define opJ(condition) \
|
#define opJ(condition) \
|
||||||
static int opJ ## condition(uint32_t fetchdat) \
|
static int opJ##condition(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int8_t offset = (int8_t)getbytef(); \
|
int8_t offset = (int8_t)getbytef(); \
|
||||||
CLOCK_CYCLES(timing_bnt); \
|
CLOCK_CYCLES(timing_bnt); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
cpu_state.pc += offset; \
|
cpu_state.pc += offset; \
|
||||||
if (!(cpu_state.op32 & 0x100)) \
|
if (!(cpu_state.op32 & 0x100)) \
|
||||||
cpu_state.pc &= 0xffff; \
|
cpu_state.pc &= 0xffff; \
|
||||||
CLOCK_CYCLES_ALWAYS(timing_bt); \
|
CLOCK_CYCLES_ALWAYS(timing_bt); \
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
PREFETCH_RUN(timing_bt+timing_bnt, 2, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_bt + timing_bnt, 2, -1, 0, 0, 0, 0, 0); \
|
||||||
PREFETCH_FLUSH(); \
|
PREFETCH_FLUSH(); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(timing_bnt, 2, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_bnt, 2, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opJ ## condition ## _w(uint32_t fetchdat) \
|
static int opJ##condition##_w(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int16_t offset = (int16_t)getwordf(); \
|
int16_t offset = (int16_t)getwordf(); \
|
||||||
CLOCK_CYCLES(timing_bnt); \
|
CLOCK_CYCLES(timing_bnt); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
cpu_state.pc += offset; \
|
cpu_state.pc += offset; \
|
||||||
cpu_state.pc &= 0xffff; \
|
cpu_state.pc &= 0xffff; \
|
||||||
CLOCK_CYCLES_ALWAYS(timing_bt); \
|
CLOCK_CYCLES_ALWAYS(timing_bt); \
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
PREFETCH_RUN(timing_bt+timing_bnt, 3, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_bt + timing_bnt, 3, -1, 0, 0, 0, 0, 0); \
|
||||||
PREFETCH_FLUSH(); \
|
PREFETCH_FLUSH(); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(timing_bnt, 3, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_bnt, 3, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opJ ## condition ## _l(uint32_t fetchdat) \
|
static int opJ##condition##_l(uint32_t fetchdat) { \
|
||||||
{ \
|
uint32_t offset = getlong(); \
|
||||||
uint32_t offset = getlong(); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
CLOCK_CYCLES(timing_bnt); \
|
CLOCK_CYCLES(timing_bnt); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
cpu_state.pc += offset; \
|
cpu_state.pc += offset; \
|
||||||
CLOCK_CYCLES_ALWAYS(timing_bt); \
|
CLOCK_CYCLES_ALWAYS(timing_bt); \
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
PREFETCH_RUN(timing_bt+timing_bnt, 5, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_bt + timing_bnt, 5, -1, 0, 0, 0, 0, 0); \
|
||||||
PREFETCH_FLUSH(); \
|
PREFETCH_FLUSH(); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(timing_bnt, 5, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(timing_bnt, 5, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
}
|
||||||
|
|
||||||
opJ(O)
|
opJ(O) opJ(NO) opJ(B) opJ(NB) opJ(E) opJ(NE) opJ(BE) opJ(NBE) opJ(S) opJ(NS) opJ(P) opJ(NP) opJ(L) opJ(NL) opJ(LE) opJ(NLE)
|
||||||
opJ(NO)
|
|
||||||
opJ(B)
|
|
||||||
opJ(NB)
|
|
||||||
opJ(E)
|
|
||||||
opJ(NE)
|
|
||||||
opJ(BE)
|
|
||||||
opJ(NBE)
|
|
||||||
opJ(S)
|
|
||||||
opJ(NS)
|
|
||||||
opJ(P)
|
|
||||||
opJ(NP)
|
|
||||||
opJ(L)
|
|
||||||
opJ(NL)
|
|
||||||
opJ(LE)
|
|
||||||
opJ(NLE)
|
|
||||||
|
|
||||||
static int opLOOPNE_w(uint32_t fetchdat) {
|
static int opLOOPNE_w(uint32_t fetchdat) {
|
||||||
int8_t offset = (int8_t)getbytef();
|
int8_t offset = (int8_t)getbytef();
|
||||||
CX--;
|
CX--;
|
||||||
CLOCK_CYCLES((is486) ? 7 : 11);
|
CLOCK_CYCLES((is486) ? 7 : 11);
|
||||||
|
@@ -54,7 +54,8 @@ static int opF6_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*TEST b,#8*/
|
case 0x00: /*TEST b,#8*/
|
||||||
case 0x08:src = readmemb(cs, cpu_state.pc);
|
case 0x08:
|
||||||
|
src = readmemb(cs, cpu_state.pc);
|
||||||
cpu_state.pc++;
|
cpu_state.pc++;
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -72,7 +73,8 @@ static int opF6_a16(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*NEG b*/
|
case 0x18: /*NEG b*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -82,7 +84,8 @@ static int opF6_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub8(0, dst);
|
setsub8(0, dst);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*MUL AL,b*/
|
case 0x20: /*MUL AL,b*/
|
||||||
AX = AL * dst;
|
AX = AL * dst;
|
||||||
@@ -138,7 +141,7 @@ static int opF6_a16(uint32_t fetchdat) {
|
|||||||
cpu_state.flags &= ~1;
|
cpu_state.flags &= ~1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// pclog("IDIVb exception - %X / %08X = %X\n", tempws, dst, tempws2);
|
// pclog("IDIVb exception - %X / %08X = %X\n", tempws, dst, tempws2);
|
||||||
x86_int(0);
|
x86_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -146,7 +149,8 @@ static int opF6_a16(uint32_t fetchdat) {
|
|||||||
PREFETCH_RUN(19, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
PREFETCH_RUN(19, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad F6 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad F6 opcode %02X\n", rmdat & 0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -165,7 +169,8 @@ static int opF6_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*TEST b,#8*/
|
case 0x00: /*TEST b,#8*/
|
||||||
case 0x08:src = readmemb(cs, cpu_state.pc);
|
case 0x08:
|
||||||
|
src = readmemb(cs, cpu_state.pc);
|
||||||
cpu_state.pc++;
|
cpu_state.pc++;
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
@@ -183,7 +188,8 @@ static int opF6_a32(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*NEG b*/
|
case 0x18: /*NEG b*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -193,7 +199,8 @@ static int opF6_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub8(0, dst);
|
setsub8(0, dst);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*MUL AL,b*/
|
case 0x20: /*MUL AL,b*/
|
||||||
AX = AL * dst;
|
AX = AL * dst;
|
||||||
@@ -249,7 +256,7 @@ static int opF6_a32(uint32_t fetchdat) {
|
|||||||
cpu_state.flags &= ~1;
|
cpu_state.flags &= ~1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// pclog("IDIVb exception - %X / %08X = %X\n", tempws, dst, tempws2);
|
// pclog("IDIVb exception - %X / %08X = %X\n", tempws, dst, tempws2);
|
||||||
x86_int(0);
|
x86_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -257,7 +264,8 @@ static int opF6_a32(uint32_t fetchdat) {
|
|||||||
PREFETCH_RUN(19, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
PREFETCH_RUN(19, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad F6 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad F6 opcode %02X\n", rmdat & 0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -277,7 +285,8 @@ static int opF7_w_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*TEST w*/
|
case 0x00: /*TEST w*/
|
||||||
case 0x08:src = getword();
|
case 0x08:
|
||||||
|
src = getword();
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
setznp16(src & dst);
|
setznp16(src & dst);
|
||||||
@@ -294,7 +303,8 @@ static int opF7_w_a16(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*NEG w*/
|
case 0x18: /*NEG w*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -304,7 +314,8 @@ static int opF7_w_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub16(0, dst);
|
setsub16(0, dst);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 0);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*MUL AX,w*/
|
case 0x20: /*MUL AX,w*/
|
||||||
templ = AX * dst;
|
templ = AX * dst;
|
||||||
@@ -340,7 +351,7 @@ static int opF7_w_a16(uint32_t fetchdat) {
|
|||||||
if (!cpu_iscyrix)
|
if (!cpu_iscyrix)
|
||||||
setznp16(AX); /*Not a Cyrix*/
|
setznp16(AX); /*Not a Cyrix*/
|
||||||
} else {
|
} else {
|
||||||
// fatal("DIVw BY 0 %04X:%04X %i\n",cs>>4,pc,ins);
|
// fatal("DIVw BY 0 %04X:%04X %i\n",cs>>4,pc,ins);
|
||||||
x86_int(0);
|
x86_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -358,7 +369,7 @@ static int opF7_w_a16(uint32_t fetchdat) {
|
|||||||
if (!cpu_iscyrix)
|
if (!cpu_iscyrix)
|
||||||
setznp16(AX); /*Not a Cyrix*/
|
setznp16(AX); /*Not a Cyrix*/
|
||||||
} else {
|
} else {
|
||||||
// pclog("IDIVw exception - %X / %08X = %X\n",tempws, dst, tempws2);
|
// pclog("IDIVw exception - %X / %08X = %X\n",tempws, dst, tempws2);
|
||||||
x86_int(0);
|
x86_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -366,7 +377,8 @@ static int opF7_w_a16(uint32_t fetchdat) {
|
|||||||
PREFETCH_RUN(27, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
PREFETCH_RUN(27, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -385,7 +397,8 @@ static int opF7_w_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*TEST w*/
|
case 0x00: /*TEST w*/
|
||||||
case 0x08:src = getword();
|
case 0x08:
|
||||||
|
src = getword();
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
setznp16(src & dst);
|
setznp16(src & dst);
|
||||||
@@ -402,7 +415,8 @@ static int opF7_w_a32(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*NEG w*/
|
case 0x18: /*NEG w*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -412,7 +426,8 @@ static int opF7_w_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub16(0, dst);
|
setsub16(0, dst);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mm);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1,
|
||||||
|
0, 1);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*MUL AX,w*/
|
case 0x20: /*MUL AX,w*/
|
||||||
templ = AX * dst;
|
templ = AX * dst;
|
||||||
@@ -448,7 +463,7 @@ static int opF7_w_a32(uint32_t fetchdat) {
|
|||||||
if (!cpu_iscyrix)
|
if (!cpu_iscyrix)
|
||||||
setznp16(AX); /*Not a Cyrix*/
|
setznp16(AX); /*Not a Cyrix*/
|
||||||
} else {
|
} else {
|
||||||
// fatal("DIVw BY 0 %04X:%04X %i\n",cs>>4,pc,ins);
|
// fatal("DIVw BY 0 %04X:%04X %i\n",cs>>4,pc,ins);
|
||||||
x86_int(0);
|
x86_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -466,7 +481,7 @@ static int opF7_w_a32(uint32_t fetchdat) {
|
|||||||
if (!cpu_iscyrix)
|
if (!cpu_iscyrix)
|
||||||
setznp16(AX); /*Not a Cyrix*/
|
setznp16(AX); /*Not a Cyrix*/
|
||||||
} else {
|
} else {
|
||||||
// pclog("IDIVw exception - %X / %08X = %X\n", tempws, dst, tempws2);
|
// pclog("IDIVw exception - %X / %08X = %X\n", tempws, dst, tempws2);
|
||||||
x86_int(0);
|
x86_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -474,7 +489,8 @@ static int opF7_w_a32(uint32_t fetchdat) {
|
|||||||
PREFETCH_RUN(27, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
PREFETCH_RUN(27, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -493,7 +509,8 @@ static int opF7_l_a16(uint32_t fetchdat) {
|
|||||||
|
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*TEST l*/
|
case 0x00: /*TEST l*/
|
||||||
case 0x08:src = getlong();
|
case 0x08:
|
||||||
|
src = getlong();
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
setznp32(src & dst);
|
setznp32(src & dst);
|
||||||
@@ -510,7 +527,8 @@ static int opF7_l_a16(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 0);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*NEG l*/
|
case 0x18: /*NEG l*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -520,7 +538,8 @@ static int opF7_l_a16(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub32(0, dst);
|
setsub32(0, dst);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 0);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*MUL EAX,l*/
|
case 0x20: /*MUL EAX,l*/
|
||||||
temp64 = (uint64_t)EAX * (uint64_t)dst;
|
temp64 = (uint64_t)EAX * (uint64_t)dst;
|
||||||
@@ -563,7 +582,8 @@ static int opF7_l_a16(uint32_t fetchdat) {
|
|||||||
PREFETCH_RUN(43, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0);
|
PREFETCH_RUN(43, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -581,7 +601,8 @@ static int opF7_l_a32(uint32_t fetchdat) {
|
|||||||
|
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*TEST l*/
|
case 0x00: /*TEST l*/
|
||||||
case 0x08:src = getlong();
|
case 0x08:
|
||||||
|
src = getlong();
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
setznp32(src & dst);
|
setznp32(src & dst);
|
||||||
@@ -598,7 +619,8 @@ static int opF7_l_a32(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 1);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*NEG l*/
|
case 0x18: /*NEG l*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -608,7 +630,8 @@ static int opF7_l_a32(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
setsub32(0, dst);
|
setsub32(0, dst);
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
CLOCK_CYCLES((cpu_mod == 3) ? timing_rr : timing_mml);
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1);
|
PREFETCH_RUN((cpu_mod == 3) ? timing_rr : timing_mm, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0,
|
||||||
|
(cpu_mod == 3) ? 0 : 1, 1);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*MUL EAX,l*/
|
case 0x20: /*MUL EAX,l*/
|
||||||
temp64 = (uint64_t)EAX * (uint64_t)dst;
|
temp64 = (uint64_t)EAX * (uint64_t)dst;
|
||||||
@@ -651,7 +674,8 @@ static int opF7_l_a32(uint32_t fetchdat) {
|
|||||||
PREFETCH_RUN(43, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1);
|
PREFETCH_RUN(43, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, 0, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad F7 opcode %02X\n", rmdat & 0x38);
|
||||||
x86illegal();
|
x86illegal();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -987,7 +1011,8 @@ static int opSYSENTER(uint32_t fetchdat) {
|
|||||||
x86gpf(NULL, 0);
|
x86gpf(NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// pclog("opSYSENTER: CS=%04x EIP=%08x ESP=%08x %04x:%08x %i\n", sysenter_cs, sysenter_eip, sysenter_esp, CS,cpu_state.pc, times);
|
// pclog("opSYSENTER: CS=%04x EIP=%08x ESP=%08x %04x:%08x %i\n", sysenter_cs, sysenter_eip, sysenter_esp,
|
||||||
|
// CS,cpu_state.pc, times);
|
||||||
sysenter();
|
sysenter();
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -998,7 +1023,7 @@ static int opSYSEXIT(uint32_t fetchdat) {
|
|||||||
x86gpf(NULL, 0);
|
x86gpf(NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
// pclog("opSYSEXIT\n");
|
// pclog("opSYSEXIT\n");
|
||||||
sysexit();
|
sysexit();
|
||||||
CPU_BLOCK_END();
|
CPU_BLOCK_END();
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -6,27 +6,24 @@
|
|||||||
#define USATW(val) (((val) < 0) ? 0 : (((val) > 65535) ? 65535 : (val)))
|
#define USATW(val) (((val) < 0) ? 0 : (((val) > 65535) ? 65535 : (val)))
|
||||||
|
|
||||||
#define MMX_GETSRC() \
|
#define MMX_GETSRC() \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
src = cpu_state.MM[cpu_rm]; \
|
src = cpu_state.MM[cpu_rm]; \
|
||||||
CLOCK_CYCLES(1); \
|
CLOCK_CYCLES(1); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
src.q = readmemq(easeg, cpu_state.eaaddr); if (cpu_state.abrt) return 1; \
|
src.q = readmemq(easeg, cpu_state.eaaddr); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
CLOCK_CYCLES(2); \
|
CLOCK_CYCLES(2); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define MMX_ENTER() \
|
#define MMX_ENTER() \
|
||||||
if (!cpu_has_feature(CPU_FEATURE_MMX)) \
|
if (!cpu_has_feature(CPU_FEATURE_MMX)) { \
|
||||||
{ \
|
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
x86illegal(); \
|
x86illegal(); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
if (cr0 & 0xc) \
|
if (cr0 & 0xc) { \
|
||||||
{ \
|
|
||||||
x86_int(7); \
|
x86_int(7); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
|
@@ -233,12 +233,14 @@ static int opPMADDWD_a16(uint32_t fetchdat) {
|
|||||||
if (cpu_state.MM[cpu_reg].l[0] == 0x80008000 && src.l[0] == 0x80008000)
|
if (cpu_state.MM[cpu_reg].l[0] == 0x80008000 && src.l[0] == 0x80008000)
|
||||||
cpu_state.MM[cpu_reg].l[0] = 0x80000000;
|
cpu_state.MM[cpu_reg].l[0] = 0x80000000;
|
||||||
else
|
else
|
||||||
cpu_state.MM[cpu_reg].sl[0] = ((int32_t)cpu_state.MM[cpu_reg].sw[0] * (int32_t)src.sw[0]) + ((int32_t)cpu_state.MM[cpu_reg].sw[1] * (int32_t)src.sw[1]);
|
cpu_state.MM[cpu_reg].sl[0] = ((int32_t)cpu_state.MM[cpu_reg].sw[0] * (int32_t)src.sw[0]) +
|
||||||
|
((int32_t)cpu_state.MM[cpu_reg].sw[1] * (int32_t)src.sw[1]);
|
||||||
|
|
||||||
if (cpu_state.MM[cpu_reg].l[1] == 0x80008000 && src.l[1] == 0x80008000)
|
if (cpu_state.MM[cpu_reg].l[1] == 0x80008000 && src.l[1] == 0x80008000)
|
||||||
cpu_state.MM[cpu_reg].l[1] = 0x80000000;
|
cpu_state.MM[cpu_reg].l[1] = 0x80000000;
|
||||||
else
|
else
|
||||||
cpu_state.MM[cpu_reg].sl[1] = ((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)src.sw[2]) + ((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)src.sw[3]);
|
cpu_state.MM[cpu_reg].sl[1] = ((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)src.sw[2]) +
|
||||||
|
((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)src.sw[3]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -252,12 +254,14 @@ static int opPMADDWD_a32(uint32_t fetchdat) {
|
|||||||
if (cpu_state.MM[cpu_reg].l[0] == 0x80008000 && src.l[0] == 0x80008000)
|
if (cpu_state.MM[cpu_reg].l[0] == 0x80008000 && src.l[0] == 0x80008000)
|
||||||
cpu_state.MM[cpu_reg].l[0] = 0x80000000;
|
cpu_state.MM[cpu_reg].l[0] = 0x80000000;
|
||||||
else
|
else
|
||||||
cpu_state.MM[cpu_reg].sl[0] = ((int32_t)cpu_state.MM[cpu_reg].sw[0] * (int32_t)src.sw[0]) + ((int32_t)cpu_state.MM[cpu_reg].sw[1] * (int32_t)src.sw[1]);
|
cpu_state.MM[cpu_reg].sl[0] = ((int32_t)cpu_state.MM[cpu_reg].sw[0] * (int32_t)src.sw[0]) +
|
||||||
|
((int32_t)cpu_state.MM[cpu_reg].sw[1] * (int32_t)src.sw[1]);
|
||||||
|
|
||||||
if (cpu_state.MM[cpu_reg].l[1] == 0x80008000 && src.l[1] == 0x80008000)
|
if (cpu_state.MM[cpu_reg].l[1] == 0x80008000 && src.l[1] == 0x80008000)
|
||||||
cpu_state.MM[cpu_reg].l[1] = 0x80000000;
|
cpu_state.MM[cpu_reg].l[1] = 0x80000000;
|
||||||
else
|
else
|
||||||
cpu_state.MM[cpu_reg].sl[1] = ((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)src.sw[2]) + ((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)src.sw[3]);
|
cpu_state.MM[cpu_reg].sl[1] = ((int32_t)cpu_state.MM[cpu_reg].sw[2] * (int32_t)src.sw[2]) +
|
||||||
|
((int32_t)cpu_state.MM[cpu_reg].sw[3] * (int32_t)src.sw[3]);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
#ifndef _X86_OPS_MMX_SHIFT_H_
|
#ifndef _X86_OPS_MMX_SHIFT_H_
|
||||||
#define _X86_OPS_MMX_SHIFT_H_
|
#define _X86_OPS_MMX_SHIFT_H_
|
||||||
#define MMX_GETSHIFT() \
|
#define MMX_GETSHIFT() \
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) { \
|
||||||
{ \
|
|
||||||
shift = cpu_state.MM[cpu_rm].b[0]; \
|
shift = cpu_state.MM[cpu_rm].b[0]; \
|
||||||
CLOCK_CYCLES(1); \
|
CLOCK_CYCLES(1); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
shift = readmemb(easeg, cpu_state.eaaddr); if (cpu_state.abrt) return 0; \
|
shift = readmemb(easeg, cpu_state.eaaddr); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 0; \
|
||||||
CLOCK_CYCLES(2); \
|
CLOCK_CYCLES(2); \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +49,8 @@ static int opPSxxW_imm(uint32_t fetchdat) {
|
|||||||
cpu_state.MM[reg].w[3] <<= shift;
|
cpu_state.MM[reg].w[3] <<= shift;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:pclog("Bad PSxxW (0F 71) instruction %02X\n", op);
|
default:
|
||||||
|
pclog("Bad PSxxW (0F 71) instruction %02X\n", op);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -206,7 +206,8 @@ static int opPSxxD_imm(uint32_t fetchdat) {
|
|||||||
cpu_state.MM[reg].l[1] <<= shift;
|
cpu_state.MM[reg].l[1] <<= shift;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:pclog("Bad PSxxD (0F 72) instruction %02X\n", op);
|
default:
|
||||||
|
pclog("Bad PSxxD (0F 72) instruction %02X\n", op);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
return 0;
|
return 0;
|
||||||
@@ -345,7 +346,8 @@ static int opPSxxQ_imm(uint32_t fetchdat) {
|
|||||||
else
|
else
|
||||||
cpu_state.MM[reg].q <<= shift;
|
cpu_state.MM[reg].q <<= shift;
|
||||||
break;
|
break;
|
||||||
default:pclog("Bad PSxxQ (0F 73) instruction %02X\n", op);
|
default:
|
||||||
|
pclog("Bad PSxxQ (0F 73) instruction %02X\n", op);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
return 0;
|
return 0;
|
||||||
|
@@ -653,76 +653,72 @@ static int opMOV_r_l_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define opCMOV(condition) \
|
#define opCMOV(condition) \
|
||||||
static int opCMOV ## condition ## _w_a16(uint32_t fetchdat) \
|
static int opCMOV##condition##_w_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) \
|
||||||
cpu_state.regs[cpu_reg].w = cpu_state.regs[cpu_rm].w; \
|
cpu_state.regs[cpu_reg].w = cpu_state.regs[cpu_rm].w; \
|
||||||
else \
|
else { \
|
||||||
{ \
|
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr+1); \
|
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr + 1); \
|
||||||
temp = geteaw(); if (cpu_state.abrt) return 1; \
|
temp = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].w = temp; \
|
cpu_state.regs[cpu_reg].w = temp; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
CLOCK_CYCLES(1); \
|
CLOCK_CYCLES(1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opCMOV ## condition ## _w_a32(uint32_t fetchdat) \
|
static int opCMOV##condition##_w_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) \
|
||||||
cpu_state.regs[cpu_reg].w = cpu_state.regs[cpu_rm].w; \
|
cpu_state.regs[cpu_reg].w = cpu_state.regs[cpu_rm].w; \
|
||||||
else \
|
else { \
|
||||||
{ \
|
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr+1); \
|
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr + 1); \
|
||||||
temp = geteaw(); if (cpu_state.abrt) return 1; \
|
temp = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].w = temp; \
|
cpu_state.regs[cpu_reg].w = temp; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
CLOCK_CYCLES(1); \
|
CLOCK_CYCLES(1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opCMOV ## condition ## _l_a16(uint32_t fetchdat) \
|
static int opCMOV##condition##_l_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) \
|
||||||
cpu_state.regs[cpu_reg].l = cpu_state.regs[cpu_rm].l; \
|
cpu_state.regs[cpu_reg].l = cpu_state.regs[cpu_rm].l; \
|
||||||
else \
|
else { \
|
||||||
{ \
|
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr+3); \
|
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr + 3); \
|
||||||
temp = geteal(); if (cpu_state.abrt) return 1; \
|
temp = geteal(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].l = temp; \
|
cpu_state.regs[cpu_reg].l = temp; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
CLOCK_CYCLES(1); \
|
CLOCK_CYCLES(1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opCMOV ## condition ## _l_a32(uint32_t fetchdat) \
|
static int opCMOV##condition##_l_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cond_ ## condition) \
|
if (cond_##condition) { \
|
||||||
{ \
|
|
||||||
if (cpu_mod == 3) \
|
if (cpu_mod == 3) \
|
||||||
cpu_state.regs[cpu_reg].l = cpu_state.regs[cpu_rm].l; \
|
cpu_state.regs[cpu_reg].l = cpu_state.regs[cpu_rm].l; \
|
||||||
else \
|
else { \
|
||||||
{ \
|
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr+3); \
|
CHECK_READ(cpu_state.ea_seg, cpu_state.eaaddr, cpu_state.eaaddr + 3); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
temp = geteal(); if (cpu_state.abrt) return 1; \
|
temp = geteal(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].l = temp; \
|
cpu_state.regs[cpu_reg].l = temp; \
|
||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
@@ -730,21 +726,7 @@ static int opMOV_r_l_a32(uint32_t fetchdat) {
|
|||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opCMOV(O)
|
opCMOV(O) opCMOV(NO) opCMOV(B) opCMOV(NB) opCMOV(E) opCMOV(NE) opCMOV(BE) opCMOV(NBE) opCMOV(S) opCMOV(NS) opCMOV(P) opCMOV(NP)
|
||||||
opCMOV(NO)
|
opCMOV(L) opCMOV(NL) opCMOV(LE) opCMOV(NLE)
|
||||||
opCMOV(B)
|
|
||||||
opCMOV(NB)
|
|
||||||
opCMOV(E)
|
|
||||||
opCMOV(NE)
|
|
||||||
opCMOV(BE)
|
|
||||||
opCMOV(NBE)
|
|
||||||
opCMOV(S)
|
|
||||||
opCMOV(NS)
|
|
||||||
opCMOV(P)
|
|
||||||
opCMOV(NP)
|
|
||||||
opCMOV(L)
|
|
||||||
opCMOV(NL)
|
|
||||||
opCMOV(LE)
|
|
||||||
opCMOV(NLE)
|
|
||||||
|
|
||||||
#endif /* _X86_OPS_MOV_H_ */
|
#endif /* _X86_OPS_MOV_H_ */
|
||||||
|
@@ -8,20 +8,24 @@ static int opMOV_r_CRx_a16(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
fetch_ea_16(fetchdat);
|
fetch_ea_16(fetchdat);
|
||||||
switch (cpu_reg) {
|
switch (cpu_reg) {
|
||||||
case 0:cpu_state.regs[cpu_rm].l = cr0;
|
case 0:
|
||||||
|
cpu_state.regs[cpu_rm].l = cr0;
|
||||||
if (is486)
|
if (is486)
|
||||||
cpu_state.regs[cpu_rm].l |= 0x10; /*ET hardwired on 486*/
|
cpu_state.regs[cpu_rm].l |= 0x10; /*ET hardwired on 486*/
|
||||||
break;
|
break;
|
||||||
case 2:cpu_state.regs[cpu_rm].l = cr2;
|
case 2:
|
||||||
|
cpu_state.regs[cpu_rm].l = cr2;
|
||||||
break;
|
break;
|
||||||
case 3:cpu_state.regs[cpu_rm].l = cr3;
|
case 3:
|
||||||
|
cpu_state.regs[cpu_rm].l = cr3;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (cpu_has_feature(CPU_FEATURE_CR4)) {
|
if (cpu_has_feature(CPU_FEATURE_CR4)) {
|
||||||
cpu_state.regs[cpu_rm].l = cr4;
|
cpu_state.regs[cpu_rm].l = cr4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:pclog("Bad read of CR%i %i\n", rmdat & 7, cpu_reg);
|
default:
|
||||||
|
pclog("Bad read of CR%i %i\n", rmdat & 7, cpu_reg);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -38,20 +42,24 @@ static int opMOV_r_CRx_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
fetch_ea_32(fetchdat);
|
fetch_ea_32(fetchdat);
|
||||||
switch (cpu_reg) {
|
switch (cpu_reg) {
|
||||||
case 0:cpu_state.regs[cpu_rm].l = cr0;
|
case 0:
|
||||||
|
cpu_state.regs[cpu_rm].l = cr0;
|
||||||
if (is486)
|
if (is486)
|
||||||
cpu_state.regs[cpu_rm].l |= 0x10; /*ET hardwired on 486*/
|
cpu_state.regs[cpu_rm].l |= 0x10; /*ET hardwired on 486*/
|
||||||
break;
|
break;
|
||||||
case 2:cpu_state.regs[cpu_rm].l = cr2;
|
case 2:
|
||||||
|
cpu_state.regs[cpu_rm].l = cr2;
|
||||||
break;
|
break;
|
||||||
case 3:cpu_state.regs[cpu_rm].l = cr3;
|
case 3:
|
||||||
|
cpu_state.regs[cpu_rm].l = cr3;
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
if (cpu_has_feature(CPU_FEATURE_CR4)) {
|
if (cpu_has_feature(CPU_FEATURE_CR4)) {
|
||||||
cpu_state.regs[cpu_rm].l = cr4;
|
cpu_state.regs[cpu_rm].l = cr4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:pclog("Bad read of CR%i %i\n", rmdat & 7, cpu_reg);
|
default:
|
||||||
|
pclog("Bad read of CR%i %i\n", rmdat & 7, cpu_reg);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -115,9 +123,11 @@ static int opMOV_CRx_r_a16(uint32_t fetchdat) {
|
|||||||
else
|
else
|
||||||
cpu_cur_status &= ~CPU_STATUS_PMODE;
|
cpu_cur_status &= ~CPU_STATUS_PMODE;
|
||||||
break;
|
break;
|
||||||
case 2:cr2 = cpu_state.regs[cpu_rm].l;
|
case 2:
|
||||||
|
cr2 = cpu_state.regs[cpu_rm].l;
|
||||||
break;
|
break;
|
||||||
case 3:cr3 = cpu_state.regs[cpu_rm].l;
|
case 3:
|
||||||
|
cr3 = cpu_state.regs[cpu_rm].l;
|
||||||
flushmmucache();
|
flushmmucache();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
@@ -126,7 +136,8 @@ static int opMOV_CRx_r_a16(uint32_t fetchdat) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:pclog("Bad load CR%i\n", cpu_reg);
|
default:
|
||||||
|
pclog("Bad load CR%i\n", cpu_reg);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -164,9 +175,11 @@ static int opMOV_CRx_r_a32(uint32_t fetchdat) {
|
|||||||
else
|
else
|
||||||
cpu_cur_status &= ~CPU_STATUS_PMODE;
|
cpu_cur_status &= ~CPU_STATUS_PMODE;
|
||||||
break;
|
break;
|
||||||
case 2:cr2 = cpu_state.regs[cpu_rm].l;
|
case 2:
|
||||||
|
cr2 = cpu_state.regs[cpu_rm].l;
|
||||||
break;
|
break;
|
||||||
case 3:cr3 = cpu_state.regs[cpu_rm].l;
|
case 3:
|
||||||
|
cr3 = cpu_state.regs[cpu_rm].l;
|
||||||
flushmmucache();
|
flushmmucache();
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
@@ -175,7 +188,8 @@ static int opMOV_CRx_r_a32(uint32_t fetchdat) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:pclog("Bad load CR%i\n", cpu_reg);
|
default:
|
||||||
|
pclog("Bad load CR%i\n", cpu_reg);
|
||||||
cpu_state.pc = cpu_state.oldpc;
|
cpu_state.pc = cpu_state.oldpc;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
|
@@ -70,32 +70,38 @@ static int opMOV_l_seg_a16(uint32_t fetchdat) {
|
|||||||
case 0x00: /*ES*/
|
case 0x00: /*ES*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = ES;
|
cpu_state.regs[cpu_rm].l = ES;
|
||||||
else seteaw(ES);
|
else
|
||||||
|
seteaw(ES);
|
||||||
break;
|
break;
|
||||||
case 0x08: /*CS*/
|
case 0x08: /*CS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = CS;
|
cpu_state.regs[cpu_rm].l = CS;
|
||||||
else seteaw(CS);
|
else
|
||||||
|
seteaw(CS);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*DS*/
|
case 0x18: /*DS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = DS;
|
cpu_state.regs[cpu_rm].l = DS;
|
||||||
else seteaw(DS);
|
else
|
||||||
|
seteaw(DS);
|
||||||
break;
|
break;
|
||||||
case 0x10: /*SS*/
|
case 0x10: /*SS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = SS;
|
cpu_state.regs[cpu_rm].l = SS;
|
||||||
else seteaw(SS);
|
else
|
||||||
|
seteaw(SS);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*FS*/
|
case 0x20: /*FS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = FS;
|
cpu_state.regs[cpu_rm].l = FS;
|
||||||
else seteaw(FS);
|
else
|
||||||
|
seteaw(FS);
|
||||||
break;
|
break;
|
||||||
case 0x28: /*GS*/
|
case 0x28: /*GS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = GS;
|
cpu_state.regs[cpu_rm].l = GS;
|
||||||
else seteaw(GS);
|
else
|
||||||
|
seteaw(GS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,32 +118,38 @@ static int opMOV_l_seg_a32(uint32_t fetchdat) {
|
|||||||
case 0x00: /*ES*/
|
case 0x00: /*ES*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = ES;
|
cpu_state.regs[cpu_rm].l = ES;
|
||||||
else seteaw(ES);
|
else
|
||||||
|
seteaw(ES);
|
||||||
break;
|
break;
|
||||||
case 0x08: /*CS*/
|
case 0x08: /*CS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = CS;
|
cpu_state.regs[cpu_rm].l = CS;
|
||||||
else seteaw(CS);
|
else
|
||||||
|
seteaw(CS);
|
||||||
break;
|
break;
|
||||||
case 0x18: /*DS*/
|
case 0x18: /*DS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = DS;
|
cpu_state.regs[cpu_rm].l = DS;
|
||||||
else seteaw(DS);
|
else
|
||||||
|
seteaw(DS);
|
||||||
break;
|
break;
|
||||||
case 0x10: /*SS*/
|
case 0x10: /*SS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = SS;
|
cpu_state.regs[cpu_rm].l = SS;
|
||||||
else seteaw(SS);
|
else
|
||||||
|
seteaw(SS);
|
||||||
break;
|
break;
|
||||||
case 0x20: /*FS*/
|
case 0x20: /*FS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = FS;
|
cpu_state.regs[cpu_rm].l = FS;
|
||||||
else seteaw(FS);
|
else
|
||||||
|
seteaw(FS);
|
||||||
break;
|
break;
|
||||||
case 0x28: /*GS*/
|
case 0x28: /*GS*/
|
||||||
if (cpu_mod == 3)
|
if (cpu_mod == 3)
|
||||||
cpu_state.regs[cpu_rm].l = GS;
|
cpu_state.regs[cpu_rm].l = GS;
|
||||||
else seteaw(GS);
|
else
|
||||||
|
seteaw(GS);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,42 +404,47 @@ static int opLSS_l_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define opLsel(name, sel) \
|
#define opLsel(name, sel) \
|
||||||
static int opL ## name ## _w_a16(uint32_t fetchdat) \
|
static int opL##name##_w_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint16_t addr, seg; \
|
uint16_t addr, seg; \
|
||||||
\
|
\
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
ILLEGAL_ON(cpu_mod == 3); \
|
ILLEGAL_ON(cpu_mod == 3); \
|
||||||
addr = readmemw(easeg, cpu_state.eaaddr); \
|
addr = readmemw(easeg, cpu_state.eaaddr); \
|
||||||
seg = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; \
|
seg = readmemw(easeg, cpu_state.eaaddr + 2); \
|
||||||
loadseg(seg, &sel); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
loadseg(seg, &sel); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].w = addr; \
|
cpu_state.regs[cpu_reg].w = addr; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(7); \
|
CLOCK_CYCLES(7); \
|
||||||
PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 0); \
|
PREFETCH_RUN(7, 2, rmdat, 2, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opL ## name ## _w_a32(uint32_t fetchdat) \
|
static int opL##name##_w_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint16_t addr, seg; \
|
uint16_t addr, seg; \
|
||||||
\
|
\
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
ILLEGAL_ON(cpu_mod == 3); \
|
ILLEGAL_ON(cpu_mod == 3); \
|
||||||
addr = readmemw(easeg, cpu_state.eaaddr); \
|
addr = readmemw(easeg, cpu_state.eaaddr); \
|
||||||
seg = readmemw(easeg, cpu_state.eaaddr + 2); if (cpu_state.abrt) return 1; \
|
seg = readmemw(easeg, cpu_state.eaaddr + 2); \
|
||||||
loadseg(seg, &sel); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
loadseg(seg, &sel); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].w = addr; \
|
cpu_state.regs[cpu_reg].w = addr; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(7); \
|
CLOCK_CYCLES(7); \
|
||||||
PREFETCH_RUN(7, 2, rmdat, 2,0,0,0, 1); \
|
PREFETCH_RUN(7, 2, rmdat, 2, 0, 0, 0, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opL ## name ## _l_a16(uint32_t fetchdat) \
|
static int opL##name##_l_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint32_t addr; \
|
uint32_t addr; \
|
||||||
uint16_t seg; \
|
uint16_t seg; \
|
||||||
\
|
\
|
||||||
@@ -435,17 +452,20 @@ static int opLSS_l_a32(uint32_t fetchdat) {
|
|||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
ILLEGAL_ON(cpu_mod == 3); \
|
ILLEGAL_ON(cpu_mod == 3); \
|
||||||
addr = readmeml(easeg, cpu_state.eaaddr); \
|
addr = readmeml(easeg, cpu_state.eaaddr); \
|
||||||
seg = readmemw(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; \
|
seg = readmemw(easeg, cpu_state.eaaddr + 4); \
|
||||||
loadseg(seg, &sel); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
loadseg(seg, &sel); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].l = addr; \
|
cpu_state.regs[cpu_reg].l = addr; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(7); \
|
CLOCK_CYCLES(7); \
|
||||||
PREFETCH_RUN(7, 2, rmdat, 1,1,0,0, 0); \
|
PREFETCH_RUN(7, 2, rmdat, 1, 1, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opL ## name ## _l_a32(uint32_t fetchdat) \
|
static int opL##name##_l_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint32_t addr; \
|
uint32_t addr; \
|
||||||
uint16_t seg; \
|
uint16_t seg; \
|
||||||
\
|
\
|
||||||
@@ -453,17 +473,19 @@ static int opLSS_l_a32(uint32_t fetchdat) {
|
|||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
ILLEGAL_ON(cpu_mod == 3); \
|
ILLEGAL_ON(cpu_mod == 3); \
|
||||||
addr = readmeml(easeg, cpu_state.eaaddr); \
|
addr = readmeml(easeg, cpu_state.eaaddr); \
|
||||||
seg = readmemw(easeg, cpu_state.eaaddr + 4); if (cpu_state.abrt) return 1; \
|
seg = readmemw(easeg, cpu_state.eaaddr + 4); \
|
||||||
loadseg(seg, &sel); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
loadseg(seg, &sel); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.regs[cpu_reg].l = addr; \
|
cpu_state.regs[cpu_reg].l = addr; \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(7); \
|
CLOCK_CYCLES(7); \
|
||||||
PREFETCH_RUN(7, 2, rmdat, 1,1,0,0, 1); \
|
PREFETCH_RUN(7, 2, rmdat, 1, 1, 0, 0, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opLsel(ES, cpu_state.seg_es)
|
opLsel(ES, cpu_state.seg_es) opLsel(FS, cpu_state.seg_fs) opLsel(GS, cpu_state.seg_gs)
|
||||||
opLsel(FS, cpu_state.seg_fs)
|
|
||||||
opLsel(GS, cpu_state.seg_gs)
|
|
||||||
|
|
||||||
#endif /* _X86_OPS_MOV_SEG_H_ */
|
#endif /* _X86_OPS_MOV_SEG_H_ */
|
||||||
|
@@ -54,8 +54,7 @@ static int opARPL_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define opLAR(name, fetch_ea, is32, ea32) \
|
#define opLAR(name, fetch_ea, is32, ea32) \
|
||||||
static int opLAR_ ## name(uint32_t fetchdat) \
|
static int opLAR_##name(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int valid; \
|
int valid; \
|
||||||
uint16_t sel, desc = 0; \
|
uint16_t sel, desc = 0; \
|
||||||
\
|
\
|
||||||
@@ -64,50 +63,58 @@ static int opARPL_a32(uint32_t fetchdat) {
|
|||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
\
|
\
|
||||||
sel = geteaw(); if (cpu_state.abrt) return 1; \
|
sel = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (!(sel & 0xfffc)) { cpu_state.flags &= ~Z_FLAG; return 0; } /*Null selector*/ \
|
if (!(sel & 0xfffc)) { \
|
||||||
|
cpu_state.flags &= ~Z_FLAG; \
|
||||||
|
return 0; \
|
||||||
|
} /*Null selector*/ \
|
||||||
valid = (sel & ~7) < ((sel & 4) ? ldt.limit : gdt.limit); \
|
valid = (sel & ~7) < ((sel & 4) ? ldt.limit : gdt.limit); \
|
||||||
if (valid) \
|
if (valid) { \
|
||||||
{ \
|
|
||||||
cpl_override = 1; \
|
cpl_override = 1; \
|
||||||
desc = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4); \
|
desc = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4); \
|
||||||
cpl_override = 0; if (cpu_state.abrt) return 1; \
|
cpl_override = 0; \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
} \
|
} \
|
||||||
cpu_state.flags &= ~Z_FLAG; \
|
cpu_state.flags &= ~Z_FLAG; \
|
||||||
if ((desc & 0x1f00) == 0x000) valid = 0; \
|
if ((desc & 0x1f00) == 0x000) \
|
||||||
if ((desc & 0x1f00) == 0x800) valid = 0; \
|
valid = 0; \
|
||||||
if ((desc & 0x1f00) == 0xa00) valid = 0; \
|
if ((desc & 0x1f00) == 0x800) \
|
||||||
if ((desc & 0x1f00) == 0xd00) valid = 0; \
|
valid = 0; \
|
||||||
|
if ((desc & 0x1f00) == 0xa00) \
|
||||||
|
valid = 0; \
|
||||||
|
if ((desc & 0x1f00) == 0xd00) \
|
||||||
|
valid = 0; \
|
||||||
if ((desc & 0x1c00) < 0x1c00) /*Exclude conforming code segments*/ \
|
if ((desc & 0x1c00) < 0x1c00) /*Exclude conforming code segments*/ \
|
||||||
{ \
|
{ \
|
||||||
int dpl = (desc >> 13) & 3; \
|
int dpl = (desc >> 13) & 3; \
|
||||||
if (dpl < CPL || dpl < (sel & 3)) valid = 0; \
|
if (dpl < CPL || dpl < (sel & 3)) \
|
||||||
|
valid = 0; \
|
||||||
} \
|
} \
|
||||||
if (valid) \
|
if (valid) { \
|
||||||
{ \
|
|
||||||
cpu_state.flags |= Z_FLAG; \
|
cpu_state.flags |= Z_FLAG; \
|
||||||
cpl_override = 1; \
|
cpl_override = 1; \
|
||||||
if (is32) \
|
if (is32) \
|
||||||
cpu_state.regs[cpu_reg].l = readmeml(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4) & 0xffff00; \
|
cpu_state.regs[cpu_reg].l = \
|
||||||
|
readmeml(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4) & 0xffff00; \
|
||||||
else \
|
else \
|
||||||
cpu_state.regs[cpu_reg].w = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4) & 0xff00; \
|
cpu_state.regs[cpu_reg].w = \
|
||||||
|
readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4) & 0xff00; \
|
||||||
cpl_override = 0; \
|
cpl_override = 0; \
|
||||||
} \
|
} \
|
||||||
CLOCK_CYCLES(11); \
|
CLOCK_CYCLES(11); \
|
||||||
PREFETCH_RUN(11, 2, rmdat, 2,0,0,0, ea32); \
|
PREFETCH_RUN(11, 2, rmdat, 2, 0, 0, 0, ea32); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opLAR(w_a16, fetch_ea_16, 0, 0)
|
opLAR(w_a16, fetch_ea_16, 0, 0) opLAR(w_a32, fetch_ea_32, 0, 1) opLAR(l_a16, fetch_ea_16, 1, 0) opLAR(l_a32, fetch_ea_32, 1, 1)
|
||||||
opLAR(w_a32, fetch_ea_32, 0, 1)
|
|
||||||
opLAR(l_a16, fetch_ea_16, 1, 0)
|
|
||||||
opLAR(l_a32, fetch_ea_32, 1, 1)
|
|
||||||
|
|
||||||
#define opLSL(name, fetch_ea, is32, ea32) \
|
#define opLSL(name, fetch_ea, is32, ea32) \
|
||||||
static int opLSL_ ## name(uint32_t fetchdat) \
|
static int opLSL_##name(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int valid; \
|
int valid; \
|
||||||
uint16_t sel, desc = 0; \
|
uint16_t sel, desc = 0; \
|
||||||
\
|
\
|
||||||
@@ -116,60 +123,63 @@ opLAR(l_a32, fetch_ea_32, 1, 1)
|
|||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
\
|
\
|
||||||
sel = geteaw(); if (cpu_state.abrt) return 1; \
|
sel = geteaw(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
cpu_state.flags &= ~Z_FLAG; \
|
cpu_state.flags &= ~Z_FLAG; \
|
||||||
if (!(sel & 0xfffc)) return 0; /*Null selector*/ \
|
if (!(sel & 0xfffc)) \
|
||||||
|
return 0; /*Null selector*/ \
|
||||||
valid = (sel & ~7) < ((sel & 4) ? ldt.limit : gdt.limit); \
|
valid = (sel & ~7) < ((sel & 4) ? ldt.limit : gdt.limit); \
|
||||||
if (valid) \
|
if (valid) { \
|
||||||
{ \
|
|
||||||
cpl_override = 1; \
|
cpl_override = 1; \
|
||||||
desc = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4); \
|
desc = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 4); \
|
||||||
cpl_override = 0; if (cpu_state.abrt) return 1; \
|
cpl_override = 0; \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
} \
|
} \
|
||||||
if ((desc & 0x1400) == 0x400) valid = 0; /*Interrupt or trap or call gate*/ \
|
if ((desc & 0x1400) == 0x400) \
|
||||||
if ((desc & 0x1f00) == 0x000) valid = 0; /*Invalid*/ \
|
valid = 0; /*Interrupt or trap or call gate*/ \
|
||||||
if ((desc & 0x1f00) == 0xa00) valid = 0; /*Invalid*/ \
|
if ((desc & 0x1f00) == 0x000) \
|
||||||
|
valid = 0; /*Invalid*/ \
|
||||||
|
if ((desc & 0x1f00) == 0xa00) \
|
||||||
|
valid = 0; /*Invalid*/ \
|
||||||
if ((desc & 0x1c00) != 0x1c00) /*Exclude conforming code segments*/ \
|
if ((desc & 0x1c00) != 0x1c00) /*Exclude conforming code segments*/ \
|
||||||
{ \
|
{ \
|
||||||
int rpl = (desc >> 13) & 3; \
|
int rpl = (desc >> 13) & 3; \
|
||||||
if (rpl < CPL || rpl < (sel & 3)) valid = 0; \
|
if (rpl < CPL || rpl < (sel & 3)) \
|
||||||
|
valid = 0; \
|
||||||
} \
|
} \
|
||||||
if (valid) \
|
if (valid) { \
|
||||||
{ \
|
|
||||||
cpu_state.flags |= Z_FLAG; \
|
cpu_state.flags |= Z_FLAG; \
|
||||||
cpl_override = 1; \
|
cpl_override = 1; \
|
||||||
if (is32) \
|
if (is32) { \
|
||||||
{ \
|
|
||||||
cpu_state.regs[cpu_reg].l = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7)); \
|
cpu_state.regs[cpu_reg].l = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7)); \
|
||||||
cpu_state.regs[cpu_reg].l |= (readmemb(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 6) & 0xF) << 16; \
|
cpu_state.regs[cpu_reg].l |= \
|
||||||
if (readmemb(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 6) & 0x80) \
|
(readmemb(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 6) & 0xF) << 16; \
|
||||||
{ \
|
if (readmemb(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7) + 6) & 0x80) { \
|
||||||
cpu_state.regs[cpu_reg].l <<= 12; \
|
cpu_state.regs[cpu_reg].l <<= 12; \
|
||||||
cpu_state.regs[cpu_reg].l |= 0xFFF; \
|
cpu_state.regs[cpu_reg].l |= 0xFFF; \
|
||||||
} \
|
} \
|
||||||
} \
|
} else \
|
||||||
else \
|
|
||||||
cpu_state.regs[cpu_reg].w = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7)); \
|
cpu_state.regs[cpu_reg].w = readmemw(0, ((sel & 4) ? ldt.base : gdt.base) + (sel & ~7)); \
|
||||||
cpl_override = 0; \
|
cpl_override = 0; \
|
||||||
} \
|
} \
|
||||||
CLOCK_CYCLES(10); \
|
CLOCK_CYCLES(10); \
|
||||||
PREFETCH_RUN(10, 2, rmdat, 4,0,0,0, ea32); \
|
PREFETCH_RUN(10, 2, rmdat, 4, 0, 0, 0, ea32); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opLSL(w_a16, fetch_ea_16, 0, 0)
|
opLSL(w_a16, fetch_ea_16, 0, 0) opLSL(w_a32, fetch_ea_32, 0, 1) opLSL(l_a16, fetch_ea_16, 1, 0)
|
||||||
opLSL(w_a32, fetch_ea_32, 0, 1)
|
opLSL(l_a32, fetch_ea_32, 1, 1)
|
||||||
opLSL(l_a16, fetch_ea_16, 1, 0)
|
|
||||||
opLSL(l_a32, fetch_ea_32, 1, 1)
|
|
||||||
|
|
||||||
static int op0F00_common(uint32_t fetchdat, int ea32) {
|
static int op0F00_common(uint32_t fetchdat, int ea32) {
|
||||||
int dpl, valid, granularity;
|
int dpl, valid, granularity;
|
||||||
uint32_t addr, base, limit;
|
uint32_t addr, base, limit;
|
||||||
uint16_t desc, sel;
|
uint16_t desc, sel;
|
||||||
uint8_t access, access2;
|
uint8_t access, access2;
|
||||||
|
|
||||||
// pclog("op0F00 %02X %04X:%04X\n", rmdat & 0x38, CS, pc);
|
// pclog("op0F00 %02X %04X:%04X\n", rmdat & 0x38, CS, pc);
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*SLDT*/
|
case 0x00: /*SLDT*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
@@ -315,7 +325,8 @@ static int op0F00_common(uint32_t fetchdat, int ea32) {
|
|||||||
PREFETCH_RUN(20, 2, rmdat, (cpu_mod == 3) ? 1 : 2, 0, 0, 0, ea32);
|
PREFETCH_RUN(20, 2, rmdat, (cpu_mod == 3) ? 1 : 2, 0, 0, 0, ea32);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:pclog("Bad 0F 00 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad 0F 00 opcode %02X\n", rmdat & 0x38);
|
||||||
cpu_state.pc -= 3;
|
cpu_state.pc -= 3;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
@@ -341,13 +352,13 @@ static int op0F00_a32(uint32_t fetchdat) {
|
|||||||
static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) {
|
static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) {
|
||||||
uint32_t base;
|
uint32_t base;
|
||||||
uint16_t limit, tempw;
|
uint16_t limit, tempw;
|
||||||
// pclog("op0F01 %02X %04X:%04X\n", rmdat & 0x38, CS, pc);
|
// pclog("op0F01 %02X %04X:%04X\n", rmdat & 0x38, CS, pc);
|
||||||
switch (rmdat & 0x38) {
|
switch (rmdat & 0x38) {
|
||||||
case 0x00: /*SGDT*/
|
case 0x00: /*SGDT*/
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
SEG_CHECK_WRITE(cpu_state.ea_seg);
|
||||||
seteaw(gdt.limit);
|
seteaw(gdt.limit);
|
||||||
base = gdt.base; //is32 ? gdt.base : (gdt.base & 0xffffff);
|
base = gdt.base; // is32 ? gdt.base : (gdt.base & 0xffffff);
|
||||||
if (is286)
|
if (is286)
|
||||||
base |= 0xff000000;
|
base |= 0xff000000;
|
||||||
writememl(easeg, cpu_state.eaaddr + 2, base);
|
writememl(easeg, cpu_state.eaaddr + 2, base);
|
||||||
@@ -373,12 +384,12 @@ static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) {
|
|||||||
}
|
}
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||||
// pclog("LGDT %08X:%08X\n", easeg, eaaddr);
|
// pclog("LGDT %08X:%08X\n", easeg, eaaddr);
|
||||||
limit = geteaw();
|
limit = geteaw();
|
||||||
base = readmeml(0, easeg + cpu_state.eaaddr + 2);
|
base = readmeml(0, easeg + cpu_state.eaaddr + 2);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
// pclog(" %08X %04X\n", base, limit);
|
// pclog(" %08X %04X\n", base, limit);
|
||||||
gdt.limit = limit;
|
gdt.limit = limit;
|
||||||
gdt.base = base;
|
gdt.base = base;
|
||||||
if (!is32)
|
if (!is32)
|
||||||
@@ -394,12 +405,12 @@ static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) {
|
|||||||
}
|
}
|
||||||
if (cpu_mod != 3)
|
if (cpu_mod != 3)
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg);
|
SEG_CHECK_READ(cpu_state.ea_seg);
|
||||||
// pclog("LIDT %08X:%08X\n", easeg, eaaddr);
|
// pclog("LIDT %08X:%08X\n", easeg, eaaddr);
|
||||||
limit = geteaw();
|
limit = geteaw();
|
||||||
base = readmeml(0, easeg + cpu_state.eaaddr + 2);
|
base = readmeml(0, easeg + cpu_state.eaaddr + 2);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
// pclog(" %08X %04X\n", base, limit);
|
// pclog(" %08X %04X\n", base, limit);
|
||||||
idt.limit = limit;
|
idt.limit = limit;
|
||||||
idt.base = base;
|
idt.base = base;
|
||||||
if (!is32)
|
if (!is32)
|
||||||
@@ -415,7 +426,8 @@ static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) {
|
|||||||
seteaw(msw);
|
seteaw(msw);
|
||||||
else if (is386)
|
else if (is386)
|
||||||
seteaw(msw | 0xFF00);
|
seteaw(msw | 0xFF00);
|
||||||
else seteaw(msw | 0xFFF0);
|
else
|
||||||
|
seteaw(msw | 0xFFF0);
|
||||||
CLOCK_CYCLES(2);
|
CLOCK_CYCLES(2);
|
||||||
PREFETCH_RUN(2, 2, rmdat, 0, 0, (cpu_mod == 3) ? 0 : 1, 0, ea32);
|
PREFETCH_RUN(2, 2, rmdat, 0, 0, (cpu_mod == 3) ? 0 : 1, 0, ea32);
|
||||||
break;
|
break;
|
||||||
@@ -459,7 +471,8 @@ static int op0F01_common(uint32_t fetchdat, int is32, int is286, int ea32) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:pclog("Bad 0F 01 opcode %02X\n", rmdat & 0x38);
|
default:
|
||||||
|
pclog("Bad 0F 01 opcode %02X\n", rmdat & 0x38);
|
||||||
cpu_state.pc -= 3;
|
cpu_state.pc -= 3;
|
||||||
x86illegal();
|
x86illegal();
|
||||||
break;
|
break;
|
||||||
|
@@ -1,10 +1,10 @@
|
|||||||
#ifndef _X86_OPS_PREFIX_H_
|
#ifndef _X86_OPS_PREFIX_H_
|
||||||
#define _X86_OPS_PREFIX_H_
|
#define _X86_OPS_PREFIX_H_
|
||||||
#define op_seg(name, seg, opcode_table, normal_opcode_table) \
|
#define op_seg(name, seg, opcode_table, normal_opcode_table) \
|
||||||
static int op ## name ## _w_a16(uint32_t fetchdat) \
|
static int op##name##_w_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetchdat = fastreadl(cs + cpu_state.pc); \
|
fetchdat = fastreadl(cs + cpu_state.pc); \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.pc++; \
|
cpu_state.pc++; \
|
||||||
\
|
\
|
||||||
cpu_state.ea_seg = &seg; \
|
cpu_state.ea_seg = &seg; \
|
||||||
@@ -15,12 +15,12 @@ static int op ## name ## _w_a16(uint32_t fetchdat) \
|
|||||||
if (opcode_table[fetchdat & 0xff]) \
|
if (opcode_table[fetchdat & 0xff]) \
|
||||||
return opcode_table[fetchdat & 0xff](fetchdat >> 8); \
|
return opcode_table[fetchdat & 0xff](fetchdat >> 8); \
|
||||||
return normal_opcode_table[fetchdat & 0xff](fetchdat >> 8); \
|
return normal_opcode_table[fetchdat & 0xff](fetchdat >> 8); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _l_a16(uint32_t fetchdat) \
|
static int op##name##_l_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetchdat = fastreadl(cs + cpu_state.pc); \
|
fetchdat = fastreadl(cs + cpu_state.pc); \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.pc++; \
|
cpu_state.pc++; \
|
||||||
\
|
\
|
||||||
cpu_state.ea_seg = &seg; \
|
cpu_state.ea_seg = &seg; \
|
||||||
@@ -31,12 +31,12 @@ static int op ## name ## _l_a16(uint32_t fetchdat) \
|
|||||||
if (opcode_table[(fetchdat & 0xff) | 0x100]) \
|
if (opcode_table[(fetchdat & 0xff) | 0x100]) \
|
||||||
return opcode_table[(fetchdat & 0xff) | 0x100](fetchdat >> 8); \
|
return opcode_table[(fetchdat & 0xff) | 0x100](fetchdat >> 8); \
|
||||||
return normal_opcode_table[(fetchdat & 0xff) | 0x100](fetchdat >> 8); \
|
return normal_opcode_table[(fetchdat & 0xff) | 0x100](fetchdat >> 8); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _w_a32(uint32_t fetchdat) \
|
static int op##name##_w_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetchdat = fastreadl(cs + cpu_state.pc); \
|
fetchdat = fastreadl(cs + cpu_state.pc); \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.pc++; \
|
cpu_state.pc++; \
|
||||||
\
|
\
|
||||||
cpu_state.ea_seg = &seg; \
|
cpu_state.ea_seg = &seg; \
|
||||||
@@ -47,12 +47,12 @@ static int op ## name ## _w_a32(uint32_t fetchdat) \
|
|||||||
if (opcode_table[(fetchdat & 0xff) | 0x200]) \
|
if (opcode_table[(fetchdat & 0xff) | 0x200]) \
|
||||||
return opcode_table[(fetchdat & 0xff) | 0x200](fetchdat >> 8); \
|
return opcode_table[(fetchdat & 0xff) | 0x200](fetchdat >> 8); \
|
||||||
return normal_opcode_table[(fetchdat & 0xff) | 0x200](fetchdat >> 8); \
|
return normal_opcode_table[(fetchdat & 0xff) | 0x200](fetchdat >> 8); \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int op ## name ## _l_a32(uint32_t fetchdat) \
|
static int op##name##_l_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetchdat = fastreadl(cs + cpu_state.pc); \
|
fetchdat = fastreadl(cs + cpu_state.pc); \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.pc++; \
|
cpu_state.pc++; \
|
||||||
\
|
\
|
||||||
cpu_state.ea_seg = &seg; \
|
cpu_state.ea_seg = &seg; \
|
||||||
@@ -63,30 +63,27 @@ static int op ## name ## _l_a32(uint32_t fetchdat) \
|
|||||||
if (opcode_table[(fetchdat & 0xff) | 0x300]) \
|
if (opcode_table[(fetchdat & 0xff) | 0x300]) \
|
||||||
return opcode_table[(fetchdat & 0xff) | 0x300](fetchdat >> 8); \
|
return opcode_table[(fetchdat & 0xff) | 0x300](fetchdat >> 8); \
|
||||||
return normal_opcode_table[(fetchdat & 0xff) | 0x300](fetchdat >> 8); \
|
return normal_opcode_table[(fetchdat & 0xff) | 0x300](fetchdat >> 8); \
|
||||||
}
|
}
|
||||||
|
|
||||||
op_seg(CS, cpu_state.seg_cs, x86_opcodes, x86_opcodes)
|
op_seg(CS, cpu_state.seg_cs, x86_opcodes, x86_opcodes) op_seg(DS, cpu_state.seg_ds, x86_opcodes, x86_opcodes)
|
||||||
op_seg(DS, cpu_state.seg_ds, x86_opcodes, x86_opcodes)
|
op_seg(ES, cpu_state.seg_es, x86_opcodes, x86_opcodes) op_seg(FS, cpu_state.seg_fs, x86_opcodes, x86_opcodes) op_seg(
|
||||||
op_seg(ES, cpu_state.seg_es, x86_opcodes, x86_opcodes)
|
GS, cpu_state.seg_gs, x86_opcodes, x86_opcodes) op_seg(SS, cpu_state.seg_ss, x86_opcodes, x86_opcodes)
|
||||||
op_seg(FS, cpu_state.seg_fs, x86_opcodes, x86_opcodes)
|
|
||||||
op_seg(GS, cpu_state.seg_gs, x86_opcodes, x86_opcodes)
|
|
||||||
op_seg(SS, cpu_state.seg_ss, x86_opcodes, x86_opcodes)
|
|
||||||
|
|
||||||
op_seg(CS_REPE, cpu_state.seg_cs, x86_opcodes_REPE, x86_opcodes)
|
op_seg(CS_REPE, cpu_state.seg_cs, x86_opcodes_REPE,
|
||||||
op_seg(DS_REPE, cpu_state.seg_ds, x86_opcodes_REPE, x86_opcodes)
|
x86_opcodes) op_seg(DS_REPE, cpu_state.seg_ds, x86_opcodes_REPE,
|
||||||
op_seg(ES_REPE, cpu_state.seg_es, x86_opcodes_REPE, x86_opcodes)
|
x86_opcodes) op_seg(ES_REPE, cpu_state.seg_es, x86_opcodes_REPE, x86_opcodes)
|
||||||
op_seg(FS_REPE, cpu_state.seg_fs, x86_opcodes_REPE, x86_opcodes)
|
op_seg(FS_REPE, cpu_state.seg_fs, x86_opcodes_REPE,
|
||||||
op_seg(GS_REPE, cpu_state.seg_gs, x86_opcodes_REPE, x86_opcodes)
|
x86_opcodes) op_seg(GS_REPE, cpu_state.seg_gs, x86_opcodes_REPE,
|
||||||
op_seg(SS_REPE, cpu_state.seg_ss, x86_opcodes_REPE, x86_opcodes)
|
x86_opcodes) op_seg(SS_REPE, cpu_state.seg_ss, x86_opcodes_REPE, x86_opcodes)
|
||||||
|
|
||||||
op_seg(CS_REPNE, cpu_state.seg_cs, x86_opcodes_REPNE, x86_opcodes)
|
op_seg(CS_REPNE, cpu_state.seg_cs, x86_opcodes_REPNE,
|
||||||
op_seg(DS_REPNE, cpu_state.seg_ds, x86_opcodes_REPNE, x86_opcodes)
|
x86_opcodes) op_seg(DS_REPNE, cpu_state.seg_ds, x86_opcodes_REPNE, x86_opcodes)
|
||||||
op_seg(ES_REPNE, cpu_state.seg_es, x86_opcodes_REPNE, x86_opcodes)
|
op_seg(ES_REPNE, cpu_state.seg_es, x86_opcodes_REPNE, x86_opcodes)
|
||||||
op_seg(FS_REPNE, cpu_state.seg_fs, x86_opcodes_REPNE, x86_opcodes)
|
op_seg(FS_REPNE, cpu_state.seg_fs, x86_opcodes_REPNE, x86_opcodes)
|
||||||
op_seg(GS_REPNE, cpu_state.seg_gs, x86_opcodes_REPNE, x86_opcodes)
|
op_seg(GS_REPNE, cpu_state.seg_gs, x86_opcodes_REPNE, x86_opcodes)
|
||||||
op_seg(SS_REPNE, cpu_state.seg_ss, x86_opcodes_REPNE, x86_opcodes)
|
op_seg(SS_REPNE, cpu_state.seg_ss, x86_opcodes_REPNE, x86_opcodes)
|
||||||
|
|
||||||
static int op_66(uint32_t fetchdat) /*Data size select*/
|
static int op_66(uint32_t fetchdat) /*Data size select*/
|
||||||
{
|
{
|
||||||
fetchdat = fastreadl(cs + cpu_state.pc);
|
fetchdat = fastreadl(cs + cpu_state.pc);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
|
@@ -1,665 +1,735 @@
|
|||||||
#ifndef _X86_OPS_REP_H_
|
#ifndef _X86_OPS_REP_H_
|
||||||
#define _X86_OPS_REP_H_
|
#define _X86_OPS_REP_H_
|
||||||
#define REP_OPS(size, CNT_REG, SRC_REG, DEST_REG) \
|
#define REP_OPS(size, CNT_REG, SRC_REG, DEST_REG) \
|
||||||
static int opREP_INSB_ ## size(uint32_t fetchdat) \
|
static int opREP_INSB_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
\
|
\
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint8_t temp; \
|
uint8_t temp; \
|
||||||
\
|
\
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
check_io_perm(DX); \
|
check_io_perm(DX); \
|
||||||
temp = inb(DX); \
|
temp = inb(DX); \
|
||||||
writememb(es, DEST_REG, temp); if (cpu_state.abrt) return 1; \
|
writememb(es, DEST_REG, temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG--; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else DEST_REG++; \
|
DEST_REG--; \
|
||||||
|
else \
|
||||||
|
DEST_REG++; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= 15; \
|
cycles -= 15; \
|
||||||
reads++; writes++; total_cycles += 15; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += 15; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_INSW_ ## size(uint32_t fetchdat) \
|
static int opREP_INSW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
\
|
\
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
\
|
\
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
check_io_perm(DX); \
|
check_io_perm(DX); \
|
||||||
check_io_perm(DX+1); \
|
check_io_perm(DX + 1); \
|
||||||
temp = inw(DX); \
|
temp = inw(DX); \
|
||||||
writememw(es, DEST_REG, temp); if (cpu_state.abrt) return 1; \
|
writememw(es, DEST_REG, temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG -= 2; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else DEST_REG += 2; \
|
DEST_REG -= 2; \
|
||||||
|
else \
|
||||||
|
DEST_REG += 2; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= 15; \
|
cycles -= 15; \
|
||||||
reads++; writes++; total_cycles += 15; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += 15; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_INSL_ ## size(uint32_t fetchdat) \
|
static int opREP_INSL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
\
|
\
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
\
|
\
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
check_io_perm(DX); \
|
check_io_perm(DX); \
|
||||||
check_io_perm(DX+1); \
|
check_io_perm(DX + 1); \
|
||||||
check_io_perm(DX+2); \
|
check_io_perm(DX + 2); \
|
||||||
check_io_perm(DX+3); \
|
check_io_perm(DX + 3); \
|
||||||
temp = inl(DX); \
|
temp = inl(DX); \
|
||||||
writememl(es, DEST_REG, temp); if (cpu_state.abrt) return 1; \
|
writememl(es, DEST_REG, temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG -= 4; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else DEST_REG += 4; \
|
DEST_REG -= 4; \
|
||||||
|
else \
|
||||||
|
DEST_REG += 4; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= 15; \
|
cycles -= 15; \
|
||||||
reads++; writes++; total_cycles += 15; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += 15; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, writes, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, writes, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opREP_OUTSB_ ## size(uint32_t fetchdat) \
|
static int opREP_OUTSB_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
\
|
\
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint8_t temp; \
|
uint8_t temp; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
check_io_perm(DX); \
|
check_io_perm(DX); \
|
||||||
outb(DX, temp); \
|
outb(DX, temp); \
|
||||||
if (cpu_state.flags & D_FLAG) SRC_REG--; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else SRC_REG++; \
|
SRC_REG--; \
|
||||||
|
else \
|
||||||
|
SRC_REG++; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= 14; \
|
cycles -= 14; \
|
||||||
reads++; writes++; total_cycles += 14; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += 14; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_OUTSW_ ## size(uint32_t fetchdat) \
|
static int opREP_OUTSW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
\
|
\
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
check_io_perm(DX); \
|
check_io_perm(DX); \
|
||||||
check_io_perm(DX+1); \
|
check_io_perm(DX + 1); \
|
||||||
outw(DX, temp); \
|
outw(DX, temp); \
|
||||||
if (cpu_state.flags & D_FLAG) SRC_REG -= 2; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else SRC_REG += 2; \
|
SRC_REG -= 2; \
|
||||||
|
else \
|
||||||
|
SRC_REG += 2; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= 14; \
|
cycles -= 14; \
|
||||||
reads++; writes++; total_cycles += 14; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += 14; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_OUTSL_ ## size(uint32_t fetchdat) \
|
static int opREP_OUTSL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
\
|
\
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
check_io_perm(DX); \
|
check_io_perm(DX); \
|
||||||
check_io_perm(DX+1); \
|
check_io_perm(DX + 1); \
|
||||||
check_io_perm(DX+2); \
|
check_io_perm(DX + 2); \
|
||||||
check_io_perm(DX+3); \
|
check_io_perm(DX + 3); \
|
||||||
outl(DX, temp); \
|
outl(DX, temp); \
|
||||||
if (cpu_state.flags & D_FLAG) SRC_REG -= 4; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else SRC_REG += 4; \
|
SRC_REG -= 4; \
|
||||||
|
else \
|
||||||
|
SRC_REG += 4; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= 14; \
|
cycles -= 14; \
|
||||||
reads++; writes++; total_cycles += 14; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += 14; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, writes, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, writes, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opREP_MOVSB_ ## size(uint32_t fetchdat) \
|
static int opREP_MOVSB_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
} \
|
} \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint8_t temp; \
|
uint8_t temp; \
|
||||||
\
|
\
|
||||||
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
||||||
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
writememb(es, DEST_REG, temp); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
writememb(es, DEST_REG, temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) { DEST_REG--; SRC_REG--; } \
|
if (cpu_state.flags & D_FLAG) { \
|
||||||
else { DEST_REG++; SRC_REG++; } \
|
DEST_REG--; \
|
||||||
|
SRC_REG--; \
|
||||||
|
} else { \
|
||||||
|
DEST_REG++; \
|
||||||
|
SRC_REG++; \
|
||||||
|
} \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 3 : 4; \
|
cycles -= is486 ? 3 : 4; \
|
||||||
ins++; \
|
ins++; \
|
||||||
reads++; writes++; total_cycles += is486 ? 3 : 4; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += is486 ? 3 : 4; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
ins--; \
|
ins--; \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_MOVSW_ ## size(uint32_t fetchdat) \
|
static int opREP_MOVSW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
} \
|
} \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint16_t temp; \
|
uint16_t temp; \
|
||||||
\
|
\
|
||||||
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
||||||
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
writememw(es, DEST_REG, temp); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
writememw(es, DEST_REG, temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) { DEST_REG -= 2; SRC_REG -= 2; } \
|
if (cpu_state.flags & D_FLAG) { \
|
||||||
else { DEST_REG += 2; SRC_REG += 2; } \
|
DEST_REG -= 2; \
|
||||||
|
SRC_REG -= 2; \
|
||||||
|
} else { \
|
||||||
|
DEST_REG += 2; \
|
||||||
|
SRC_REG += 2; \
|
||||||
|
} \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 3 : 4; \
|
cycles -= is486 ? 3 : 4; \
|
||||||
ins++; \
|
ins++; \
|
||||||
reads++; writes++; total_cycles += is486 ? 3 : 4; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += is486 ? 3 : 4; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
ins--; \
|
ins--; \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_MOVSL_ ## size(uint32_t fetchdat) \
|
static int opREP_MOVSL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, writes = 0, total_cycles = 0; \
|
int reads = 0, writes = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
} \
|
} \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
uint32_t temp; \
|
uint32_t temp; \
|
||||||
\
|
\
|
||||||
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
||||||
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
writememl(es, DEST_REG, temp); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
writememl(es, DEST_REG, temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) { DEST_REG -= 4; SRC_REG -= 4; } \
|
if (cpu_state.flags & D_FLAG) { \
|
||||||
else { DEST_REG += 4; SRC_REG += 4; } \
|
DEST_REG -= 4; \
|
||||||
|
SRC_REG -= 4; \
|
||||||
|
} else { \
|
||||||
|
DEST_REG += 4; \
|
||||||
|
SRC_REG += 4; \
|
||||||
|
} \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 3 : 4; \
|
cycles -= is486 ? 3 : 4; \
|
||||||
ins++; \
|
ins++; \
|
||||||
reads++; writes++; total_cycles += is486 ? 3 : 4; \
|
reads++; \
|
||||||
|
writes++; \
|
||||||
|
total_cycles += is486 ? 3 : 4; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
ins--; \
|
ins--; \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
\
|
static int opREP_STOSB_##size(uint32_t fetchdat) { \
|
||||||
static int opREP_STOSB_ ## size(uint32_t fetchdat) \
|
|
||||||
{ \
|
|
||||||
int writes = 0, total_cycles = 0; \
|
int writes = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) \
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG); \
|
||||||
writememb(es, DEST_REG, AL); if (cpu_state.abrt) return 1; \
|
writememb(es, DEST_REG, AL); \
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG--; \
|
if (cpu_state.abrt) \
|
||||||
else DEST_REG++; \
|
return 1; \
|
||||||
|
if (cpu_state.flags & D_FLAG) \
|
||||||
|
DEST_REG--; \
|
||||||
|
else \
|
||||||
|
DEST_REG++; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 4 : 5; \
|
cycles -= is486 ? 4 : 5; \
|
||||||
writes++; total_cycles += is486 ? 4 : 5; \
|
writes++; \
|
||||||
|
total_cycles += is486 ? 4 : 5; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_STOSW_ ## size(uint32_t fetchdat) \
|
static int opREP_STOSW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int writes = 0, total_cycles = 0; \
|
int writes = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) \
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG + 1); \
|
||||||
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG+1); \
|
writememw(es, DEST_REG, AX); \
|
||||||
writememw(es, DEST_REG, AX); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG -= 2; \
|
return 1; \
|
||||||
else DEST_REG += 2; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
|
DEST_REG -= 2; \
|
||||||
|
else \
|
||||||
|
DEST_REG += 2; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 4 : 5; \
|
cycles -= is486 ? 4 : 5; \
|
||||||
writes++; total_cycles += is486 ? 4 : 5; \
|
writes++; \
|
||||||
|
total_cycles += is486 ? 4 : 5; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, 0, writes, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, 0, writes, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_STOSL_ ## size(uint32_t fetchdat) \
|
static int opREP_STOSL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int writes = 0, total_cycles = 0; \
|
int writes = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) \
|
||||||
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
SEG_CHECK_WRITE(&cpu_state.seg_es); \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG + 3); \
|
||||||
CHECK_WRITE_REP(&cpu_state.seg_es, DEST_REG, DEST_REG+3); \
|
writememl(es, DEST_REG, EAX); \
|
||||||
writememl(es, DEST_REG, EAX); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG -= 4; \
|
return 1; \
|
||||||
else DEST_REG += 4; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
|
DEST_REG -= 4; \
|
||||||
|
else \
|
||||||
|
DEST_REG += 4; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 4 : 5; \
|
cycles -= is486 ? 4 : 5; \
|
||||||
writes++; total_cycles += is486 ? 4 : 5; \
|
writes++; \
|
||||||
|
total_cycles += is486 ? 4 : 5; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, 0, 0, writes, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, 0, 0, writes, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opREP_LODSB_ ## size(uint32_t fetchdat) \
|
static int opREP_LODSB_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0; \
|
int reads = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
AL = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
AL = readmemb(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (cpu_state.flags & D_FLAG) SRC_REG--; \
|
return 1; \
|
||||||
else SRC_REG++; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
|
SRC_REG--; \
|
||||||
|
else \
|
||||||
|
SRC_REG++; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 4 : 5; \
|
cycles -= is486 ? 4 : 5; \
|
||||||
reads++; total_cycles += is486 ? 4 : 5; \
|
reads++; \
|
||||||
|
total_cycles += is486 ? 4 : 5; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_LODSW_ ## size(uint32_t fetchdat) \
|
static int opREP_LODSW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0; \
|
int reads = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
AX = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
AX = readmemw(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (cpu_state.flags & D_FLAG) SRC_REG -= 2; \
|
return 1; \
|
||||||
else SRC_REG += 2; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
|
SRC_REG -= 2; \
|
||||||
|
else \
|
||||||
|
SRC_REG += 2; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 4 : 5; \
|
cycles -= is486 ? 4 : 5; \
|
||||||
reads++; total_cycles += is486 ? 4 : 5; \
|
reads++; \
|
||||||
|
total_cycles += is486 ? 4 : 5; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_LODSL_ ## size(uint32_t fetchdat) \
|
static int opREP_LODSL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0; \
|
int reads = 0, total_cycles = 0; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
while (CNT_REG > 0) \
|
while (CNT_REG > 0) { \
|
||||||
{ \
|
EAX = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
EAX = readmeml(cpu_state.ea_seg->base, SRC_REG); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (cpu_state.flags & D_FLAG) SRC_REG -= 4; \
|
return 1; \
|
||||||
else SRC_REG += 4; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
|
SRC_REG -= 4; \
|
||||||
|
else \
|
||||||
|
SRC_REG += 4; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 4 : 5; \
|
cycles -= is486 ? 4 : 5; \
|
||||||
reads++; total_cycles += is486 ? 4 : 5; \
|
reads++; \
|
||||||
|
total_cycles += is486 ? 4 : 5; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, 0, 0); \
|
||||||
if (CNT_REG > 0) \
|
if (CNT_REG > 0) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
}
|
||||||
|
|
||||||
|
|
||||||
#define REP_OPS_CMPS_SCAS(size, CNT_REG, SRC_REG, DEST_REG, FV) \
|
#define REP_OPS_CMPS_SCAS(size, CNT_REG, SRC_REG, DEST_REG, FV) \
|
||||||
static int opREP_CMPSB_ ## size(uint32_t fetchdat) \
|
static int opREP_CMPSB_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0, tempz; \
|
int reads = 0, total_cycles = 0, tempz; \
|
||||||
\
|
\
|
||||||
tempz = FV; \
|
tempz = FV; \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
uint8_t temp, temp2; \
|
uint8_t temp, temp2; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
SEG_CHECK_READ(&cpu_state.seg_es); \
|
SEG_CHECK_READ(&cpu_state.seg_es); \
|
||||||
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
temp = readmemb(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
temp2 = readmemb(es, DEST_REG); if (cpu_state.abrt) return 1; \
|
temp2 = readmemb(es, DEST_REG); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) { DEST_REG--; SRC_REG--; } \
|
if (cpu_state.flags & D_FLAG) { \
|
||||||
else { DEST_REG++; SRC_REG++; } \
|
DEST_REG--; \
|
||||||
|
SRC_REG--; \
|
||||||
|
} else { \
|
||||||
|
DEST_REG++; \
|
||||||
|
SRC_REG++; \
|
||||||
|
} \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 7 : 9; \
|
cycles -= is486 ? 7 : 9; \
|
||||||
reads += 2; total_cycles += is486 ? 7 : 9; \
|
reads += 2; \
|
||||||
|
total_cycles += is486 ? 7 : 9; \
|
||||||
setsub8(temp, temp2); \
|
setsub8(temp, temp2); \
|
||||||
tempz = (ZF_SET()) ? 1 : 0; \
|
tempz = (ZF_SET()) ? 1 : 0; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_CMPSW_ ## size(uint32_t fetchdat) \
|
static int opREP_CMPSW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0, tempz; \
|
int reads = 0, total_cycles = 0, tempz; \
|
||||||
\
|
\
|
||||||
tempz = FV; \
|
tempz = FV; \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
uint16_t temp, temp2; \
|
uint16_t temp, temp2; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
SEG_CHECK_READ(&cpu_state.seg_es); \
|
SEG_CHECK_READ(&cpu_state.seg_es); \
|
||||||
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
temp = readmemw(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
temp2 = readmemw(es, DEST_REG); if (cpu_state.abrt) return 1; \
|
temp2 = readmemw(es, DEST_REG); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) { DEST_REG -= 2; SRC_REG -= 2; } \
|
if (cpu_state.flags & D_FLAG) { \
|
||||||
else { DEST_REG += 2; SRC_REG += 2; } \
|
DEST_REG -= 2; \
|
||||||
|
SRC_REG -= 2; \
|
||||||
|
} else { \
|
||||||
|
DEST_REG += 2; \
|
||||||
|
SRC_REG += 2; \
|
||||||
|
} \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 7 : 9; \
|
cycles -= is486 ? 7 : 9; \
|
||||||
reads += 2; total_cycles += is486 ? 7 : 9; \
|
reads += 2; \
|
||||||
|
total_cycles += is486 ? 7 : 9; \
|
||||||
setsub16(temp, temp2); \
|
setsub16(temp, temp2); \
|
||||||
tempz = (ZF_SET()) ? 1 : 0; \
|
tempz = (ZF_SET()) ? 1 : 0; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_CMPSL_ ## size(uint32_t fetchdat) \
|
static int opREP_CMPSL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0, tempz; \
|
int reads = 0, total_cycles = 0, tempz; \
|
||||||
\
|
\
|
||||||
tempz = FV; \
|
tempz = FV; \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
uint32_t temp, temp2; \
|
uint32_t temp, temp2; \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
SEG_CHECK_READ(&cpu_state.seg_es); \
|
SEG_CHECK_READ(&cpu_state.seg_es); \
|
||||||
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
temp = readmeml(cpu_state.ea_seg->base, SRC_REG); \
|
||||||
temp2 = readmeml(es, DEST_REG); if (cpu_state.abrt) return 1; \
|
temp2 = readmeml(es, DEST_REG); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
\
|
\
|
||||||
if (cpu_state.flags & D_FLAG) { DEST_REG -= 4; SRC_REG -= 4; } \
|
if (cpu_state.flags & D_FLAG) { \
|
||||||
else { DEST_REG += 4; SRC_REG += 4; } \
|
DEST_REG -= 4; \
|
||||||
|
SRC_REG -= 4; \
|
||||||
|
} else { \
|
||||||
|
DEST_REG += 4; \
|
||||||
|
SRC_REG += 4; \
|
||||||
|
} \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 7 : 9; \
|
cycles -= is486 ? 7 : 9; \
|
||||||
reads += 2; total_cycles += is486 ? 7 : 9; \
|
reads += 2; \
|
||||||
|
total_cycles += is486 ? 7 : 9; \
|
||||||
setsub32(temp, temp2); \
|
setsub32(temp, temp2); \
|
||||||
tempz = (ZF_SET()) ? 1 : 0; \
|
tempz = (ZF_SET()) ? 1 : 0; \
|
||||||
} \
|
} \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, 0, 0); \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opREP_SCASB_ ## size(uint32_t fetchdat) \
|
static int opREP_SCASB_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0, tempz; \
|
int reads = 0, total_cycles = 0, tempz; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
tempz = FV; \
|
tempz = FV; \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) \
|
||||||
SEG_CHECK_READ(&cpu_state.seg_es); \
|
SEG_CHECK_READ(&cpu_state.seg_es); \
|
||||||
while ((CNT_REG > 0) && (FV == tempz)) \
|
while ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
uint8_t temp = readmemb(es, DEST_REG); \
|
||||||
uint8_t temp = readmemb(es, DEST_REG); if (cpu_state.abrt) break;\
|
if (cpu_state.abrt) \
|
||||||
|
break; \
|
||||||
setsub8(AL, temp); \
|
setsub8(AL, temp); \
|
||||||
tempz = (ZF_SET()) ? 1 : 0; \
|
tempz = (ZF_SET()) ? 1 : 0; \
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG--; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else DEST_REG++; \
|
DEST_REG--; \
|
||||||
|
else \
|
||||||
|
DEST_REG++; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 5 : 8; \
|
cycles -= is486 ? 5 : 8; \
|
||||||
reads++; total_cycles += is486 ? 5 : 8; \
|
reads++; \
|
||||||
|
total_cycles += is486 ? 5 : 8; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
ins--; \
|
ins--; \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_SCASW_ ## size(uint32_t fetchdat) \
|
static int opREP_SCASW_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0, tempz; \
|
int reads = 0, total_cycles = 0, tempz; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
tempz = FV; \
|
tempz = FV; \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) \
|
||||||
SEG_CHECK_READ(&cpu_state.seg_es); \
|
SEG_CHECK_READ(&cpu_state.seg_es); \
|
||||||
while ((CNT_REG > 0) && (FV == tempz)) \
|
while ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
uint16_t temp = readmemw(es, DEST_REG); \
|
||||||
uint16_t temp = readmemw(es, DEST_REG); if (cpu_state.abrt) break;\
|
if (cpu_state.abrt) \
|
||||||
|
break; \
|
||||||
setsub16(AX, temp); \
|
setsub16(AX, temp); \
|
||||||
tempz = (ZF_SET()) ? 1 : 0; \
|
tempz = (ZF_SET()) ? 1 : 0; \
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG -= 2; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else DEST_REG += 2; \
|
DEST_REG -= 2; \
|
||||||
|
else \
|
||||||
|
DEST_REG += 2; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 5 : 8; \
|
cycles -= is486 ? 5 : 8; \
|
||||||
reads++; total_cycles += is486 ? 5 : 8; \
|
reads++; \
|
||||||
|
total_cycles += is486 ? 5 : 8; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
ins--; \
|
ins--; \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, reads, 0, 0, 0, 0); \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opREP_SCASL_ ## size(uint32_t fetchdat) \
|
static int opREP_SCASL_##size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int reads = 0, total_cycles = 0, tempz; \
|
int reads = 0, total_cycles = 0, tempz; \
|
||||||
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
int cycles_end = cycles - ((is386 && cpu_use_dynarec) ? 1000 : 100); \
|
||||||
if (trap) \
|
if (trap) \
|
||||||
cycles_end = cycles+1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
cycles_end = cycles + 1; /*Force the instruction to end after only one iteration when trap flag set*/ \
|
||||||
tempz = FV; \
|
tempz = FV; \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) \
|
||||||
SEG_CHECK_READ(&cpu_state.seg_es); \
|
SEG_CHECK_READ(&cpu_state.seg_es); \
|
||||||
while ((CNT_REG > 0) && (FV == tempz)) \
|
while ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
uint32_t temp = readmeml(es, DEST_REG); \
|
||||||
uint32_t temp = readmeml(es, DEST_REG); if (cpu_state.abrt) break;\
|
if (cpu_state.abrt) \
|
||||||
|
break; \
|
||||||
setsub32(EAX, temp); \
|
setsub32(EAX, temp); \
|
||||||
tempz = (ZF_SET()) ? 1 : 0; \
|
tempz = (ZF_SET()) ? 1 : 0; \
|
||||||
if (cpu_state.flags & D_FLAG) DEST_REG -= 4; \
|
if (cpu_state.flags & D_FLAG) \
|
||||||
else DEST_REG += 4; \
|
DEST_REG -= 4; \
|
||||||
|
else \
|
||||||
|
DEST_REG += 4; \
|
||||||
CNT_REG--; \
|
CNT_REG--; \
|
||||||
cycles -= is486 ? 5 : 8; \
|
cycles -= is486 ? 5 : 8; \
|
||||||
reads++; total_cycles += is486 ? 5 : 8; \
|
reads++; \
|
||||||
|
total_cycles += is486 ? 5 : 8; \
|
||||||
ins++; \
|
ins++; \
|
||||||
if (cycles < cycles_end) \
|
if (cycles < cycles_end) \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
ins--; \
|
ins--; \
|
||||||
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, 0, 0); \
|
PREFETCH_RUN(total_cycles, 1, -1, 0, reads, 0, 0, 0); \
|
||||||
if ((CNT_REG > 0) && (FV == tempz)) \
|
if ((CNT_REG > 0) && (FV == tempz)) { \
|
||||||
{ \
|
|
||||||
CPU_BLOCK_END(); \
|
CPU_BLOCK_END(); \
|
||||||
cpu_state.pc = cpu_state.oldpc; \
|
cpu_state.pc = cpu_state.oldpc; \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
REP_OPS(a16, CX, SI, DI)
|
REP_OPS(a16, CX, SI, DI)
|
||||||
REP_OPS(a32, ECX, ESI, EDI)
|
REP_OPS(a32, ECX, ESI, EDI)
|
||||||
|
@@ -1,45 +1,43 @@
|
|||||||
#ifndef _X86_OPS_RET_H_
|
#ifndef _X86_OPS_RET_H_
|
||||||
#define _X86_OPS_RET_H_
|
#define _X86_OPS_RET_H_
|
||||||
#define RETF_a16(stack_offset) \
|
#define RETF_a16(stack_offset) \
|
||||||
if ((msw&1) && !(cpu_state.eflags&VM_FLAG)) \
|
if ((msw & 1) && !(cpu_state.eflags & VM_FLAG)) { \
|
||||||
{ \
|
|
||||||
pmoderetf(0, stack_offset); \
|
pmoderetf(0, stack_offset); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
if (stack32) \
|
if (stack32) { \
|
||||||
{ \
|
|
||||||
cpu_state.pc = readmemw(ss, ESP); \
|
cpu_state.pc = readmemw(ss, ESP); \
|
||||||
loadcs(readmemw(ss, ESP + 2)); \
|
loadcs(readmemw(ss, ESP + 2)); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
cpu_state.pc = readmemw(ss, SP); \
|
cpu_state.pc = readmemw(ss, SP); \
|
||||||
loadcs(readmemw(ss, SP + 2)); \
|
loadcs(readmemw(ss, SP + 2)); \
|
||||||
} \
|
} \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (stack32) ESP += 4 + stack_offset; \
|
return 1; \
|
||||||
else SP += 4 + stack_offset; \
|
if (stack32) \
|
||||||
|
ESP += 4 + stack_offset; \
|
||||||
|
else \
|
||||||
|
SP += 4 + stack_offset; \
|
||||||
cycles -= timing_retf_rm;
|
cycles -= timing_retf_rm;
|
||||||
|
|
||||||
#define RETF_a32(stack_offset) \
|
#define RETF_a32(stack_offset) \
|
||||||
if ((msw&1) && !(cpu_state.eflags&VM_FLAG)) \
|
if ((msw & 1) && !(cpu_state.eflags & VM_FLAG)) { \
|
||||||
{ \
|
|
||||||
pmoderetf(1, stack_offset); \
|
pmoderetf(1, stack_offset); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
if (stack32) \
|
if (stack32) { \
|
||||||
{ \
|
|
||||||
cpu_state.pc = readmeml(ss, ESP); \
|
cpu_state.pc = readmeml(ss, ESP); \
|
||||||
loadcs(readmeml(ss, ESP + 4) & 0xffff); \
|
loadcs(readmeml(ss, ESP + 4) & 0xffff); \
|
||||||
} \
|
} else { \
|
||||||
else \
|
|
||||||
{ \
|
|
||||||
cpu_state.pc = readmeml(ss, SP); \
|
cpu_state.pc = readmeml(ss, SP); \
|
||||||
loadcs(readmeml(ss, SP + 4) & 0xffff); \
|
loadcs(readmeml(ss, SP + 4) & 0xffff); \
|
||||||
} \
|
} \
|
||||||
if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
if (stack32) ESP += 8 + stack_offset; \
|
return 1; \
|
||||||
else SP += 8 + stack_offset; \
|
if (stack32) \
|
||||||
|
ESP += 8 + stack_offset; \
|
||||||
|
else \
|
||||||
|
SP += 8 + stack_offset; \
|
||||||
cycles -= timing_retf_rm;
|
cycles -= timing_retf_rm;
|
||||||
|
|
||||||
static int opRETF_a16(uint32_t fetchdat) {
|
static int opRETF_a16(uint32_t fetchdat) {
|
||||||
|
@@ -1,41 +1,25 @@
|
|||||||
#ifndef _X86_OPS_SET_H_
|
#ifndef _X86_OPS_SET_H_
|
||||||
#define _X86_OPS_SET_H_
|
#define _X86_OPS_SET_H_
|
||||||
#define opSET(condition) \
|
#define opSET(condition) \
|
||||||
static int opSET ## condition ## _a16(uint32_t fetchdat) \
|
static int opSET##condition##_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
seteab((cond_ ## condition) ? 1 : 0); \
|
seteab((cond_##condition) ? 1 : 0); \
|
||||||
CLOCK_CYCLES(4); \
|
CLOCK_CYCLES(4); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
\
|
\
|
||||||
static int opSET ## condition ## _a32(uint32_t fetchdat) \
|
static int opSET##condition##_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
if (cpu_mod != 3) \
|
if (cpu_mod != 3) \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
seteab((cond_ ## condition) ? 1 : 0); \
|
seteab((cond_##condition) ? 1 : 0); \
|
||||||
CLOCK_CYCLES(4); \
|
CLOCK_CYCLES(4); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opSET(O)
|
opSET(O) opSET(NO) opSET(B) opSET(NB) opSET(E) opSET(NE) opSET(BE) opSET(NBE) opSET(S) opSET(NS) opSET(P) opSET(NP) opSET(L)
|
||||||
opSET(NO)
|
opSET(NL) opSET(LE) opSET(NLE)
|
||||||
opSET(B)
|
|
||||||
opSET(NB)
|
|
||||||
opSET(E)
|
|
||||||
opSET(NE)
|
|
||||||
opSET(BE)
|
|
||||||
opSET(NBE)
|
|
||||||
opSET(S)
|
|
||||||
opSET(NS)
|
|
||||||
opSET(P)
|
|
||||||
opSET(NP)
|
|
||||||
opSET(L)
|
|
||||||
opSET(NL)
|
|
||||||
opSET(LE)
|
|
||||||
opSET(NLE)
|
|
||||||
|
|
||||||
#endif /* _X86_OPS_SET_H_ */
|
#endif /* _X86_OPS_SET_H_ */
|
||||||
|
@@ -3,76 +3,102 @@
|
|||||||
#define OP_SHIFT_b(c, ea32) \
|
#define OP_SHIFT_b(c, ea32) \
|
||||||
{ \
|
{ \
|
||||||
uint8_t temp_orig = temp; \
|
uint8_t temp_orig = temp; \
|
||||||
if (!c) return 0; \
|
if (!c) \
|
||||||
|
return 0; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
switch (rmdat & 0x38) \
|
switch (rmdat & 0x38) { \
|
||||||
{ \
|
|
||||||
case 0x00: /*ROL b, c*/ \
|
case 0x00: /*ROL b, c*/ \
|
||||||
temp = (temp << (c & 7)) | (temp >> (8-(c & 7))); \
|
temp = (temp << (c & 7)) | (temp >> (8 - (c & 7))); \
|
||||||
seteab(temp); if (cpu_state.abrt) return 1; \
|
seteab(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_rotate(FLAGS_ROL8, temp); \
|
set_flags_rotate(FLAGS_ROL8, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x08: /*ROR b,CL*/ \
|
case 0x08: /*ROR b,CL*/ \
|
||||||
temp = (temp >> (c & 7)) | (temp << (8-(c & 7))); \
|
temp = (temp >> (c & 7)) | (temp << (8 - (c & 7))); \
|
||||||
seteab(temp); if (cpu_state.abrt) return 1; \
|
seteab(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_rotate(FLAGS_ROR8, temp); \
|
set_flags_rotate(FLAGS_ROR8, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x10: /*RCL b,CL*/ \
|
case 0x10: /*RCL b,CL*/ \
|
||||||
temp2 = cpu_state.flags & C_FLAG; \
|
temp2 = cpu_state.flags & C_FLAG; \
|
||||||
if (is486) CLOCK_CYCLES_ALWAYS(c); \
|
if (is486) \
|
||||||
while (c > 0) \
|
CLOCK_CYCLES_ALWAYS(c); \
|
||||||
{ \
|
while (c > 0) { \
|
||||||
tempc = temp2 ? 1 : 0; \
|
tempc = temp2 ? 1 : 0; \
|
||||||
temp2 = temp & 0x80; \
|
temp2 = temp & 0x80; \
|
||||||
temp = (temp << 1) | tempc; \
|
temp = (temp << 1) | tempc; \
|
||||||
c--; \
|
c--; \
|
||||||
} \
|
} \
|
||||||
seteab(temp); if (cpu_state.abrt) return 1; \
|
seteab(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
||||||
if (temp2) cpu_state.flags |= C_FLAG; \
|
if (temp2) \
|
||||||
if ((cpu_state.flags & C_FLAG) ^ (temp >> 7)) cpu_state.flags |= V_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
if ((cpu_state.flags & C_FLAG) ^ (temp >> 7)) \
|
||||||
|
cpu_state.flags |= V_FLAG; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x18: /*RCR b,CL*/ \
|
case 0x18: /*RCR b,CL*/ \
|
||||||
temp2 = cpu_state.flags & C_FLAG; \
|
temp2 = cpu_state.flags & C_FLAG; \
|
||||||
if (is486) CLOCK_CYCLES_ALWAYS(c); \
|
if (is486) \
|
||||||
while (c > 0) \
|
CLOCK_CYCLES_ALWAYS(c); \
|
||||||
{ \
|
while (c > 0) { \
|
||||||
tempc = temp2 ? 0x80 : 0; \
|
tempc = temp2 ? 0x80 : 0; \
|
||||||
temp2 = temp & 1; \
|
temp2 = temp & 1; \
|
||||||
temp = (temp >> 1) | tempc; \
|
temp = (temp >> 1) | tempc; \
|
||||||
c--; \
|
c--; \
|
||||||
} \
|
} \
|
||||||
seteab(temp); if (cpu_state.abrt) return 1; \
|
seteab(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
||||||
if (temp2) cpu_state.flags |= C_FLAG; \
|
if (temp2) \
|
||||||
if ((temp ^ (temp >> 1)) & 0x40) cpu_state.flags |= V_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
if ((temp ^ (temp >> 1)) & 0x40) \
|
||||||
|
cpu_state.flags |= V_FLAG; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x20: case 0x30: /*SHL b,CL*/ \
|
case 0x20: \
|
||||||
seteab(temp << c); if (cpu_state.abrt) return 1; \
|
case 0x30: /*SHL b,CL*/ \
|
||||||
|
seteab(temp << c); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SHL8, temp_orig, c, (temp << c) & 0xff); \
|
set_flags_shift(FLAGS_SHL8, temp_orig, c, (temp << c) & 0xff); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x28: /*SHR b,CL*/ \
|
case 0x28: /*SHR b,CL*/ \
|
||||||
seteab(temp >> c); if (cpu_state.abrt) return 1; \
|
seteab(temp >> c); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SHR8, temp_orig, c, temp >> c); \
|
set_flags_shift(FLAGS_SHR8, temp_orig, c, temp >> c); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x38: /*SAR b,CL*/ \
|
case 0x38: /*SAR b,CL*/ \
|
||||||
temp = (int8_t)temp >> c; \
|
temp = (int8_t)temp >> c; \
|
||||||
seteab(temp); if (cpu_state.abrt) return 1; \
|
seteab(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SAR8, temp_orig, c, temp); \
|
set_flags_shift(FLAGS_SAR8, temp_orig, c, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@@ -80,76 +106,102 @@
|
|||||||
#define OP_SHIFT_w(c, ea32) \
|
#define OP_SHIFT_w(c, ea32) \
|
||||||
{ \
|
{ \
|
||||||
uint16_t temp_orig = temp; \
|
uint16_t temp_orig = temp; \
|
||||||
if (!c) return 0; \
|
if (!c) \
|
||||||
|
return 0; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
switch (rmdat & 0x38) \
|
switch (rmdat & 0x38) { \
|
||||||
{ \
|
|
||||||
case 0x00: /*ROL w, c*/ \
|
case 0x00: /*ROL w, c*/ \
|
||||||
temp = (temp << (c & 15)) | (temp >> (16-(c & 15))); \
|
temp = (temp << (c & 15)) | (temp >> (16 - (c & 15))); \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_rotate(FLAGS_ROL16, temp); \
|
set_flags_rotate(FLAGS_ROL16, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x08: /*ROR w,CL*/ \
|
case 0x08: /*ROR w,CL*/ \
|
||||||
temp = (temp >> (c & 15)) | (temp << (16-(c & 15))); \
|
temp = (temp >> (c & 15)) | (temp << (16 - (c & 15))); \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_rotate(FLAGS_ROR16, temp); \
|
set_flags_rotate(FLAGS_ROR16, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x10: /*RCL w, c*/ \
|
case 0x10: /*RCL w, c*/ \
|
||||||
temp2 = cpu_state.flags & C_FLAG; \
|
temp2 = cpu_state.flags & C_FLAG; \
|
||||||
if (is486) CLOCK_CYCLES_ALWAYS(c); \
|
if (is486) \
|
||||||
while (c > 0) \
|
CLOCK_CYCLES_ALWAYS(c); \
|
||||||
{ \
|
while (c > 0) { \
|
||||||
tempc = temp2 ? 1 : 0; \
|
tempc = temp2 ? 1 : 0; \
|
||||||
temp2 = temp & 0x8000; \
|
temp2 = temp & 0x8000; \
|
||||||
temp = (temp << 1) | tempc; \
|
temp = (temp << 1) | tempc; \
|
||||||
c--; \
|
c--; \
|
||||||
} \
|
} \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
||||||
if (temp2) cpu_state.flags |= C_FLAG; \
|
if (temp2) \
|
||||||
if ((cpu_state.flags & C_FLAG) ^ (temp >> 15)) cpu_state.flags |= V_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
if ((cpu_state.flags & C_FLAG) ^ (temp >> 15)) \
|
||||||
|
cpu_state.flags |= V_FLAG; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x18: /*RCR w, c*/ \
|
case 0x18: /*RCR w, c*/ \
|
||||||
temp2 = cpu_state.flags & C_FLAG; \
|
temp2 = cpu_state.flags & C_FLAG; \
|
||||||
if (is486) CLOCK_CYCLES_ALWAYS(c); \
|
if (is486) \
|
||||||
while (c > 0) \
|
CLOCK_CYCLES_ALWAYS(c); \
|
||||||
{ \
|
while (c > 0) { \
|
||||||
tempc = temp2 ? 0x8000 : 0; \
|
tempc = temp2 ? 0x8000 : 0; \
|
||||||
temp2 = temp & 1; \
|
temp2 = temp & 1; \
|
||||||
temp = (temp >> 1) | tempc; \
|
temp = (temp >> 1) | tempc; \
|
||||||
c--; \
|
c--; \
|
||||||
} \
|
} \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
||||||
if (temp2) cpu_state.flags |= C_FLAG; \
|
if (temp2) \
|
||||||
if ((temp ^ (temp >> 1)) & 0x4000) cpu_state.flags |= V_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
if ((temp ^ (temp >> 1)) & 0x4000) \
|
||||||
|
cpu_state.flags |= V_FLAG; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x20: case 0x30: /*SHL w, c*/ \
|
case 0x20: \
|
||||||
seteaw(temp << c); if (cpu_state.abrt) return 1; \
|
case 0x30: /*SHL w, c*/ \
|
||||||
|
seteaw(temp << c); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SHL16, temp_orig, c, (temp << c) & 0xffff); \
|
set_flags_shift(FLAGS_SHL16, temp_orig, c, (temp << c) & 0xffff); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x28: /*SHR w, c*/ \
|
case 0x28: /*SHR w, c*/ \
|
||||||
seteaw(temp >> c); if (cpu_state.abrt) return 1; \
|
seteaw(temp >> c); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SHR16, temp_orig, c, temp >> c); \
|
set_flags_shift(FLAGS_SHR16, temp_orig, c, temp >> c); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x38: /*SAR w, c*/ \
|
case 0x38: /*SAR w, c*/ \
|
||||||
temp = (int16_t)temp >> c; \
|
temp = (int16_t)temp >> c; \
|
||||||
seteaw(temp); if (cpu_state.abrt) return 1; \
|
seteaw(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SAR16, temp_orig, c, temp); \
|
set_flags_shift(FLAGS_SAR16, temp_orig, c, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@@ -157,76 +209,102 @@
|
|||||||
#define OP_SHIFT_l(c, ea32) \
|
#define OP_SHIFT_l(c, ea32) \
|
||||||
{ \
|
{ \
|
||||||
uint32_t temp_orig = temp; \
|
uint32_t temp_orig = temp; \
|
||||||
if (!c) return 0; \
|
if (!c) \
|
||||||
|
return 0; \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
switch (rmdat & 0x38) \
|
switch (rmdat & 0x38) { \
|
||||||
{ \
|
|
||||||
case 0x00: /*ROL l, c*/ \
|
case 0x00: /*ROL l, c*/ \
|
||||||
temp = (temp << c) | (temp >> (32-c)); \
|
temp = (temp << c) | (temp >> (32 - c)); \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_rotate(FLAGS_ROL32, temp); \
|
set_flags_rotate(FLAGS_ROL32, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x08: /*ROR l,CL*/ \
|
case 0x08: /*ROR l,CL*/ \
|
||||||
temp = (temp >> c) | (temp << (32-c)); \
|
temp = (temp >> c) | (temp << (32 - c)); \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_rotate(FLAGS_ROR32, temp); \
|
set_flags_rotate(FLAGS_ROR32, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1,0, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x10: /*RCL l, c*/ \
|
case 0x10: /*RCL l, c*/ \
|
||||||
temp2 = CF_SET(); \
|
temp2 = CF_SET(); \
|
||||||
if (is486) CLOCK_CYCLES_ALWAYS(c); \
|
if (is486) \
|
||||||
while (c > 0) \
|
CLOCK_CYCLES_ALWAYS(c); \
|
||||||
{ \
|
while (c > 0) { \
|
||||||
tempc = temp2 ? 1 : 0; \
|
tempc = temp2 ? 1 : 0; \
|
||||||
temp2 = temp & 0x80000000; \
|
temp2 = temp & 0x80000000; \
|
||||||
temp = (temp << 1) | tempc; \
|
temp = (temp << 1) | tempc; \
|
||||||
c--; \
|
c--; \
|
||||||
} \
|
} \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
||||||
if (temp2) cpu_state.flags |= C_FLAG; \
|
if (temp2) \
|
||||||
if ((cpu_state.flags & C_FLAG) ^ (temp >> 31)) cpu_state.flags |= V_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
if ((cpu_state.flags & C_FLAG) ^ (temp >> 31)) \
|
||||||
|
cpu_state.flags |= V_FLAG; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x18: /*RCR l, c*/ \
|
case 0x18: /*RCR l, c*/ \
|
||||||
temp2 = cpu_state.flags & C_FLAG; \
|
temp2 = cpu_state.flags & C_FLAG; \
|
||||||
if (is486) CLOCK_CYCLES_ALWAYS(c); \
|
if (is486) \
|
||||||
while (c > 0) \
|
CLOCK_CYCLES_ALWAYS(c); \
|
||||||
{ \
|
while (c > 0) { \
|
||||||
tempc = temp2 ? 0x80000000 : 0; \
|
tempc = temp2 ? 0x80000000 : 0; \
|
||||||
temp2 = temp & 1; \
|
temp2 = temp & 1; \
|
||||||
temp = (temp >> 1) | tempc; \
|
temp = (temp >> 1) | tempc; \
|
||||||
c--; \
|
c--; \
|
||||||
} \
|
} \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
cpu_state.flags &= ~(C_FLAG | V_FLAG); \
|
||||||
if (temp2) cpu_state.flags |= C_FLAG; \
|
if (temp2) \
|
||||||
if ((temp ^ (temp >> 1)) & 0x40000000) cpu_state.flags |= V_FLAG; \
|
cpu_state.flags |= C_FLAG; \
|
||||||
|
if ((temp ^ (temp >> 1)) & 0x40000000) \
|
||||||
|
cpu_state.flags |= V_FLAG; \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 9 : 10); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 9 : 10, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x20: case 0x30: /*SHL l, c*/ \
|
case 0x20: \
|
||||||
seteal(temp << c); if (cpu_state.abrt) return 1; \
|
case 0x30: /*SHL l, c*/ \
|
||||||
|
seteal(temp << c); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SHL32, temp_orig, c, temp << c); \
|
set_flags_shift(FLAGS_SHL32, temp_orig, c, temp << c); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x28: /*SHR l, c*/ \
|
case 0x28: /*SHR l, c*/ \
|
||||||
seteal(temp >> c); if (cpu_state.abrt) return 1; \
|
seteal(temp >> c); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SHR32, temp_orig, c, temp >> c); \
|
set_flags_shift(FLAGS_SHR32, temp_orig, c, temp >> c); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
case 0x38: /*SAR l, c*/ \
|
case 0x38: /*SAR l, c*/ \
|
||||||
temp = (int32_t)temp >> c; \
|
temp = (int32_t)temp >> c; \
|
||||||
seteal(temp); if (cpu_state.abrt) return 1; \
|
seteal(temp); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
set_flags_shift(FLAGS_SAR32, temp_orig, c, temp); \
|
set_flags_shift(FLAGS_SAR32, temp_orig, c, temp); \
|
||||||
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
CLOCK_CYCLES((cpu_mod == 3) ? 3 : 7); \
|
||||||
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, ea32); \
|
PREFETCH_RUN((cpu_mod == 3) ? 3 : 7, 2, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, \
|
||||||
|
ea32); \
|
||||||
break; \
|
break; \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
@@ -511,59 +589,76 @@ static int opD3_l_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define SHLD_w() \
|
#define SHLD_w() \
|
||||||
if (count) \
|
if (count) { \
|
||||||
{ \
|
uint16_t tempw = geteaw(); \
|
||||||
uint16_t tempw = geteaw(); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
int tempc = ((tempw << (count - 1)) & (1 << 15)) ? 1 : 0; \
|
int tempc = ((tempw << (count - 1)) & (1 << 15)) ? 1 : 0; \
|
||||||
uint32_t templ = (tempw << 16) | cpu_state.regs[cpu_reg].w; \
|
uint32_t templ = (tempw << 16) | cpu_state.regs[cpu_reg].w; \
|
||||||
if (count <= 16) tempw = templ >> (16 - count); \
|
if (count <= 16) \
|
||||||
else tempw = (templ << count) >> 16; \
|
tempw = templ >> (16 - count); \
|
||||||
seteaw(tempw); if (cpu_state.abrt) return 1; \
|
else \
|
||||||
|
tempw = (templ << count) >> 16; \
|
||||||
|
seteaw(tempw); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
setznp16(tempw); \
|
setznp16(tempw); \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
|
cpu_state.flags |= C_FLAG; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHLD_l() \
|
#define SHLD_l() \
|
||||||
if (count) \
|
if (count) { \
|
||||||
{ \
|
uint32_t templ = geteal(); \
|
||||||
uint32_t templ = geteal(); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
int tempc = ((templ << (count - 1)) & (1 << 31)) ? 1 : 0; \
|
int tempc = ((templ << (count - 1)) & (1 << 31)) ? 1 : 0; \
|
||||||
templ = (templ << count) | (cpu_state.regs[cpu_reg].l >> (32 - count)); \
|
templ = (templ << count) | (cpu_state.regs[cpu_reg].l >> (32 - count)); \
|
||||||
seteal(templ); if (cpu_state.abrt) return 1; \
|
seteal(templ); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
setznp32(templ); \
|
setznp32(templ); \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
|
cpu_state.flags |= C_FLAG; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHRD_w() \
|
#define SHRD_w() \
|
||||||
if (count) \
|
if (count) { \
|
||||||
{ \
|
uint16_t tempw = geteaw(); \
|
||||||
uint16_t tempw = geteaw(); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
int tempc = (tempw >> (count - 1)) & 1; \
|
int tempc = (tempw >> (count - 1)) & 1; \
|
||||||
uint32_t templ = tempw | (cpu_state.regs[cpu_reg].w << 16); \
|
uint32_t templ = tempw | (cpu_state.regs[cpu_reg].w << 16); \
|
||||||
tempw = templ >> count; \
|
tempw = templ >> count; \
|
||||||
seteaw(tempw); if (cpu_state.abrt) return 1; \
|
seteaw(tempw); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
setznp16(tempw); \
|
setznp16(tempw); \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
|
cpu_state.flags |= C_FLAG; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SHRD_l() \
|
#define SHRD_l() \
|
||||||
if (count) \
|
if (count) { \
|
||||||
{ \
|
uint32_t templ = geteal(); \
|
||||||
uint32_t templ = geteal(); if (cpu_state.abrt) return 1; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
int tempc = (templ >> (count - 1)) & 1; \
|
int tempc = (templ >> (count - 1)) & 1; \
|
||||||
templ = (templ >> count) | (cpu_state.regs[cpu_reg].l << (32 - count)); \
|
templ = (templ >> count) | (cpu_state.regs[cpu_reg].l << (32 - count)); \
|
||||||
seteal(templ); if (cpu_state.abrt) return 1; \
|
seteal(templ); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
setznp32(templ); \
|
setznp32(templ); \
|
||||||
flags_rebuild(); \
|
flags_rebuild(); \
|
||||||
if (tempc) cpu_state.flags |= C_FLAG; \
|
if (tempc) \
|
||||||
|
cpu_state.flags |= C_FLAG; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define opSHxD(operation) \
|
#define opSHxD(operation) \
|
||||||
static int op ## operation ## _i_a16(uint32_t fetchdat) \
|
static int op##operation##_i_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int count; \
|
int count; \
|
||||||
\
|
\
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
@@ -573,11 +668,10 @@ static int opD3_l_a32(uint32_t fetchdat) {
|
|||||||
operation(); \
|
operation(); \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(3); \
|
CLOCK_CYCLES(3); \
|
||||||
PREFETCH_RUN(3, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 0); \
|
PREFETCH_RUN(3, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## operation ## _CL_a16(uint32_t fetchdat) \
|
static int op##operation##_CL_a16(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int count; \
|
int count; \
|
||||||
\
|
\
|
||||||
fetch_ea_16(fetchdat); \
|
fetch_ea_16(fetchdat); \
|
||||||
@@ -587,11 +681,10 @@ static int opD3_l_a32(uint32_t fetchdat) {
|
|||||||
operation(); \
|
operation(); \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(3); \
|
CLOCK_CYCLES(3); \
|
||||||
PREFETCH_RUN(3, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 0); \
|
PREFETCH_RUN(3, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## operation ## _i_a32(uint32_t fetchdat) \
|
static int op##operation##_i_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int count; \
|
int count; \
|
||||||
\
|
\
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
@@ -601,11 +694,10 @@ static int opD3_l_a32(uint32_t fetchdat) {
|
|||||||
operation(); \
|
operation(); \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(3); \
|
CLOCK_CYCLES(3); \
|
||||||
PREFETCH_RUN(3, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 1); \
|
PREFETCH_RUN(3, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int op ## operation ## _CL_a32(uint32_t fetchdat) \
|
static int op##operation##_CL_a32(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
int count; \
|
int count; \
|
||||||
\
|
\
|
||||||
fetch_ea_32(fetchdat); \
|
fetch_ea_32(fetchdat); \
|
||||||
@@ -615,13 +707,10 @@ static int opD3_l_a32(uint32_t fetchdat) {
|
|||||||
operation(); \
|
operation(); \
|
||||||
\
|
\
|
||||||
CLOCK_CYCLES(3); \
|
CLOCK_CYCLES(3); \
|
||||||
PREFETCH_RUN(3, 3, rmdat, 0,(cpu_mod == 3) ? 0:1,0,(cpu_mod == 3) ? 0:1, 1); \
|
PREFETCH_RUN(3, 3, rmdat, 0, (cpu_mod == 3) ? 0 : 1, 0, (cpu_mod == 3) ? 0 : 1, 1); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opSHxD(SHLD_w)
|
opSHxD(SHLD_w) opSHxD(SHLD_l) opSHxD(SHRD_w) opSHxD(SHRD_l)
|
||||||
opSHxD(SHLD_l)
|
|
||||||
opSHxD(SHRD_w)
|
|
||||||
opSHxD(SHRD_l)
|
|
||||||
|
|
||||||
#endif /* _X86_OPS_SHIFT_H_ */
|
#endif /* _X86_OPS_SHIFT_H_ */
|
||||||
|
@@ -1,38 +1,34 @@
|
|||||||
#ifndef _X86_OPS_STACK_H_
|
#ifndef _X86_OPS_STACK_H_
|
||||||
#define _X86_OPS_STACK_H_
|
#define _X86_OPS_STACK_H_
|
||||||
#define PUSH_W_OP(reg) \
|
#define PUSH_W_OP(reg) \
|
||||||
static int opPUSH_ ## reg (uint32_t fetchdat) \
|
static int opPUSH_##reg(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
PUSH_W(reg); \
|
PUSH_W(reg); \
|
||||||
CLOCK_CYCLES((is486) ? 1 : 2); \
|
CLOCK_CYCLES((is486) ? 1 : 2); \
|
||||||
PREFETCH_RUN(2, 1, -1, 0,0,1,0, 0); \
|
PREFETCH_RUN(2, 1, -1, 0, 0, 1, 0, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define PUSH_L_OP(reg) \
|
#define PUSH_L_OP(reg) \
|
||||||
static int opPUSH_ ## reg (uint32_t fetchdat) \
|
static int opPUSH_##reg(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
PUSH_L(reg); \
|
PUSH_L(reg); \
|
||||||
CLOCK_CYCLES((is486) ? 1 : 2); \
|
CLOCK_CYCLES((is486) ? 1 : 2); \
|
||||||
PREFETCH_RUN(2, 1, -1, 0,0,0,1, 0); \
|
PREFETCH_RUN(2, 1, -1, 0, 0, 0, 1, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define POP_W_OP(reg) \
|
#define POP_W_OP(reg) \
|
||||||
static int opPOP_ ## reg (uint32_t fetchdat) \
|
static int opPOP_##reg(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
reg = POP_W(); \
|
reg = POP_W(); \
|
||||||
CLOCK_CYCLES((is486) ? 1 : 4); \
|
CLOCK_CYCLES((is486) ? 1 : 4); \
|
||||||
PREFETCH_RUN(4, 1, -1, 1,0,0,0, 0); \
|
PREFETCH_RUN(4, 1, -1, 1, 0, 0, 0, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define POP_L_OP(reg) \
|
#define POP_L_OP(reg) \
|
||||||
static int opPOP_ ## reg (uint32_t fetchdat) \
|
static int opPOP_##reg(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
reg = POP_L(); \
|
reg = POP_L(); \
|
||||||
CLOCK_CYCLES((is486) ? 1 : 4); \
|
CLOCK_CYCLES((is486) ? 1 : 4); \
|
||||||
PREFETCH_RUN(4, 1, -1, 0,1,0,0, 0); \
|
PREFETCH_RUN(4, 1, -1, 0, 1, 0, 0, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -154,7 +150,7 @@ static int opPOPA_w(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
ESP += 16;
|
ESP += 16;
|
||||||
} else {
|
} else {
|
||||||
DI = readmemw(ss, ((SP) & 0xFFFF));
|
DI = readmemw(ss, ((SP)&0xFFFF));
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
SI = readmemw(ss, ((SP + 2) & 0xFFFF));
|
SI = readmemw(ss, ((SP + 2) & 0xFFFF));
|
||||||
@@ -206,7 +202,7 @@ static int opPOPA_l(uint32_t fetchdat) {
|
|||||||
return 1;
|
return 1;
|
||||||
ESP += 32;
|
ESP += 32;
|
||||||
} else {
|
} else {
|
||||||
EDI = readmeml(ss, ((SP) & 0xFFFF));
|
EDI = readmeml(ss, ((SP)&0xFFFF));
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
ESI = readmeml(ss, ((SP + 4) & 0xFFFF));
|
ESI = readmeml(ss, ((SP + 4) & 0xFFFF));
|
||||||
@@ -521,40 +517,44 @@ static int opLEAVE_l(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define PUSH_SEG_OPS(seg) \
|
#define PUSH_SEG_OPS(seg) \
|
||||||
static int opPUSH_ ## seg ## _w(uint32_t fetchdat) \
|
static int opPUSH_##seg##_w(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
PUSH_W(seg); \
|
PUSH_W(seg); \
|
||||||
CLOCK_CYCLES(2); \
|
CLOCK_CYCLES(2); \
|
||||||
PREFETCH_RUN(2, 1, -1, 0,0,1,0, 0); \
|
PREFETCH_RUN(2, 1, -1, 0, 0, 1, 0, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opPUSH_ ## seg ## _l(uint32_t fetchdat) \
|
static int opPUSH_##seg##_l(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
PUSH_L(seg); \
|
PUSH_L(seg); \
|
||||||
CLOCK_CYCLES(2); \
|
CLOCK_CYCLES(2); \
|
||||||
PREFETCH_RUN(2, 1, -1, 0,0,0,1, 0); \
|
PREFETCH_RUN(2, 1, -1, 0, 0, 0, 1, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define POP_SEG_OPS(seg, realseg) \
|
#define POP_SEG_OPS(seg, realseg) \
|
||||||
static int opPOP_ ## seg ## _w(uint32_t fetchdat) \
|
static int opPOP_##seg##_w(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint16_t temp_seg; \
|
uint16_t temp_seg; \
|
||||||
uint32_t temp_esp = ESP; \
|
uint32_t temp_esp = ESP; \
|
||||||
temp_seg = POP_W(); if (cpu_state.abrt) return 1; \
|
temp_seg = POP_W(); \
|
||||||
loadseg(temp_seg, realseg); if (cpu_state.abrt) ESP = temp_esp; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
loadseg(temp_seg, realseg); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
ESP = temp_esp; \
|
||||||
CLOCK_CYCLES(is486 ? 3 : 7); \
|
CLOCK_CYCLES(is486 ? 3 : 7); \
|
||||||
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0); \
|
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0, 0, 1, 0, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
} \
|
} \
|
||||||
static int opPOP_ ## seg ## _l(uint32_t fetchdat) \
|
static int opPOP_##seg##_l(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
uint32_t temp_seg; \
|
uint32_t temp_seg; \
|
||||||
uint32_t temp_esp = ESP; \
|
uint32_t temp_esp = ESP; \
|
||||||
temp_seg = POP_L(); if (cpu_state.abrt) return 1; \
|
temp_seg = POP_L(); \
|
||||||
loadseg(temp_seg & 0xffff, realseg); if (cpu_state.abrt) ESP = temp_esp; \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
loadseg(temp_seg & 0xffff, realseg); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
ESP = temp_esp; \
|
||||||
CLOCK_CYCLES(is486 ? 3 : 7); \
|
CLOCK_CYCLES(is486 ? 3 : 7); \
|
||||||
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0,0,1,0, 0); \
|
PREFETCH_RUN(is486 ? 3 : 7, 1, -1, 0, 0, 1, 0, 0); \
|
||||||
return cpu_state.abrt; \
|
return cpu_state.abrt; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -220,21 +220,13 @@ static int opXCHG_EAX_ESP(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define opBSWAP(reg) \
|
#define opBSWAP(reg) \
|
||||||
static int opBSWAP_ ## reg(uint32_t fetchdat) \
|
static int opBSWAP_##reg(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
reg = (reg >> 24) | ((reg >> 8) & 0xff00) | ((reg << 8) & 0xff0000) | ((reg << 24) & 0xff000000); \
|
reg = (reg >> 24) | ((reg >> 8) & 0xff00) | ((reg << 8) & 0xff0000) | ((reg << 24) & 0xff000000); \
|
||||||
CLOCK_CYCLES(1); \
|
CLOCK_CYCLES(1); \
|
||||||
PREFETCH_RUN(1, 1, -1, 0,0,0,0, 0); \
|
PREFETCH_RUN(1, 1, -1, 0, 0, 0, 0, 0); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opBSWAP(EAX)
|
opBSWAP(EAX) opBSWAP(EBX) opBSWAP(ECX) opBSWAP(EDX) opBSWAP(ESI) opBSWAP(EDI) opBSWAP(EBP) opBSWAP(ESP)
|
||||||
opBSWAP(EBX)
|
|
||||||
opBSWAP(ECX)
|
|
||||||
opBSWAP(EDX)
|
|
||||||
opBSWAP(ESI)
|
|
||||||
opBSWAP(EDI)
|
|
||||||
opBSWAP(EBP)
|
|
||||||
opBSWAP(ESP)
|
|
||||||
|
|
||||||
#endif /* _X86_OPS_XCHG_H_ */
|
#endif /* _X86_OPS_XCHG_H_ */
|
||||||
|
@@ -1,9 +1,9 @@
|
|||||||
#ifndef _X87_H_
|
#ifndef _X87_H_
|
||||||
#define _X87_H_
|
#define _X87_H_
|
||||||
#define C0 (1<<8)
|
#define C0 (1 << 8)
|
||||||
#define C1 (1<<9)
|
#define C1 (1 << 9)
|
||||||
#define C2 (1<<10)
|
#define C2 (1 << 10)
|
||||||
#define C3 (1<<14)
|
#define C3 (1 << 14)
|
||||||
|
|
||||||
uint32_t x87_pc_off, x87_op_off;
|
uint32_t x87_pc_off, x87_op_off;
|
||||||
uint16_t x87_pc_seg, x87_op_seg;
|
uint16_t x87_pc_seg, x87_op_seg;
|
||||||
|
@@ -8,32 +8,28 @@
|
|||||||
|
|
||||||
static int rounding_modes[4] = {FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO};
|
static int rounding_modes[4] = {FE_TONEAREST, FE_DOWNWARD, FE_UPWARD, FE_TOWARDZERO};
|
||||||
|
|
||||||
#define ST(x) cpu_state.ST[((cpu_state.TOP+(x))&7)]
|
#define ST(x) cpu_state.ST[((cpu_state.TOP + (x)) & 7)]
|
||||||
|
|
||||||
#define STATUS_ZERODIVIDE 4
|
#define STATUS_ZERODIVIDE 4
|
||||||
|
|
||||||
#define FPCW_DISI (1 << 7)
|
#define FPCW_DISI (1 << 7)
|
||||||
|
|
||||||
#define x87_div(dst, src1, src2) do \
|
#define x87_div(dst, src1, src2) \
|
||||||
{ \
|
do { \
|
||||||
if (((double)src2) == 0.0) \
|
if (((double)src2) == 0.0) { \
|
||||||
{ \
|
|
||||||
cpu_state.npxs |= STATUS_ZERODIVIDE; \
|
cpu_state.npxs |= STATUS_ZERODIVIDE; \
|
||||||
if (cpu_state.npxc & STATUS_ZERODIVIDE) \
|
if (cpu_state.npxc & STATUS_ZERODIVIDE) \
|
||||||
dst = src1 / (double)src2; \
|
dst = src1 / (double)src2; \
|
||||||
else \
|
else { \
|
||||||
{ \
|
|
||||||
pclog("FPU : divide by zero\n"); \
|
pclog("FPU : divide by zero\n"); \
|
||||||
picint(1 << 13); \
|
picint(1 << 13); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
} \
|
} else \
|
||||||
else \
|
|
||||||
dst = src1 / (double)src2; \
|
dst = src1 / (double)src2; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static inline void x87_checkexceptions() {
|
static inline void x87_checkexceptions() {}
|
||||||
}
|
|
||||||
|
|
||||||
static inline void x87_push(double i) {
|
static inline void x87_push(double i) {
|
||||||
cpu_state.TOP--;
|
cpu_state.TOP--;
|
||||||
@@ -139,10 +135,10 @@ static inline void x87_st80(double d) {
|
|||||||
{
|
{
|
||||||
exp80final = 0x7fff;
|
exp80final = 0x7fff;
|
||||||
mant80final |= (0x8000000000000000);
|
mant80final |= (0x8000000000000000);
|
||||||
} else if (d != 0) { //Zero is a special case
|
} else if (d != 0) { // Zero is a special case
|
||||||
// Elvira wants the 8 and tcalc doesn't
|
// Elvira wants the 8 and tcalc doesn't
|
||||||
mant80final |= (0x8000000000000000);
|
mant80final |= (0x8000000000000000);
|
||||||
//Ca-cyber doesn't like this when result is zero.
|
// Ca-cyber doesn't like this when result is zero.
|
||||||
exp80final += (BIAS80 - BIAS64);
|
exp80final += (BIAS80 - BIAS64);
|
||||||
}
|
}
|
||||||
test.begin = (((int16_t)sign80) << 15) | (int16_t)exp80final;
|
test.begin = (((int16_t)sign80) << 15) | (int16_t)exp80final;
|
||||||
@@ -196,17 +192,15 @@ static inline uint16_t x87_compare(double a, double b) {
|
|||||||
|
|
||||||
/* Memory barrier, to force GCC to write to the input parameters
|
/* Memory barrier, to force GCC to write to the input parameters
|
||||||
* before the compare rather than after */
|
* before the compare rather than after */
|
||||||
asm volatile ("" : : : "memory");
|
asm volatile("" : : : "memory");
|
||||||
|
|
||||||
asm(
|
asm("fldl %2\n"
|
||||||
"fldl %2\n"
|
|
||||||
"fldl %1\n"
|
"fldl %1\n"
|
||||||
"fclex\n"
|
"fclex\n"
|
||||||
"fcompp\n"
|
"fcompp\n"
|
||||||
"fnstsw %0\n"
|
"fnstsw %0\n"
|
||||||
: "=m" (out)
|
: "=m"(out)
|
||||||
: "m" (a), "m" (b)
|
: "m"(a), "m"(b));
|
||||||
);
|
|
||||||
|
|
||||||
return out & (C0 | C2 | C3);
|
return out & (C0 | C2 | C3);
|
||||||
#else
|
#else
|
||||||
@@ -229,17 +223,15 @@ static inline uint16_t x87_ucompare(double a, double b) {
|
|||||||
|
|
||||||
/* Memory barrier, to force GCC to write to the input parameters
|
/* Memory barrier, to force GCC to write to the input parameters
|
||||||
* before the compare rather than after */
|
* before the compare rather than after */
|
||||||
asm volatile ("" : : : "memory");
|
asm volatile("" : : : "memory");
|
||||||
|
|
||||||
asm(
|
asm("fldl %2\n"
|
||||||
"fldl %2\n"
|
|
||||||
"fldl %1\n"
|
"fldl %1\n"
|
||||||
"fclex\n"
|
"fclex\n"
|
||||||
"fucompp\n"
|
"fucompp\n"
|
||||||
"fnstsw %0\n"
|
"fnstsw %0\n"
|
||||||
: "=m" (out)
|
: "=m"(out)
|
||||||
: "m" (a), "m" (b)
|
: "m"(a), "m"(b));
|
||||||
);
|
|
||||||
|
|
||||||
return out & (C0 | C2 | C3);
|
return out & (C0 | C2 | C3);
|
||||||
#else
|
#else
|
||||||
@@ -269,10 +261,9 @@ typedef union {
|
|||||||
#ifdef X8087
|
#ifdef X8087
|
||||||
#define FP_ENTER() fpucount++
|
#define FP_ENTER() fpucount++
|
||||||
#else
|
#else
|
||||||
#define FP_ENTER() do \
|
#define FP_ENTER() \
|
||||||
{ \
|
do { \
|
||||||
if (cr0 & 0xc) \
|
if (cr0 & 0xc) { \
|
||||||
{ \
|
|
||||||
x86_int(7); \
|
x86_int(7); \
|
||||||
return 1; \
|
return 1; \
|
||||||
} \
|
} \
|
||||||
@@ -316,24 +307,19 @@ static int FPU_ILLEGAL_a32(uint32_t fetchdat) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
OpFn OP_TABLE(fpu_d8_a16)[32] =
|
OpFn OP_TABLE(fpu_d8_a16)[32] = {opFADDs_a16, opFMULs_a16, opFCOMs_a16, opFCOMPs_a16, opFSUBs_a16, opFSUBRs_a16, opFDIVs_a16,
|
||||||
{
|
opFDIVRs_a16, opFADDs_a16, opFMULs_a16, opFCOMs_a16, opFCOMPs_a16, opFSUBs_a16, opFSUBRs_a16,
|
||||||
opFADDs_a16, opFMULs_a16, opFCOMs_a16, opFCOMPs_a16, opFSUBs_a16, opFSUBRs_a16, opFDIVs_a16, opFDIVRs_a16,
|
opFDIVs_a16, opFDIVRs_a16, opFADDs_a16, opFMULs_a16, opFCOMs_a16, opFCOMPs_a16, opFSUBs_a16,
|
||||||
opFADDs_a16, opFMULs_a16, opFCOMs_a16, opFCOMPs_a16, opFSUBs_a16, opFSUBRs_a16, opFDIVs_a16, opFDIVRs_a16,
|
opFSUBRs_a16, opFDIVs_a16, opFDIVRs_a16, opFADD, opFMUL, opFCOM, opFCOMP,
|
||||||
opFADDs_a16, opFMULs_a16, opFCOMs_a16, opFCOMPs_a16, opFSUBs_a16, opFSUBRs_a16, opFDIVs_a16, opFDIVRs_a16,
|
opFSUB, opFSUBR, opFDIV, opFDIVR};
|
||||||
opFADD, opFMUL, opFCOM, opFCOMP, opFSUB, opFSUBR, opFDIV, opFDIVR
|
OpFn OP_TABLE(fpu_d8_a32)[32] = {opFADDs_a32, opFMULs_a32, opFCOMs_a32, opFCOMPs_a32, opFSUBs_a32, opFSUBRs_a32, opFDIVs_a32,
|
||||||
};
|
opFDIVRs_a32, opFADDs_a32, opFMULs_a32, opFCOMs_a32, opFCOMPs_a32, opFSUBs_a32, opFSUBRs_a32,
|
||||||
OpFn OP_TABLE(fpu_d8_a32)[32] =
|
opFDIVs_a32, opFDIVRs_a32, opFADDs_a32, opFMULs_a32, opFCOMs_a32, opFCOMPs_a32, opFSUBs_a32,
|
||||||
{
|
opFSUBRs_a32, opFDIVs_a32, opFDIVRs_a32, opFADD, opFMUL, opFCOM, opFCOMP,
|
||||||
opFADDs_a32, opFMULs_a32, opFCOMs_a32, opFCOMPs_a32, opFSUBs_a32, opFSUBRs_a32, opFDIVs_a32, opFDIVRs_a32,
|
opFSUB, opFSUBR, opFDIV, opFDIVR};
|
||||||
opFADDs_a32, opFMULs_a32, opFCOMs_a32, opFCOMPs_a32, opFSUBs_a32, opFSUBRs_a32, opFDIVs_a32, opFDIVRs_a32,
|
|
||||||
opFADDs_a32, opFMULs_a32, opFCOMs_a32, opFCOMPs_a32, opFSUBs_a32, opFSUBRs_a32, opFDIVs_a32, opFDIVRs_a32,
|
|
||||||
opFADD, opFMUL, opFCOM, opFCOMP, opFSUB, opFSUBR, opFDIV, opFDIVR
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_d9_a16)[256] =
|
OpFn OP_TABLE(fpu_d9_a16)[256] = {
|
||||||
{
|
|
||||||
opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16,
|
opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16, opFLDs_a16,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16,
|
opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16, opFSTs_a16,
|
||||||
@@ -368,12 +354,10 @@ OpFn OP_TABLE(fpu_d9_a16)[256] =
|
|||||||
opFCHS, opFABS, ILLEGAL, ILLEGAL, opFTST, opFXAM, ILLEGAL, ILLEGAL,
|
opFCHS, opFABS, ILLEGAL, ILLEGAL, opFTST, opFXAM, ILLEGAL, ILLEGAL,
|
||||||
opFLD1, opFLDL2T, opFLDL2E, opFLDPI, opFLDEG2, opFLDLN2, opFLDZ, ILLEGAL,
|
opFLD1, opFLDL2T, opFLDL2E, opFLDPI, opFLDEG2, opFLDLN2, opFLDZ, ILLEGAL,
|
||||||
opF2XM1, opFYL2X, opFPTAN, opFPATAN, ILLEGAL, opFPREM1, opFDECSTP, opFINCSTP,
|
opF2XM1, opFYL2X, opFPTAN, opFPATAN, ILLEGAL, opFPREM1, opFDECSTP, opFINCSTP,
|
||||||
opFPREM, opFYL2XP1, opFSQRT, opFSINCOS, opFRNDINT, opFSCALE, opFSIN, opFCOS
|
opFPREM, opFYL2XP1, opFSQRT, opFSINCOS, opFRNDINT, opFSCALE, opFSIN, opFCOS};
|
||||||
};
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_d9_a32)[256] =
|
OpFn OP_TABLE(fpu_d9_a32)[256] = {
|
||||||
{
|
|
||||||
opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32,
|
opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32, opFLDs_a32,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32,
|
opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32, opFSTs_a32,
|
||||||
@@ -408,13 +392,11 @@ OpFn OP_TABLE(fpu_d9_a32)[256] =
|
|||||||
opFCHS, opFABS, ILLEGAL, ILLEGAL, opFTST, opFXAM, ILLEGAL, ILLEGAL,
|
opFCHS, opFABS, ILLEGAL, ILLEGAL, opFTST, opFXAM, ILLEGAL, ILLEGAL,
|
||||||
opFLD1, opFLDL2T, opFLDL2E, opFLDPI, opFLDEG2, opFLDLN2, opFLDZ, ILLEGAL,
|
opFLD1, opFLDL2T, opFLDL2E, opFLDPI, opFLDEG2, opFLDLN2, opFLDZ, ILLEGAL,
|
||||||
opF2XM1, opFYL2X, opFPTAN, opFPATAN, ILLEGAL, opFPREM1, opFDECSTP, opFINCSTP,
|
opF2XM1, opFYL2X, opFPTAN, opFPATAN, ILLEGAL, opFPREM1, opFDECSTP, opFINCSTP,
|
||||||
opFPREM, opFYL2XP1, opFSQRT, opFSINCOS, opFRNDINT, opFSCALE, opFSIN, opFCOS
|
opFPREM, opFYL2XP1, opFSQRT, opFSINCOS, opFRNDINT, opFSCALE, opFSIN, opFCOS};
|
||||||
};
|
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_da_a16)[256] =
|
OpFn OP_TABLE(fpu_da_a16)[256] = {
|
||||||
{
|
|
||||||
opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16,
|
opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16,
|
||||||
opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16,
|
opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16,
|
||||||
opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16,
|
opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16,
|
||||||
@@ -450,11 +432,10 @@ OpFn OP_TABLE(fpu_da_a16)[256] =
|
|||||||
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_da_a32)[256] =
|
OpFn OP_TABLE(fpu_da_a32)[256] = {
|
||||||
{
|
|
||||||
opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32,
|
opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32,
|
||||||
opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32,
|
opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32,
|
||||||
opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32,
|
opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32,
|
||||||
@@ -490,12 +471,11 @@ OpFn OP_TABLE(fpu_da_a32)[256] =
|
|||||||
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_686_da_a16)[256] =
|
OpFn OP_TABLE(fpu_686_da_a16)[256] = {
|
||||||
{
|
|
||||||
opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16,
|
opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16, opFADDil_a16,
|
||||||
opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16,
|
opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16, opFMULil_a16,
|
||||||
opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16,
|
opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16, opFCOMil_a16,
|
||||||
@@ -531,11 +511,10 @@ OpFn OP_TABLE(fpu_686_da_a16)[256] =
|
|||||||
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_686_da_a32)[256] =
|
OpFn OP_TABLE(fpu_686_da_a32)[256] = {
|
||||||
{
|
|
||||||
opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32,
|
opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32, opFADDil_a32,
|
||||||
opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32,
|
opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32, opFMULil_a32,
|
||||||
opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32,
|
opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32, opFCOMil_a32,
|
||||||
@@ -571,12 +550,11 @@ OpFn OP_TABLE(fpu_686_da_a32)[256] =
|
|||||||
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, opFUCOMPP, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_db_a16)[256] =
|
OpFn OP_TABLE(fpu_db_a16)[256] = {
|
||||||
{
|
|
||||||
opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16,
|
opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16,
|
opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16,
|
||||||
@@ -612,11 +590,10 @@ OpFn OP_TABLE(fpu_db_a16)[256] =
|
|||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_db_a32)[256] =
|
OpFn OP_TABLE(fpu_db_a32)[256] = {
|
||||||
{
|
|
||||||
opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32,
|
opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32,
|
opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32,
|
||||||
@@ -652,12 +629,11 @@ OpFn OP_TABLE(fpu_db_a32)[256] =
|
|||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_686_db_a16)[256] =
|
OpFn OP_TABLE(fpu_686_db_a16)[256] = {
|
||||||
{
|
|
||||||
opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16,
|
opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16, opFILDil_a16,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16,
|
opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16, opFISTil_a16,
|
||||||
@@ -693,11 +669,10 @@ OpFn OP_TABLE(fpu_686_db_a16)[256] =
|
|||||||
opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI,
|
opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI,
|
||||||
opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI,
|
opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_686_db_a32)[256] =
|
OpFn OP_TABLE(fpu_686_db_a32)[256] = {
|
||||||
{
|
|
||||||
opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32,
|
opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32, opFILDil_a32,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32,
|
opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32, opFISTil_a32,
|
||||||
@@ -733,27 +708,22 @@ OpFn OP_TABLE(fpu_686_db_a32)[256] =
|
|||||||
opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI,
|
opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI, opFUCOMI,
|
||||||
opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI,
|
opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI, opFCOMI,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
|
|
||||||
OpFn OP_TABLE(fpu_dc_a16)[32] =
|
OpFn OP_TABLE(fpu_dc_a16)[32] = {opFADDd_a16, opFMULd_a16, opFCOMd_a16, opFCOMPd_a16, opFSUBd_a16, opFSUBRd_a16, opFDIVd_a16,
|
||||||
{
|
opFDIVRd_a16, opFADDd_a16, opFMULd_a16, opFCOMd_a16, opFCOMPd_a16, opFSUBd_a16, opFSUBRd_a16,
|
||||||
opFADDd_a16, opFMULd_a16, opFCOMd_a16, opFCOMPd_a16, opFSUBd_a16, opFSUBRd_a16, opFDIVd_a16, opFDIVRd_a16,
|
opFDIVd_a16, opFDIVRd_a16, opFADDd_a16, opFMULd_a16, opFCOMd_a16, opFCOMPd_a16, opFSUBd_a16,
|
||||||
opFADDd_a16, opFMULd_a16, opFCOMd_a16, opFCOMPd_a16, opFSUBd_a16, opFSUBRd_a16, opFDIVd_a16, opFDIVRd_a16,
|
opFSUBRd_a16, opFDIVd_a16, opFDIVRd_a16, opFADDr, opFMULr, opFCOM, opFCOMP,
|
||||||
opFADDd_a16, opFMULd_a16, opFCOMd_a16, opFCOMPd_a16, opFSUBd_a16, opFSUBRd_a16, opFDIVd_a16, opFDIVRd_a16,
|
opFSUBRr, opFSUBr, opFDIVRr, opFDIVr};
|
||||||
opFADDr, opFMULr, opFCOM, opFCOMP, opFSUBRr, opFSUBr, opFDIVRr, opFDIVr
|
OpFn OP_TABLE(fpu_dc_a32)[32] = {opFADDd_a32, opFMULd_a32, opFCOMd_a32, opFCOMPd_a32, opFSUBd_a32, opFSUBRd_a32, opFDIVd_a32,
|
||||||
};
|
opFDIVRd_a32, opFADDd_a32, opFMULd_a32, opFCOMd_a32, opFCOMPd_a32, opFSUBd_a32, opFSUBRd_a32,
|
||||||
OpFn OP_TABLE(fpu_dc_a32)[32] =
|
opFDIVd_a32, opFDIVRd_a32, opFADDd_a32, opFMULd_a32, opFCOMd_a32, opFCOMPd_a32, opFSUBd_a32,
|
||||||
{
|
opFSUBRd_a32, opFDIVd_a32, opFDIVRd_a32, opFADDr, opFMULr, opFCOM, opFCOMP,
|
||||||
opFADDd_a32, opFMULd_a32, opFCOMd_a32, opFCOMPd_a32, opFSUBd_a32, opFSUBRd_a32, opFDIVd_a32, opFDIVRd_a32,
|
opFSUBRr, opFSUBr, opFDIVRr, opFDIVr};
|
||||||
opFADDd_a32, opFMULd_a32, opFCOMd_a32, opFCOMPd_a32, opFSUBd_a32, opFSUBRd_a32, opFDIVd_a32, opFDIVRd_a32,
|
|
||||||
opFADDd_a32, opFMULd_a32, opFCOMd_a32, opFCOMPd_a32, opFSUBd_a32, opFSUBRd_a32, opFDIVd_a32, opFDIVRd_a32,
|
|
||||||
opFADDr, opFMULr, opFCOM, opFCOMP, opFSUBRr, opFSUBr, opFDIVRr, opFDIVr
|
|
||||||
};
|
|
||||||
|
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_dd_a16)[256] =
|
OpFn OP_TABLE(fpu_dd_a16)[256] = {
|
||||||
{
|
|
||||||
opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16,
|
opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16, opFLDd_a16,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16,
|
opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16, opFSTd_a16,
|
||||||
@@ -789,11 +759,10 @@ OpFn OP_TABLE(fpu_dd_a16)[256] =
|
|||||||
opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP,
|
opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_dd_a32)[256] =
|
OpFn OP_TABLE(fpu_dd_a32)[256] = {
|
||||||
{
|
|
||||||
opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32,
|
opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32, opFLDd_a32,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32,
|
opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32, opFSTd_a32,
|
||||||
@@ -829,12 +798,11 @@ OpFn OP_TABLE(fpu_dd_a32)[256] =
|
|||||||
opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP,
|
opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP, opFUCOMP,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_de_a16)[256] =
|
OpFn OP_TABLE(fpu_de_a16)[256] = {
|
||||||
{
|
|
||||||
opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16,
|
opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16, opFADDiw_a16,
|
||||||
opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16,
|
opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16, opFMULiw_a16,
|
||||||
opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16,
|
opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16, opFCOMiw_a16,
|
||||||
@@ -870,11 +838,10 @@ OpFn OP_TABLE(fpu_de_a16)[256] =
|
|||||||
opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP,
|
opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP,
|
||||||
opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP,
|
opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP,
|
||||||
opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP,
|
opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_de_a32)[256] =
|
OpFn OP_TABLE(fpu_de_a32)[256] = {
|
||||||
{
|
|
||||||
opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32,
|
opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32, opFADDiw_a32,
|
||||||
opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32,
|
opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32, opFMULiw_a32,
|
||||||
opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32,
|
opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32, opFCOMiw_a32,
|
||||||
@@ -910,12 +877,11 @@ OpFn OP_TABLE(fpu_de_a32)[256] =
|
|||||||
opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP,
|
opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP, opFSUBP,
|
||||||
opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP,
|
opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP, opFDIVRP,
|
||||||
opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP,
|
opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP, opFDIVP,
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_df_a16)[256] =
|
OpFn OP_TABLE(fpu_df_a16)[256] = {
|
||||||
{
|
|
||||||
opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16,
|
opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16,
|
opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16,
|
||||||
@@ -951,11 +917,10 @@ OpFn OP_TABLE(fpu_df_a16)[256] =
|
|||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_df_a32)[256] =
|
OpFn OP_TABLE(fpu_df_a32)[256] = {
|
||||||
{
|
|
||||||
opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32,
|
opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32,
|
opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32,
|
||||||
@@ -991,12 +956,11 @@ OpFn OP_TABLE(fpu_df_a32)[256] =
|
|||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a16
|
#define ILLEGAL FPU_ILLEGAL_a16
|
||||||
OpFn OP_TABLE(fpu_686_df_a16)[256] =
|
OpFn OP_TABLE(fpu_686_df_a16)[256] = {
|
||||||
{
|
|
||||||
opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16,
|
opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16, opFILDiw_a16,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16,
|
opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16, opFISTiw_a16,
|
||||||
@@ -1032,11 +996,10 @@ OpFn OP_TABLE(fpu_686_df_a16)[256] =
|
|||||||
opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP,
|
opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP,
|
||||||
opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP,
|
opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
#define ILLEGAL FPU_ILLEGAL_a32
|
#define ILLEGAL FPU_ILLEGAL_a32
|
||||||
OpFn OP_TABLE(fpu_686_df_a32)[256] =
|
OpFn OP_TABLE(fpu_686_df_a32)[256] = {
|
||||||
{
|
|
||||||
opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32,
|
opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32, opFILDiw_a32,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32,
|
opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32, opFISTiw_a32,
|
||||||
@@ -1072,11 +1035,10 @@ OpFn OP_TABLE(fpu_686_df_a32)[256] =
|
|||||||
opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP,
|
opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP, opFUCOMIP,
|
||||||
opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP,
|
opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP, opFCOMIP,
|
||||||
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL, ILLEGAL,
|
||||||
};
|
};
|
||||||
#undef ILLEGAL
|
#undef ILLEGAL
|
||||||
|
|
||||||
OpFn OP_TABLE(nofpu_a16)[256] =
|
OpFn OP_TABLE(nofpu_a16)[256] = {
|
||||||
{
|
|
||||||
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
||||||
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
||||||
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
||||||
@@ -1112,9 +1074,8 @@ OpFn OP_TABLE(nofpu_a16)[256] =
|
|||||||
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
||||||
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
||||||
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16, op_nofpu_a16,
|
||||||
};
|
};
|
||||||
OpFn OP_TABLE(nofpu_a32)[256] =
|
OpFn OP_TABLE(nofpu_a32)[256] = {
|
||||||
{
|
|
||||||
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
||||||
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
||||||
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
||||||
@@ -1150,6 +1111,6 @@ OpFn OP_TABLE(nofpu_a32)[256] =
|
|||||||
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
||||||
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
||||||
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32, op_nofpu_a32,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _X87_OPS_H_ */
|
#endif /* _X87_OPS_H_ */
|
||||||
|
@@ -1,119 +1,125 @@
|
|||||||
#ifndef _X87_OPS_ARITH_H_
|
#ifndef _X87_OPS_ARITH_H_
|
||||||
#define _X87_OPS_ARITH_H_
|
#define _X87_OPS_ARITH_H_
|
||||||
#define opFPU(name, optype, a_size, load_var, get, use_var, cycle_postfix) \
|
#define opFPU(name, optype, a_size, load_var, get, use_var, cycle_postfix) \
|
||||||
static int opFADD ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFADD##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
if ((cpu_state.npxc >> 10) & 3) \
|
if ((cpu_state.npxc >> 10) & 3) \
|
||||||
fesetround(rounding_modes[(cpu_state.npxc >> 10) & 3]); \
|
fesetround(rounding_modes[(cpu_state.npxc >> 10) & 3]); \
|
||||||
ST(0) += use_var; \
|
ST(0) += use_var; \
|
||||||
if ((cpu_state.npxc >> 10) & 3) \
|
if ((cpu_state.npxc >> 10) & 3) \
|
||||||
fesetround(FE_TONEAREST); \
|
fesetround(FE_TONEAREST); \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID; \
|
||||||
CLOCK_CYCLES(x87_timings.fadd ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fadd##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFCOM ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFCOM##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
cpu_state.npxs &= ~(C0|C2|C3); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
cpu_state.npxs &= ~(C0 | C2 | C3); \
|
||||||
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
|
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
|
||||||
CLOCK_CYCLES(x87_timings.fcom ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fcom##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFCOMP ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFCOMP##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
cpu_state.npxs &= ~(C0|C2|C3); \
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
|
cpu_state.npxs &= ~(C0 | C2 | C3); \
|
||||||
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
|
cpu_state.npxs |= x87_compare(ST(0), (double)use_var); \
|
||||||
x87_pop(); \
|
x87_pop(); \
|
||||||
CLOCK_CYCLES(x87_timings.fcom ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fcom##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFDIV ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFDIV##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
x87_div(ST(0), ST(0), use_var); \
|
x87_div(ST(0), ST(0), use_var); \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID; \
|
||||||
CLOCK_CYCLES(x87_timings.fdiv ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fdiv##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFDIVR ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFDIVR##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
x87_div(ST(0), use_var, ST(0)); \
|
x87_div(ST(0), use_var, ST(0)); \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID; \
|
||||||
CLOCK_CYCLES(x87_timings.fdiv ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fdiv##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFMUL ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFMUL##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
ST(0) *= use_var; \
|
ST(0) *= use_var; \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID; \
|
||||||
CLOCK_CYCLES(x87_timings.fmul ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fmul##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFSUB ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFSUB##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
ST(0) -= use_var; \
|
ST(0) -= use_var; \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID; \
|
||||||
CLOCK_CYCLES(x87_timings.fadd ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fadd##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
} \
|
} \
|
||||||
static int opFSUBR ## name ## _a ## a_size(uint32_t fetchdat) \
|
static int opFSUBR##name##_a##a_size(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
optype t; \
|
optype t; \
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
fetch_ea_ ## a_size(fetchdat); \
|
fetch_ea_##a_size(fetchdat); \
|
||||||
SEG_CHECK_READ(cpu_state.ea_seg); \
|
SEG_CHECK_READ(cpu_state.ea_seg); \
|
||||||
load_var = get(); if (cpu_state.abrt) return 1; \
|
load_var = get(); \
|
||||||
|
if (cpu_state.abrt) \
|
||||||
|
return 1; \
|
||||||
ST(0) = use_var - ST(0); \
|
ST(0) = use_var - ST(0); \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = TAG_VALID; \
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID; \
|
||||||
CLOCK_CYCLES(x87_timings.fadd ## cycle_postfix); \
|
CLOCK_CYCLES(x87_timings.fadd##cycle_postfix); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
opFPU(s, x87_ts, 16, t.i, geteal, t.s, _32)
|
opFPU(s, x87_ts, 16, t.i, geteal, t.s, _32) opFPU(s, x87_ts, 32, t.i, geteal, t.s, _32)
|
||||||
opFPU(s, x87_ts, 32, t.i, geteal, t.s, _32)
|
opFPU(d, x87_td, 16, t.i, geteaq, t.d, _64) opFPU(d, x87_td, 32, t.i, geteaq, t.d, _64)
|
||||||
opFPU(d, x87_td, 16, t.i, geteaq, t.d, _64)
|
|
||||||
opFPU(d, x87_td, 32, t.i, geteaq, t.d, _64)
|
|
||||||
|
|
||||||
opFPU(iw, uint16_t, 16, t, geteaw, (double)(int16_t)t, _i16)
|
opFPU(iw, uint16_t, 16, t, geteaw, (double)(int16_t)t, _i16)
|
||||||
opFPU(iw, uint16_t, 32, t, geteaw, (double)(int16_t)t, _i16)
|
opFPU(iw, uint16_t, 32, t, geteaw, (double)(int16_t)t, _i16)
|
||||||
opFPU(il, uint32_t, 16, t, geteal, (double)(int32_t)t, _i32)
|
opFPU(il, uint32_t, 16, t, geteal, (double)(int32_t)t, _i32)
|
||||||
opFPU(il, uint32_t, 32, t, geteal, (double)(int32_t)t, _i32)
|
opFPU(il, uint32_t, 32, t, geteal, (double)(int32_t)t, _i32)
|
||||||
|
|
||||||
static int opFADD(uint32_t fetchdat) {
|
static int opFADD(uint32_t fetchdat) {
|
||||||
FP_ENTER();
|
FP_ENTER();
|
||||||
cpu_state.pc++;
|
cpu_state.pc++;
|
||||||
if (fplog)
|
if (fplog)
|
||||||
|
@@ -41,7 +41,7 @@ static int opFISTiw_a16(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 32767 || temp64 < -32768)
|
/* if (temp64 > 32767 || temp64 < -32768)
|
||||||
fatal("FISTw overflow %i\n", temp64);*/
|
fatal("FISTw overflow %i\n", temp64);*/
|
||||||
seteaw((int16_t)temp64);
|
seteaw((int16_t)temp64);
|
||||||
CLOCK_CYCLES(x87_timings.fist_16);
|
CLOCK_CYCLES(x87_timings.fist_16);
|
||||||
@@ -55,7 +55,7 @@ static int opFISTiw_a32(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 32767 || temp64 < -32768)
|
/* if (temp64 > 32767 || temp64 < -32768)
|
||||||
fatal("FISTw overflow %i\n", temp64);*/
|
fatal("FISTw overflow %i\n", temp64);*/
|
||||||
seteaw((int16_t)temp64);
|
seteaw((int16_t)temp64);
|
||||||
CLOCK_CYCLES(x87_timings.fist_16);
|
CLOCK_CYCLES(x87_timings.fist_16);
|
||||||
@@ -70,7 +70,7 @@ static int opFISTPiw_a16(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 32767 || temp64 < -32768)
|
/* if (temp64 > 32767 || temp64 < -32768)
|
||||||
fatal("FISTw overflow %i\n", temp64);*/
|
fatal("FISTw overflow %i\n", temp64);*/
|
||||||
seteaw((int16_t)temp64);
|
seteaw((int16_t)temp64);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
@@ -87,7 +87,7 @@ static int opFISTPiw_a32(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTw %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 32767 || temp64 < -32768)
|
/* if (temp64 > 32767 || temp64 < -32768)
|
||||||
fatal("FISTw overflow %i\n", temp64);*/
|
fatal("FISTw overflow %i\n", temp64);*/
|
||||||
seteaw((int16_t)temp64);
|
seteaw((int16_t)temp64);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
@@ -108,7 +108,8 @@ static int opFILDiq_a16(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
if (fplog)
|
if (fplog)
|
||||||
pclog(" %f %08X %08X\n", (double)temp64, readmeml(easeg, cpu_state.eaaddr), readmeml(easeg, cpu_state.eaaddr + 4));
|
pclog(" %f %08X %08X\n", (double)temp64, readmeml(easeg, cpu_state.eaaddr),
|
||||||
|
readmeml(easeg, cpu_state.eaaddr + 4));
|
||||||
x87_push((double)temp64);
|
x87_push((double)temp64);
|
||||||
cpu_state.MM[cpu_state.TOP & 7].q = temp64;
|
cpu_state.MM[cpu_state.TOP & 7].q = temp64;
|
||||||
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID | TAG_UINT64;
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID | TAG_UINT64;
|
||||||
@@ -127,7 +128,8 @@ static int opFILDiq_a32(uint32_t fetchdat) {
|
|||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
return 1;
|
return 1;
|
||||||
if (fplog)
|
if (fplog)
|
||||||
pclog(" %f %08X %08X\n", (double)temp64, readmeml(easeg, cpu_state.eaaddr), readmeml(easeg, cpu_state.eaaddr + 4));
|
pclog(" %f %08X %08X\n", (double)temp64, readmeml(easeg, cpu_state.eaaddr),
|
||||||
|
readmeml(easeg, cpu_state.eaaddr + 4));
|
||||||
x87_push((double)temp64);
|
x87_push((double)temp64);
|
||||||
cpu_state.MM[cpu_state.TOP & 7].q = temp64;
|
cpu_state.MM[cpu_state.TOP & 7].q = temp64;
|
||||||
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID | TAG_UINT64;
|
cpu_state.tag[cpu_state.TOP & 7] = TAG_VALID | TAG_UINT64;
|
||||||
@@ -275,7 +277,7 @@ static int opFISTil_a16(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
||||||
fatal("FISTl out of range! %i\n", temp64);*/
|
fatal("FISTl out of range! %i\n", temp64);*/
|
||||||
seteal((int32_t)temp64);
|
seteal((int32_t)temp64);
|
||||||
CLOCK_CYCLES(x87_timings.fist_32);
|
CLOCK_CYCLES(x87_timings.fist_32);
|
||||||
@@ -289,7 +291,7 @@ static int opFISTil_a32(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
||||||
fatal("FISTl out of range! %i\n", temp64);*/
|
fatal("FISTl out of range! %i\n", temp64);*/
|
||||||
seteal((int32_t)temp64);
|
seteal((int32_t)temp64);
|
||||||
CLOCK_CYCLES(x87_timings.fist_32);
|
CLOCK_CYCLES(x87_timings.fist_32);
|
||||||
@@ -304,7 +306,7 @@ static int opFISTPil_a16(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
||||||
fatal("FISTl out of range! %i\n", temp64);*/
|
fatal("FISTl out of range! %i\n", temp64);*/
|
||||||
seteal((int32_t)temp64);
|
seteal((int32_t)temp64);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
@@ -321,7 +323,7 @@ static int opFISTPil_a32(uint32_t fetchdat) {
|
|||||||
if (fplog)
|
if (fplog)
|
||||||
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
pclog("FISTs %08X:%08X\n", easeg, cpu_state.eaaddr);
|
||||||
temp64 = x87_fround(ST(0));
|
temp64 = x87_fround(ST(0));
|
||||||
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
/* if (temp64 > 2147483647 || temp64 < -2147483647)
|
||||||
fatal("FISTl out of range! %i\n", temp64);*/
|
fatal("FISTl out of range! %i\n", temp64);*/
|
||||||
seteal((int32_t)temp64);
|
seteal((int32_t)temp64);
|
||||||
if (cpu_state.abrt)
|
if (cpu_state.abrt)
|
||||||
|
@@ -137,9 +137,10 @@ static int FSTOR() {
|
|||||||
cpu_state.ismmx = 0;
|
cpu_state.ismmx = 0;
|
||||||
/*Horrible hack, but as PCem doesn't keep the FPU stack in 80-bit precision at all times
|
/*Horrible hack, but as PCem doesn't keep the FPU stack in 80-bit precision at all times
|
||||||
something like this is needed*/
|
something like this is needed*/
|
||||||
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff && cpu_state.MM_w4[3] == 0xffff &&
|
if (cpu_state.MM_w4[0] == 0xffff && cpu_state.MM_w4[1] == 0xffff && cpu_state.MM_w4[2] == 0xffff &&
|
||||||
cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff && cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff &&
|
cpu_state.MM_w4[3] == 0xffff && cpu_state.MM_w4[4] == 0xffff && cpu_state.MM_w4[5] == 0xffff &&
|
||||||
!cpu_state.TOP && (*(uint64_t *)cpu_state.tag == 0x0101010101010101ull))
|
cpu_state.MM_w4[6] == 0xffff && cpu_state.MM_w4[7] == 0xffff && !cpu_state.TOP &&
|
||||||
|
(*(uint64_t *)cpu_state.tag == 0x0101010101010101ull))
|
||||||
cpu_state.ismmx = 1;
|
cpu_state.ismmx = 1;
|
||||||
|
|
||||||
CLOCK_CYCLES(x87_timings.frstor);
|
CLOCK_CYCLES(x87_timings.frstor);
|
||||||
@@ -904,31 +905,23 @@ static int opFSTCW_a32(uint32_t fetchdat) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define opFCMOV(condition) \
|
#define opFCMOV(condition) \
|
||||||
static int opFCMOV ## condition(uint32_t fetchdat) \
|
static int opFCMOV##condition(uint32_t fetchdat) { \
|
||||||
{ \
|
|
||||||
FP_ENTER(); \
|
FP_ENTER(); \
|
||||||
cpu_state.pc++; \
|
cpu_state.pc++; \
|
||||||
if (fplog) pclog("FCMOV %f\n", ST(fetchdat & 7)); \
|
if (fplog) \
|
||||||
if (cond_ ## condition) \
|
pclog("FCMOV %f\n", ST(fetchdat & 7)); \
|
||||||
{ \
|
if (cond_##condition) { \
|
||||||
cpu_state.tag[cpu_state.TOP&7] = cpu_state.tag[(cpu_state.TOP + fetchdat) & 7]; \
|
cpu_state.tag[cpu_state.TOP & 7] = cpu_state.tag[(cpu_state.TOP + fetchdat) & 7]; \
|
||||||
cpu_state.MM[cpu_state.TOP&7].q = cpu_state.MM[(cpu_state.TOP + fetchdat) & 7].q; \
|
cpu_state.MM[cpu_state.TOP & 7].q = cpu_state.MM[(cpu_state.TOP + fetchdat) & 7].q; \
|
||||||
ST(0) = ST(fetchdat & 7); \
|
ST(0) = ST(fetchdat & 7); \
|
||||||
} \
|
} \
|
||||||
CLOCK_CYCLES(4); \
|
CLOCK_CYCLES(4); \
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define cond_U ( PF_SET())
|
#define cond_U (PF_SET())
|
||||||
#define cond_NU (!PF_SET())
|
#define cond_NU (!PF_SET())
|
||||||
|
|
||||||
opFCMOV(B)
|
opFCMOV(B) opFCMOV(E) opFCMOV(BE) opFCMOV(U) opFCMOV(NB) opFCMOV(NE) opFCMOV(NBE) opFCMOV(NU)
|
||||||
opFCMOV(E)
|
|
||||||
opFCMOV(BE)
|
|
||||||
opFCMOV(U)
|
|
||||||
opFCMOV(NB)
|
|
||||||
opFCMOV(NE)
|
|
||||||
opFCMOV(NBE)
|
|
||||||
opFCMOV(NU)
|
|
||||||
|
|
||||||
#endif /* _X87_OPS_MISC_H_ */
|
#endif /* _X87_OPS_MISC_H_ */
|
||||||
|
@@ -32,5 +32,4 @@ void cassette_load(const char *filename);
|
|||||||
|
|
||||||
extern char cassettefn[256];
|
extern char cassettefn[256];
|
||||||
|
|
||||||
|
|
||||||
#endif /* _CASSETTE_H_ */
|
#endif /* _CASSETTE_H_ */
|
||||||
|
@@ -2,5 +2,4 @@
|
|||||||
#define _ESDI_AT_H_
|
#define _ESDI_AT_H_
|
||||||
extern device_t wd1007vse1_device;
|
extern device_t wd1007vse1_device;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _ESDI_AT_H_ */
|
#endif /* _ESDI_AT_H_ */
|
||||||
|
@@ -6,6 +6,4 @@ void upc_set_mouse(void (*mouse_write)(uint8_t val, void *p), void *p);
|
|||||||
|
|
||||||
extern device_t f82c710_upc_device;
|
extern device_t f82c710_upc_device;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _F82C710_UPC_H_ */
|
#endif /* _F82C710_UPC_H_ */
|
||||||
|
@@ -17,5 +17,4 @@ extern uint8_t nvrram[128];
|
|||||||
extern int nvrmask;
|
extern int nvrmask;
|
||||||
extern int oldromset;
|
extern int oldromset;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NVR_H_ */
|
#endif /* _NVR_H_ */
|
||||||
|
@@ -13,5 +13,4 @@ void tc8521_nvr_recalc();
|
|||||||
|
|
||||||
FILE *nvrfopen(char *fn, char *mode);
|
FILE *nvrfopen(char *fn, char *mode);
|
||||||
|
|
||||||
|
|
||||||
#endif /* _NVR_TC8521_H_ */
|
#endif /* _NVR_TC8521_H_ */
|
||||||
|
@@ -2,5 +2,4 @@
|
|||||||
#define _PS2_NVR_H_
|
#define _PS2_NVR_H_
|
||||||
extern device_t ps2_nvr_device;
|
extern device_t ps2_nvr_device;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _PS2_NVR_H_ */
|
#endif /* _PS2_NVR_H_ */
|
||||||
|
@@ -2,5 +2,4 @@
|
|||||||
#define _SIS496_H_
|
#define _SIS496_H_
|
||||||
extern device_t sis496_device;
|
extern device_t sis496_device;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _SIS496_H_ */
|
#endif /* _SIS496_H_ */
|
||||||
|
@@ -52,7 +52,7 @@ extern int motorspin;
|
|||||||
extern int motoron;
|
extern int motoron;
|
||||||
|
|
||||||
extern int defaultwriteprot;
|
extern int defaultwriteprot;
|
||||||
//extern char discfns[4][260];
|
// extern char discfns[4][260];
|
||||||
|
|
||||||
extern int writeprot[2], fwriteprot[2];
|
extern int writeprot[2], fwriteprot[2];
|
||||||
extern int disc_track[2];
|
extern int disc_track[2];
|
||||||
|
@@ -52,16 +52,16 @@ typedef size_t PhysPt;
|
|||||||
#define AUDIO_TRACK 0x10
|
#define AUDIO_TRACK 0x10
|
||||||
|
|
||||||
#define CD_FPS 75
|
#define CD_FPS 75
|
||||||
#define FRAMES_TO_MSF(f, M,S,F) { \
|
#define FRAMES_TO_MSF(f, M, S, F) \
|
||||||
|
{ \
|
||||||
int value = f; \
|
int value = f; \
|
||||||
*(F) = value%CD_FPS; \
|
*(F) = value % CD_FPS; \
|
||||||
value /= CD_FPS; \
|
value /= CD_FPS; \
|
||||||
*(S) = value%60; \
|
*(S) = value % 60; \
|
||||||
value /= 60; \
|
value /= 60; \
|
||||||
*(M) = value; \
|
*(M) = value; \
|
||||||
}
|
}
|
||||||
#define MSF_TO_FRAMES(M, S, F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))
|
#define MSF_TO_FRAMES(M, S, F) ((M)*60 * CD_FPS + (S)*CD_FPS + (F))
|
||||||
|
|
||||||
|
|
||||||
typedef struct SMSF {
|
typedef struct SMSF {
|
||||||
unsigned char min;
|
unsigned char min;
|
||||||
@@ -74,38 +74,37 @@ typedef struct SCtrl {
|
|||||||
Bit8u vol[4]; // channel volume
|
Bit8u vol[4]; // channel volume
|
||||||
} TCtrl;
|
} TCtrl;
|
||||||
|
|
||||||
extern int CDROM_GetMountType(char* path, int force);
|
extern int CDROM_GetMountType(char *path, int force);
|
||||||
|
|
||||||
class CDROM_Interface
|
class CDROM_Interface {
|
||||||
{
|
public:
|
||||||
public:
|
// CDROM_Interface (void);
|
||||||
// CDROM_Interface (void);
|
virtual ~CDROM_Interface(void){};
|
||||||
virtual ~CDROM_Interface (void) {};
|
|
||||||
|
|
||||||
virtual bool SetDevice (char* path, int forceCD) = 0;
|
virtual bool SetDevice(char *path, int forceCD) = 0;
|
||||||
|
|
||||||
virtual bool GetUPC (unsigned char& attr, char* upc) = 0;
|
virtual bool GetUPC(unsigned char &attr, char *upc) = 0;
|
||||||
|
|
||||||
virtual bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut) = 0;
|
virtual bool GetAudioTracks(int &stTrack, int &end, TMSF &leadOut) = 0;
|
||||||
virtual bool GetAudioTrackInfo (int track, int& number, TMSF& start, unsigned char& attr) = 0;
|
virtual bool GetAudioTrackInfo(int track, int &number, TMSF &start, unsigned char &attr) = 0;
|
||||||
virtual bool GetAudioSub (int sector, unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos) = 0;
|
virtual bool GetAudioSub(int sector, unsigned char &attr, unsigned char &track, unsigned char &index, TMSF &relPos,
|
||||||
virtual bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen) = 0;
|
TMSF &absPos) = 0;
|
||||||
|
virtual bool GetMediaTrayStatus(bool &mediaPresent, bool &mediaChanged, bool &trayOpen) = 0;
|
||||||
|
|
||||||
virtual bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num) = 0;
|
virtual bool ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num) = 0;
|
||||||
|
|
||||||
virtual bool LoadUnloadMedia (bool unload) = 0;
|
virtual bool LoadUnloadMedia(bool unload) = 0;
|
||||||
|
|
||||||
virtual void InitNewMedia (void) {};
|
virtual void InitNewMedia(void){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class CDROM_Interface_Image : public CDROM_Interface
|
class CDROM_Interface_Image : public CDROM_Interface {
|
||||||
{
|
private:
|
||||||
private:
|
|
||||||
class TrackFile {
|
class TrackFile {
|
||||||
public:
|
public:
|
||||||
virtual bool read(Bit8u *buffer, int seek, int count) = 0;
|
virtual bool read(Bit8u *buffer, int seek, int count) = 0;
|
||||||
virtual int getLength() = 0;
|
virtual int getLength() = 0;
|
||||||
virtual ~TrackFile() { };
|
virtual ~TrackFile(){};
|
||||||
};
|
};
|
||||||
|
|
||||||
class BinaryFile : public TrackFile {
|
class BinaryFile : public TrackFile {
|
||||||
@@ -114,6 +113,7 @@ private:
|
|||||||
~BinaryFile();
|
~BinaryFile();
|
||||||
bool read(Bit8u *buffer, int seek, int count);
|
bool read(Bit8u *buffer, int seek, int count);
|
||||||
int getLength();
|
int getLength();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BinaryFile();
|
BinaryFile();
|
||||||
std::ifstream *file;
|
std::ifstream *file;
|
||||||
@@ -131,41 +131,41 @@ private:
|
|||||||
TrackFile *file;
|
TrackFile *file;
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CDROM_Interface_Image ();
|
CDROM_Interface_Image();
|
||||||
virtual ~CDROM_Interface_Image (void);
|
virtual ~CDROM_Interface_Image(void);
|
||||||
void InitNewMedia (void);
|
void InitNewMedia(void);
|
||||||
bool SetDevice (char* path, int forceCD);
|
bool SetDevice(char *path, int forceCD);
|
||||||
bool GetUPC (unsigned char& attr, char* upc);
|
bool GetUPC(unsigned char &attr, char *upc);
|
||||||
bool GetAudioTracks (int& stTrack, int& end, TMSF& leadOut);
|
bool GetAudioTracks(int &stTrack, int &end, TMSF &leadOut);
|
||||||
bool GetAudioTrackInfo (int track, int& number, TMSF& start, unsigned char& attr);
|
bool GetAudioTrackInfo(int track, int &number, TMSF &start, unsigned char &attr);
|
||||||
bool GetAudioSub (int sector, unsigned char& attr, unsigned char& track, unsigned char& index, TMSF& relPos, TMSF& absPos);
|
bool GetAudioSub(int sector, unsigned char &attr, unsigned char &track, unsigned char &index, TMSF &relPos, TMSF &absPos);
|
||||||
bool GetMediaTrayStatus (bool& mediaPresent, bool& mediaChanged, bool& trayOpen);
|
bool GetMediaTrayStatus(bool &mediaPresent, bool &mediaChanged, bool &trayOpen);
|
||||||
bool ReadSectors (PhysPt buffer, bool raw, unsigned long sector, unsigned long num);
|
bool ReadSectors(PhysPt buffer, bool raw, unsigned long sector, unsigned long num);
|
||||||
bool LoadUnloadMedia (bool unload);
|
bool LoadUnloadMedia(bool unload);
|
||||||
bool ReadSector (Bit8u *buffer, bool raw, unsigned long sector);
|
bool ReadSector(Bit8u *buffer, bool raw, unsigned long sector);
|
||||||
bool HasDataTrack (void);
|
bool HasDataTrack(void);
|
||||||
bool HasAudioTracks (void);
|
bool HasAudioTracks(void);
|
||||||
|
|
||||||
int GetTrack (int sector);
|
int GetTrack(int sector);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// player
|
// player
|
||||||
static void CDAudioCallBack(Bitu len);
|
static void CDAudioCallBack(Bitu len);
|
||||||
|
|
||||||
void ClearTracks();
|
void ClearTracks();
|
||||||
bool LoadIsoFile(char *filename);
|
bool LoadIsoFile(char *filename);
|
||||||
bool CanReadPVD(TrackFile *file, int sectorSize, bool mode2);
|
bool CanReadPVD(TrackFile *file, int sectorSize, bool mode2);
|
||||||
// cue sheet processing
|
// cue sheet processing
|
||||||
bool LoadCueSheet(char *cuefile);
|
bool LoadCueSheet(char *cuefile);
|
||||||
bool GetRealFileName(std::string& filename, std::string& pathname);
|
bool GetRealFileName(std::string &filename, std::string &pathname);
|
||||||
bool GetCueKeyword(std::string &keyword, std::istream &in);
|
bool GetCueKeyword(std::string &keyword, std::istream &in);
|
||||||
bool GetCueFrame(int &frames, std::istream &in);
|
bool GetCueFrame(int &frames, std::istream &in);
|
||||||
bool GetCueString(std::string &str, std::istream &in);
|
bool GetCueString(std::string &str, std::istream &in);
|
||||||
bool AddTrack(Track &curr, int &shift, int prestart, int &totalPregap, int currPregap);
|
bool AddTrack(Track &curr, int &shift, int prestart, int &totalPregap, int currPregap);
|
||||||
|
|
||||||
std::vector<Track> tracks;
|
std::vector<Track> tracks;
|
||||||
typedef std::vector<Track>::iterator track_it;
|
typedef std::vector<Track>::iterator track_it;
|
||||||
std::string mcn;
|
std::string mcn;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user