synchronize with fellow cpu update.

- edge-case fixes for bcd ops
- tweak division by 0 exception a bit
- clean up includes
This commit is contained in:
Kelvin Sherlock 2016-05-16 13:45:32 -04:00
parent f79e74c510
commit 5976f91a89
16 changed files with 135 additions and 209 deletions

View File

@ -1,8 +1,6 @@
#ifndef CpuIntegration_H #ifndef CpuIntegration_H
#define CpuIntegration_H #define CpuIntegration_H
#include <setjmp.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
@ -16,6 +14,8 @@ typedef enum {
M68EC20 = 9 M68EC20 = 9
} cpu_integration_models; } cpu_integration_models;
extern void cpuIntegrationCalculateMultiplier(void);
extern void cpuIntegrationSetUpInterruptEventHandler(void); extern void cpuIntegrationSetUpInterruptEventHandler(void);
extern void cpuIntegrationExecuteInstructionEventHandler68000Fast(void); extern void cpuIntegrationExecuteInstructionEventHandler68000Fast(void);
extern void cpuIntegrationExecuteInstructionEventHandler68000General(void); extern void cpuIntegrationExecuteInstructionEventHandler68000General(void);

View File

@ -24,8 +24,7 @@
#include "defs.h" #include "defs.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"
void cpuClearEverything(void) void cpuClearEverything(void)

View File

@ -18,7 +18,7 @@ extern void cpuSetFLineExceptionFunc(cpuLineExceptionFunc func);
typedef BOOLE (*cpuCheckPendingInterruptsFunc)(void); typedef BOOLE (*cpuCheckPendingInterruptsFunc)(void);
extern void cpuSetCheckPendingInterruptsFunc(cpuCheckPendingInterruptsFunc func); extern void cpuSetCheckPendingInterruptsFunc(cpuCheckPendingInterruptsFunc func);
extern void cpuCheckPendingInterrupts(void); extern void cpuCheckPendingInterrupts(void);
void cpuSetUpInterrupt(ULO new_interrupt_level); extern void cpuSetUpInterrupt(ULO new_interrupt_level);
extern void cpuInitializeFromNewPC(ULO new_pc); extern void cpuInitializeFromNewPC(ULO new_pc);
@ -77,12 +77,9 @@ extern ULO cpuGetInitialSP(void);
extern ULO cpuGetInstructionTime(void); extern ULO cpuGetInstructionTime(void);
extern BOOLE cpuSetIrqLevel(ULO new_interrupt_level); extern BOOLE cpuSetIrqLevel(ULO irq_level);
extern ULO cpuGetIrqLevel(void); extern ULO cpuGetIrqLevel(void);
extern void cpuSetIrqAddress(ULO irq_address);
extern ULO cpuGetIrqAddress(void);
extern ULO cpuExecuteInstruction(void); extern ULO cpuExecuteInstruction(void);
extern ULO cpuDisOpcode(ULO disasm_pc, STR *saddress, STR *sdata, STR *sinstruction, STR *soperands); extern ULO cpuDisOpcode(ULO disasm_pc, STR *saddress, STR *sdata, STR *sinstruction, STR *soperands);

View File

@ -5590,254 +5590,199 @@ static void DIVS_81C0(ULO*opc_data)
{ {
UWO src = cpuGetDRegWord(opc_data[0]); UWO src = cpuGetDRegWord(opc_data[0]);
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81D0(ULO*opc_data) static void DIVS_81D0(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA02(opc_data[0])); UWO src = memoryReadWord(cpuEA02(opc_data[0]));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81D8(ULO*opc_data) static void DIVS_81D8(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA03(opc_data[0],2)); UWO src = memoryReadWord(cpuEA03(opc_data[0],2));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81E0(ULO*opc_data) static void DIVS_81E0(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA04(opc_data[0],2)); UWO src = memoryReadWord(cpuEA04(opc_data[0],2));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81E8(ULO*opc_data) static void DIVS_81E8(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA05(opc_data[0])); UWO src = memoryReadWord(cpuEA05(opc_data[0]));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81F0(ULO*opc_data) static void DIVS_81F0(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA06(opc_data[0])); UWO src = memoryReadWord(cpuEA06(opc_data[0]));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81F8(ULO*opc_data) static void DIVS_81F8(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA70()); UWO src = memoryReadWord(cpuEA70());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81F9(ULO*opc_data) static void DIVS_81F9(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA71()); UWO src = memoryReadWord(cpuEA71());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81FA(ULO*opc_data) static void DIVS_81FA(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA72()); UWO src = memoryReadWord(cpuEA72());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81FB(ULO*opc_data) static void DIVS_81FB(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA73()); UWO src = memoryReadWord(cpuEA73());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVS_81FC(ULO*opc_data) static void DIVS_81FC(ULO*opc_data)
{ {
UWO src = cpuGetNextWord(); UWO src = cpuGetNextWord();
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivsW(dst, src); cpuDivsW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C40(ULO*opc_data) static void DIVL_4C40(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = cpuGetDReg(opc_data[0]); ULO src = cpuGetDReg(opc_data[0]);
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C50(ULO*opc_data) static void DIVL_4C50(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA02(opc_data[0])); ULO src = memoryReadLong(cpuEA02(opc_data[0]));
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C58(ULO*opc_data) static void DIVL_4C58(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA03(opc_data[0],4)); ULO src = memoryReadLong(cpuEA03(opc_data[0],4));
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C60(ULO*opc_data) static void DIVL_4C60(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA04(opc_data[0],4)); ULO src = memoryReadLong(cpuEA04(opc_data[0],4));
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C68(ULO*opc_data) static void DIVL_4C68(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA05(opc_data[0])); ULO src = memoryReadLong(cpuEA05(opc_data[0]));
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C70(ULO*opc_data) static void DIVL_4C70(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA06(opc_data[0])); ULO src = memoryReadLong(cpuEA06(opc_data[0]));
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C78(ULO*opc_data) static void DIVL_4C78(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA70()); ULO src = memoryReadLong(cpuEA70());
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C79(ULO*opc_data) static void DIVL_4C79(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA71()); ULO src = memoryReadLong(cpuEA71());
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C7A(ULO*opc_data) static void DIVL_4C7A(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA72()); ULO src = memoryReadLong(cpuEA72());
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C7B(ULO*opc_data) static void DIVL_4C7B(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = memoryReadLong(cpuEA73()); ULO src = memoryReadLong(cpuEA73());
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVL_4C7C(ULO*opc_data) static void DIVL_4C7C(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
ULO src = cpuGetNextLong(); ULO src = cpuGetNextLong();
cpuDivL(src, ext); cpuDivL(src, ext, opc_data[2]);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80C0(ULO*opc_data) static void DIVU_80C0(ULO*opc_data)
{ {
UWO src = cpuGetDRegWord(opc_data[0]); UWO src = cpuGetDRegWord(opc_data[0]);
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80D0(ULO*opc_data) static void DIVU_80D0(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA02(opc_data[0])); UWO src = memoryReadWord(cpuEA02(opc_data[0]));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80D8(ULO*opc_data) static void DIVU_80D8(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA03(opc_data[0],2)); UWO src = memoryReadWord(cpuEA03(opc_data[0],2));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80E0(ULO*opc_data) static void DIVU_80E0(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA04(opc_data[0],2)); UWO src = memoryReadWord(cpuEA04(opc_data[0],2));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80E8(ULO*opc_data) static void DIVU_80E8(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA05(opc_data[0])); UWO src = memoryReadWord(cpuEA05(opc_data[0]));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80F0(ULO*opc_data) static void DIVU_80F0(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA06(opc_data[0])); UWO src = memoryReadWord(cpuEA06(opc_data[0]));
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80F8(ULO*opc_data) static void DIVU_80F8(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA70()); UWO src = memoryReadWord(cpuEA70());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80F9(ULO*opc_data) static void DIVU_80F9(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA71()); UWO src = memoryReadWord(cpuEA71());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80FA(ULO*opc_data) static void DIVU_80FA(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA72()); UWO src = memoryReadWord(cpuEA72());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80FB(ULO*opc_data) static void DIVU_80FB(ULO*opc_data)
{ {
UWO src = memoryReadWord(cpuEA73()); UWO src = memoryReadWord(cpuEA73());
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void DIVU_80FC(ULO*opc_data) static void DIVU_80FC(ULO*opc_data)
{ {
UWO src = cpuGetNextWord(); UWO src = cpuGetNextWord();
ULO dst = cpuGetDReg(opc_data[1]); ULO dst = cpuGetDReg(opc_data[1]);
ULO res = cpuDivuW(dst, src); cpuDivuW(dst, src, opc_data[1], opc_data[2]);
cpuSetDReg(opc_data[1], res);
cpuSetInstructionTime(opc_data[2]);
} }
static void MOVEM_48A0(ULO*opc_data) static void MOVEM_48A0(ULO*opc_data)
{ {
@ -6483,42 +6428,42 @@ static void BFTST_E8FB(ULO*opc_data)
static void BFCHG_EAC0(ULO*opc_data) static void BFCHG_EAC0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfChgReg(opc_data[1], ext); cpuBfChgReg(opc_data[0], ext);
} }
static void BFCLR_ECC0(ULO*opc_data) static void BFCLR_ECC0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfClrReg(opc_data[1], ext); cpuBfClrReg(opc_data[0], ext);
} }
static void BFEXTS_EBC0(ULO*opc_data) static void BFEXTS_EBC0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfExtsReg(opc_data[1], ext); cpuBfExtsReg(opc_data[0], ext);
} }
static void BFEXTU_E9C0(ULO*opc_data) static void BFEXTU_E9C0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfExtuReg(opc_data[1], ext); cpuBfExtuReg(opc_data[0], ext);
} }
static void BFFFO_EDC0(ULO*opc_data) static void BFFFO_EDC0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfFfoReg(opc_data[1], ext); cpuBfFfoReg(opc_data[0], ext);
} }
static void BFINS_EFC0(ULO*opc_data) static void BFINS_EFC0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfInsReg(opc_data[1], ext); cpuBfInsReg(opc_data[0], ext);
} }
static void BFSET_EEC0(ULO*opc_data) static void BFSET_EEC0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfSetReg(opc_data[1], ext); cpuBfSetReg(opc_data[0], ext);
} }
static void BFTST_E8C0(ULO*opc_data) static void BFTST_E8C0(ULO*opc_data)
{ {
UWO ext = cpuGetNextWord(); UWO ext = cpuGetNextWord();
cpuBfTstReg(opc_data[1], ext); cpuBfTstReg(opc_data[0], ext);
} }
static void MULL_4C00(ULO*opc_data) static void MULL_4C00(ULO*opc_data)
{ {
@ -7347,6 +7292,7 @@ static void TAS_4AC0(ULO*opc_data)
UBY dst = cpuGetDRegByte(opc_data[0]); UBY dst = cpuGetDRegByte(opc_data[0]);
dst = cpuTas(dst); dst = cpuTas(dst);
cpuSetDRegByte(opc_data[0], dst); cpuSetDRegByte(opc_data[0], dst);
cpuSetInstructionTime(4);
} }
static void TAS_4AD0(ULO*opc_data) static void TAS_4AD0(ULO*opc_data)
{ {
@ -7354,6 +7300,7 @@ static void TAS_4AD0(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(14);
} }
static void TAS_4AD8(ULO*opc_data) static void TAS_4AD8(ULO*opc_data)
{ {
@ -7361,6 +7308,7 @@ static void TAS_4AD8(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(14);
} }
static void TAS_4AE0(ULO*opc_data) static void TAS_4AE0(ULO*opc_data)
{ {
@ -7368,6 +7316,7 @@ static void TAS_4AE0(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(16);
} }
static void TAS_4AE8(ULO*opc_data) static void TAS_4AE8(ULO*opc_data)
{ {
@ -7375,6 +7324,7 @@ static void TAS_4AE8(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(18);
} }
static void TAS_4AF0(ULO*opc_data) static void TAS_4AF0(ULO*opc_data)
{ {
@ -7382,6 +7332,7 @@ static void TAS_4AF0(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(20);
} }
static void TAS_4AF8(ULO*opc_data) static void TAS_4AF8(ULO*opc_data)
{ {
@ -7389,6 +7340,7 @@ static void TAS_4AF8(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(18);
} }
static void TAS_4AF9(ULO*opc_data) static void TAS_4AF9(ULO*opc_data)
{ {
@ -7396,6 +7348,7 @@ static void TAS_4AF9(ULO*opc_data)
UBY dst = memoryReadByte(dstea); UBY dst = memoryReadByte(dstea);
dst = cpuTas(dst); dst = cpuTas(dst);
memoryWriteByte(dst, dstea); memoryWriteByte(dst, dstea);
cpuSetInstructionTime(22);
} }
static void TST_4A00(ULO*opc_data) static void TST_4A00(ULO*opc_data)
{ {
@ -7638,43 +7591,43 @@ static void PEA_4850(ULO*opc_data)
{ {
ULO dstea = cpuEA02(opc_data[0]); ULO dstea = cpuEA02(opc_data[0]);
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(8); cpuSetInstructionTime(12);
} }
static void PEA_4868(ULO*opc_data) static void PEA_4868(ULO*opc_data)
{ {
ULO dstea = cpuEA05(opc_data[0]); ULO dstea = cpuEA05(opc_data[0]);
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(10); cpuSetInstructionTime(16);
} }
static void PEA_4870(ULO*opc_data) static void PEA_4870(ULO*opc_data)
{ {
ULO dstea = cpuEA06(opc_data[0]); ULO dstea = cpuEA06(opc_data[0]);
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(14); cpuSetInstructionTime(20);
} }
static void PEA_4878(ULO*opc_data) static void PEA_4878(ULO*opc_data)
{ {
ULO dstea = cpuEA70(); ULO dstea = cpuEA70();
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(10); cpuSetInstructionTime(16);
} }
static void PEA_4879(ULO*opc_data) static void PEA_4879(ULO*opc_data)
{ {
ULO dstea = cpuEA71(); ULO dstea = cpuEA71();
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(12); cpuSetInstructionTime(20);
} }
static void PEA_487A(ULO*opc_data) static void PEA_487A(ULO*opc_data)
{ {
ULO dstea = cpuEA72(); ULO dstea = cpuEA72();
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(10); cpuSetInstructionTime(16);
} }
static void PEA_487B(ULO*opc_data) static void PEA_487B(ULO*opc_data)
{ {
ULO dstea = cpuEA73(); ULO dstea = cpuEA73();
cpuPeaL(dstea); cpuPeaL(dstea);
cpuSetInstructionTime(14); cpuSetInstructionTime(20);
} }
static void JMP_4ED0(ULO*opc_data) static void JMP_4ED0(ULO*opc_data)
{ {

View File

@ -23,7 +23,7 @@
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fmem.h" #include "CpuModule_Memory.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_DisassemblerFunc.h" #include "CpuModule_DisassemblerFunc.h"

View File

@ -24,8 +24,7 @@
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"

View File

@ -24,8 +24,7 @@
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"
@ -194,10 +193,10 @@ void cpuThrowTrapVException(void)
cpuThrowException(0x1c, cpuGetPC(), FALSE); cpuThrowException(0x1c, cpuGetPC(), FALSE);
} }
void cpuThrowDivisionByZeroException(BOOLE executejmp) void cpuThrowDivisionByZeroException()
{ {
// The saved pc points to the next instruction, which is now in pc // The saved pc points to the next instruction, which is now in pc
cpuThrowException(0x14, cpuGetPC(), executejmp); cpuThrowException(0x14, cpuGetPC(), FALSE);
} }
void cpuThrowTrapException(ULO vector_no) void cpuThrowTrapException(ULO vector_no)

View File

@ -22,7 +22,6 @@
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"
@ -195,7 +194,7 @@ void cpuSetFlags0100(void)
/// <summary> /// <summary>
/// Clear V and C. /// Clear V and C.
/// </summary> /// </summary>
static void cpuClearFlagsVC(void) void cpuClearFlagsVC(void)
{ {
cpu_sr = cpu_sr & 0xfffc; cpu_sr = cpu_sr & 0xfffc;
} }

View File

@ -24,16 +24,10 @@
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"
#ifdef UAE_FILESYS
#include "uae2fell.h"
#include "autoconf.h"
#endif
static cpuLineExceptionFunc cpu_a_line_exception_func = NULL; static cpuLineExceptionFunc cpu_a_line_exception_func = NULL;
static cpuLineExceptionFunc cpu_f_line_exception_func = NULL; static cpuLineExceptionFunc cpu_f_line_exception_func = NULL;
@ -168,24 +162,21 @@ static void cpuIllegal(void)
} }
else if ((opcode & 0xa000) == 0xa000) else if ((opcode & 0xa000) == 0xa000)
{ {
#if 0
/*
#ifdef UAE_FILESYS
if ((cpuGetPC() & 0xff0000) == 0xf00000) if ((cpuGetPC() & 0xff0000) == 0xf00000)
{ {
call_calltrap(opcode & 0xfff); call_calltrap(opcode & 0xfff);
cpuInitializeFromNewPC(cpuGetPC()); cpuInitializeFromNewPC(cpuGetPC());
cpuSetInstructionTime(512); cpuSetInstructionTime(512);
} }
else #else
#endif
*/
if (cpu_a_line_exception_func) if (cpu_a_line_exception_func)
{ {
cpu_a_line_exception_func(opcode); cpu_a_line_exception_func(opcode);
cpuInitializeFromNewPC(cpuGetPC()); cpuInitializeFromNewPC(cpuGetPC());
cpuSetInstructionTime(512); cpuSetInstructionTime(512);
} }
#endif
else else
{ {
cpuThrowALineException(); cpuThrowALineException();
@ -1162,17 +1153,16 @@ static ULO cpuMuluW(UWO src2, UWO src1, ULO eatime)
/// <summary> /// <summary>
/// Divsw, src1 / src2 /// Divsw, src1 / src2
/// </summary> /// </summary>
static ULO cpuDivsW(ULO dst, UWO src1) static void cpuDivsW(ULO dst, UWO src1, ULO destination_reg, ULO instruction_time)
{ {
ULO result;
if (src1 == 0) if (src1 == 0)
{ {
// Alcatraz odyssey assumes that PC in this exception points after the instruction. // Alcatraz odyssey assumes that PC in this exception points after the instruction.
cpuThrowDivisionByZeroException(TRUE); cpuThrowDivisionByZeroException();
result = dst;
} }
else else
{ {
ULO result;
LON x = (LON) dst; LON x = (LON) dst;
LON y = (LON)(WOR) src1; LON y = (LON)(WOR) src1;
LON res = x / y; LON res = x / y;
@ -1187,24 +1177,24 @@ static ULO cpuDivsW(ULO dst, UWO src1)
result = (rem << 16) | (res & 0xffff); result = (rem << 16) | (res & 0xffff);
cpuSetFlagsNZVC(cpuIsZeroW((UWO) res), cpuMsbW((UWO) res), FALSE, FALSE); cpuSetFlagsNZVC(cpuIsZeroW((UWO) res), cpuMsbW((UWO) res), FALSE, FALSE);
} }
cpuSetDReg(destination_reg, result);
cpuSetInstructionTime(instruction_time);
} }
return result;
} }
/// <summary> /// <summary>
/// Divuw, src1 / src2 /// Divuw, src1 / src2
/// </summary> /// </summary>
static ULO cpuDivuW(ULO dst, UWO src1) static void cpuDivuW(ULO dst, UWO src1, ULO destination_reg, ULO instruction_time)
{ {
ULO result;
if (src1 == 0) if (src1 == 0)
{ {
// Alcatraz odyssey assumes that PC in this exception points after the instruction. // Alcatraz odyssey assumes that PC in this exception points after the instruction.
cpuThrowDivisionByZeroException(TRUE); cpuThrowDivisionByZeroException();
result = dst;
} }
else else
{ {
ULO result;
ULO x = dst; ULO x = dst;
ULO y = (ULO) src1; ULO y = (ULO) src1;
ULO res = x / y; ULO res = x / y;
@ -1219,11 +1209,12 @@ static ULO cpuDivuW(ULO dst, UWO src1)
result = (rem << 16) | (res & 0xffff); result = (rem << 16) | (res & 0xffff);
cpuSetFlagsNZVC(cpuIsZeroW((UWO) res), cpuMsbW((UWO) res), FALSE, FALSE); cpuSetFlagsNZVC(cpuIsZeroW((UWO) res), cpuMsbW((UWO) res), FALSE, FALSE);
} }
cpuSetDReg(destination_reg, result);
cpuSetInstructionTime(instruction_time);
} }
return result;
} }
static void cpuDivL(ULO divisor, ULO ext) static void cpuDivL(ULO divisor, ULO ext, ULO instruction_time)
{ {
if (divisor != 0) if (divisor != 0)
{ {
@ -1296,10 +1287,11 @@ static void cpuDivL(ULO divisor, ULO ext)
cpuSetFlagsNZ00NewL((ULO) result); cpuSetFlagsNZ00NewL((ULO) result);
} }
} }
cpuSetInstructionTime(instruction_time);
} }
else else
{ {
cpuThrowDivisionByZeroException(FALSE); cpuThrowDivisionByZeroException();
} }
} }
@ -2462,7 +2454,7 @@ static void cpuCmpML(ULO regx, ULO regy)
static void cpuChkW(UWO value, UWO ub) static void cpuChkW(UWO value, UWO ub)
{ {
cpuSetFlagZ(value == 0); cpuSetFlagZ(value == 0);
cpuSetFlagsVC(FALSE, FALSE); cpuClearFlagsVC();
if (((WOR)value) < 0) if (((WOR)value) < 0)
{ {
cpuSetFlagN(TRUE); cpuSetFlagN(TRUE);
@ -2485,7 +2477,7 @@ static void cpuChkW(UWO value, UWO ub)
static void cpuChkL(ULO value, ULO ub) static void cpuChkL(ULO value, ULO ub)
{ {
cpuSetFlagZ(value == 0); cpuSetFlagZ(value == 0);
cpuSetFlagsVC(FALSE, FALSE); cpuClearFlagsVC();
if (((LON)value) < 0) if (((LON)value) < 0)
{ {
cpuSetFlagN(TRUE); cpuSetFlagN(TRUE);
@ -2567,39 +2559,35 @@ static ULO cpuSubXL(ULO dst, ULO src)
/// </summary> /// </summary>
static UBY cpuAbcdB(UBY dst, UBY src) static UBY cpuAbcdB(UBY dst, UBY src)
{ {
UBY xflag = (cpuGetFlagX()) ? 1:0; UBY xflag = (cpuGetFlagX()) ? 1 : 0;
UWO res = dst + src + xflag; UWO low_nibble = (dst & 0xf) + (src & 0xf) + xflag;
UWO res_unadjusted = res; UWO high_nibble = ((UWO)(dst & 0xf0)) + ((UWO)(src & 0xf0));
UBY res_bcd; UWO result_unadjusted = low_nibble + high_nibble;
UBY low_nibble = (dst & 0xf) + (src & 0xf) + xflag; UWO result_bcd = result_unadjusted;
if (low_nibble > 9) if (low_nibble > 9)
{ {
res += 6; result_bcd += 6;
} }
if (res > 0x99) BOOLE xc_flags = (result_bcd & 0xfff0) > 0x90;
cpuSetFlagXC(xc_flags);
if (xc_flags)
{ {
res += 0x60; result_bcd += 0x60;
cpuSetFlagXC(TRUE);
}
else
{
cpuSetFlagXC(FALSE);
} }
res_bcd = (UBY) res; if (result_bcd & 0xff)
if (res_bcd != 0)
{ {
cpuSetFlagZ(FALSE); cpuSetFlagZ(FALSE);
} }
if (res_bcd & 0x80)
if (cpuGetModelMajor() < 4) // 040 apparently does not set these flags
{ {
cpuSetFlagN(TRUE); cpuSetFlagN(result_bcd & 0x80);
cpuSetFlagV(((result_unadjusted & 0x80) == 0) && (result_bcd & 0x80));
} }
cpuSetFlagV(((res_unadjusted & 0x80) == 0) && (res_bcd & 0x80)); return (UBY)result_bcd;
return res_bcd;
} }
/// <summary> /// <summary>
@ -2612,36 +2600,38 @@ static UBY cpuAbcdB(UBY dst, UBY src)
/// </summary> /// </summary>
static UBY cpuSbcdB(UBY dst, UBY src) static UBY cpuSbcdB(UBY dst, UBY src)
{ {
UBY xflag = (cpuGetFlagX()) ? 1:0; UWO xflag = (cpuGetFlagX()) ? 1:0;
UWO res = dst - src - xflag; UWO result_plain_binary = (UWO)dst - (UWO)src - xflag;
UWO res_unadjusted = res; UWO low_nibble = (UWO)(dst & 0xf) - (UWO)(src & 0xf) - xflag;
UBY res_bcd; UWO high_nibble = ((UWO)(dst & 0xf0)) - ((UWO)(src & 0xf0));
UWO result_unadjusted = low_nibble + high_nibble;
UWO result_bcd = result_unadjusted;
if (((src & 0xf) + xflag) > (dst & 0xf)) if ((WOR)result_plain_binary < 0)
{ {
res -= 6; result_bcd -= 0x60;
} }
if (res & 0x80)
{
res -= 0x60;
cpuSetFlagXC(TRUE);
}
else
{
cpuSetFlagXC(FALSE);
}
res_bcd = (UBY) res;
if (res_bcd != 0) if (((WOR)low_nibble) < 0)
{
result_bcd -= 6;
result_plain_binary -= 6;
}
BOOLE borrow = ((WOR)result_plain_binary < 0);
cpuSetFlagXC(borrow);
if (result_bcd & 0xff)
{ {
cpuSetFlagZ(FALSE); cpuSetFlagZ(FALSE);
} }
if (res_bcd & 0x80)
if (cpuGetModelMajor() < 4)
{ {
cpuSetFlagN(TRUE); cpuSetFlagN(result_bcd & 0x80);
cpuSetFlagV(((result_unadjusted & 0x80) == 0x80) && !(result_bcd & 0x80));
} }
cpuSetFlagV(((res_unadjusted & 0x80) == 0x80) && !(res_bcd & 0x80)); return (UBY) result_bcd;
return res_bcd;
} }
/// <summary> /// <summary>
@ -2743,9 +2733,9 @@ void cpuBfDecodeExtWordAndGetField(struct cpuBfData *bf_data, ULO ea_or_reg, boo
ULO shift = (8 - bf_data->normalized_offset - bf_data->width) & 7; ULO shift = (8 - bf_data->normalized_offset - bf_data->width) & 7;
for (int i = bf_data->base_address_byte_count - 1; i >= 0; --i) for (int i = bf_data->base_address_byte_count - 1; i >= 0; --i)
{ {
ULL value = (ULL) memoryReadByte(address); ULL value = ((ULL)memoryReadByte(address)) << (8 * i);
field_memory |= (value << (8*i)); field_memory |= value;
field |= ((value >> shift) << (8*i)); field |= (value >> shift);
++address; ++address;
} }
@ -3701,7 +3691,7 @@ static void cpuPtest040(ULO rw, ULO regno)
#include "CpuModule_Decl.h" #include "CpuModule_Decl.h"
#include "CpuModule_Data.h" #include "CpuModule_Data.h"
//#include "CpuModule_Profile.h" #include "CpuModule_Profile.h"
#include "CpuModule_Code.h" #include "CpuModule_Code.h"
cpuOpcodeData cpu_opcode_data_current[65536]; cpuOpcodeData cpu_opcode_data_current[65536];

View File

@ -51,10 +51,6 @@ extern void cpuSetCaar(ULO caar);
extern ULO cpuGetCaar(void); extern ULO cpuGetCaar(void);
extern void cpuSetSR(ULO sr); extern void cpuSetSR(ULO sr);
extern ULO cpuGetSR(void); extern ULO cpuGetSR(void);
extern BOOLE cpuSetIrqLevel(ULO new_interrupt_level);
extern ULO cpuGetIrqLevel(void);
extern void cpuSetIrqAddress(ULO irq_address);
extern ULO cpuGetIrqAddress(void);
extern void cpuSetInstructionTime(ULO cycles); extern void cpuSetInstructionTime(ULO cycles);
extern ULO cpuGetInstructionTime(void); extern ULO cpuGetInstructionTime(void);
extern void cpuSetOriginalPC(ULO pc); extern void cpuSetOriginalPC(ULO pc);
@ -140,6 +136,7 @@ extern UWO cpuGetZFlagL(ULO res);
extern UWO cpuGetNFlagB(UBY res); extern UWO cpuGetNFlagB(UBY res);
extern UWO cpuGetNFlagW(UWO res); extern UWO cpuGetNFlagW(UWO res);
extern UWO cpuGetNFlagL(ULO res); extern UWO cpuGetNFlagL(ULO res);
extern void cpuClearFlagsVC(void);
extern BOOLE cpuCalculateConditionCode0(void); extern BOOLE cpuCalculateConditionCode0(void);
extern BOOLE cpuCalculateConditionCode1(void); extern BOOLE cpuCalculateConditionCode1(void);
@ -180,7 +177,7 @@ extern void cpuThrowFLineException(void);
extern void cpuThrowALineException(void); extern void cpuThrowALineException(void);
extern void cpuThrowTrapVException(void); extern void cpuThrowTrapVException(void);
extern void cpuThrowTrapException(ULO vector_no); extern void cpuThrowTrapException(ULO vector_no);
extern void cpuThrowDivisionByZeroException(BOOLE executejmp); extern void cpuThrowDivisionByZeroException();
extern void cpuThrowChkException(void); extern void cpuThrowChkException(void);
extern void cpuThrowTraceException(void); extern void cpuThrowTraceException(void);
extern void cpuThrowResetException(void); extern void cpuThrowResetException(void);

View File

@ -23,8 +23,7 @@
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"
/* M68k registers */ /* M68k registers */

View File

@ -22,9 +22,7 @@
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"

View File

@ -24,8 +24,6 @@
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h"
#include "CpuModule.h" #include "CpuModule.h"
#ifdef CPU_INSTRUCTION_LOGGING #ifdef CPU_INSTRUCTION_LOGGING

1
cpu/CpuModule_Memory.h Normal file
View File

@ -0,0 +1 @@
#include "fmem.h"

View File

@ -1,7 +1,6 @@
#ifndef CPUMODULE_PROFILE_H #ifndef CPUMODULE_PROFILE_H
#define CPUMODULE_PROFILE_H #define CPUMODULE_PROFILE_H
#include "fileops.h"
void cpuProfileWrite(void) void cpuProfileWrite(void)
{ {
} }

View File

@ -22,9 +22,7 @@
/* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/*=========================================================================*/ /*=========================================================================*/
#include "defs.h" #include "defs.h"
#include "fellow.h" #include "CpuModule_Memory.h"
#include "fmem.h"
#include "CpuModule.h" #include "CpuModule.h"
#include "CpuModule_Internal.h" #include "CpuModule_Internal.h"