aline / fline exception handler (for toolbox)

This commit is contained in:
Kelvin Sherlock 2013-02-07 00:01:22 -05:00
parent ba14f15566
commit aee146c708
2 changed files with 43 additions and 3 deletions

View File

@ -6,6 +6,10 @@ extern "C" {
#endif #endif
typedef void (*cpuLineExceptionFunc)(uint16_t);
extern void cpuSetALineExceptionFunc(cpuLineExceptionFunc func);
extern void cpuSetFLineExceptionFunc(cpuLineExceptionFunc func);
// This header file defines the internal interfaces of the CPU module. // This header file defines the internal interfaces of the CPU module.
#define CPU_INSTRUCTION_LOGGING #define CPU_INSTRUCTION_LOGGING

View File

@ -34,6 +34,20 @@
#include "autoconf.h" #include "autoconf.h"
#endif #endif
static cpuLineExceptionFunc cpu_a_line_exception_func = NULL;
static cpuLineExceptionFunc cpu_f_line_exception_func = NULL;
void cpuSetALineExceptionFunc(cpuLineExceptionFunc func)
{
cpu_a_line_exception_func = func;
}
void cpuSetFLineExceptionFunc(cpuLineExceptionFunc func)
{
cpu_f_line_exception_func = func;
}
/*============================================================================*/ /*============================================================================*/
/* profiling help functions */ /* profiling help functions */
/*============================================================================*/ /*============================================================================*/
@ -124,9 +138,23 @@ void cpuUpdateSr(ULO new_sr) {
static void cpuIllegal(void) { static void cpuIllegal(void) {
UWO opcode = memoryReadWord(cpuGetPC() - 2); UWO opcode = memoryReadWord(cpuGetPC() - 2);
if ((opcode & 0xf000) == 0xf000) { if ((opcode & 0xf000) == 0xf000)
cpuThrowFLineException(); {
} else if ((opcode & 0xa000) == 0xa000) { if (cpu_f_line_exception_func)
{
cpu_f_line_exception_func(opcode);
cpuInitializeFromNewPC(cpuGetPC());
cpuSetInstructionTime(512);
}
else
{
cpuThrowFLineException();
}
}
else if ((opcode & 0xa000) == 0xa000)
{
/*
#ifdef UAE_FILESYS #ifdef UAE_FILESYS
if ((cpuGetPC() & 0xff0000) == 0xf00000) if ((cpuGetPC() & 0xff0000) == 0xf00000)
{ {
@ -136,6 +164,14 @@ static void cpuIllegal(void) {
} }
else else
#endif #endif
*/
if (cpu_a_line_exception_func)
{
cpu_a_line_exception_func(opcode);
cpuInitializeFromNewPC(cpuGetPC());
cpuSetInstructionTime(512);
}
else
{ {
cpuThrowALineException(); cpuThrowALineException();
} }