Comments (5)
I need to think about it in more detail, but the most obvious solution might be to simply skip the exec call in Moira::execute() if a trace or interrupt exception has occurred.
void
Moira::execute()
{
// Process execution flags (if any)
if (flags) {
// Process pending trace exception (if any)
if (flags & CPU_TRACE_EXCEPTION) {
execTraceException();
}
// Check if the T flag is set inside the status register
if (flags & CPU_TRACE_FLAG) {
flags |= CPU_TRACE_EXCEPTION;
>>> ADD LINE: goto exit;
}
// Process pending interrupt (if any)
if (flags & CPU_CHECK_IRQ) {
checkForIrq();
>>> ADD LINE: IF "IRQ HAS TRIGGERED" goto exit;
}
// If the CPU is stopped, poll the IPL lines and return
if (flags & CPU_IS_STOPPED) {
pollIrq();
sync(MIMIC_MUSASHI ? 1 : 2);
return;
}
// If logging is enabled, record the executed instruction
if (flags & CPU_LOG_INSTRUCTION) {
debugger.logInstruction();
}
}
// Execute the instruction
reg.pc += 2;
(this->*exec[queue.ird])(queue.ird);
>>> ADD LABEL: exit:
// Check if a breakpoint has been reached
if (debugger.breakpoints.needsCheck)
if (debugger.breakpointMatches(reg.pc)) breakpointReached(reg.pc);
}
from moira.
@elmerucr: I think I have a decent fix for the breakpoint issue. My plan is to change the execution function as follows:
void
Moira::execute()
{
//
// The quick execution path: Call the instruction handler and return
//
if (!flags) {
reg.pc += 2;
(this->*exec[queue.ird])(queue.ird);
return;
}
//
// The slow execution path: Process flags one by one
//
// Process pending trace exception (if any)
if (flags & CPU_TRACE_EXCEPTION) {
execTraceException();
goto done;
}
// Check if the T flag is set inside the status register
if (flags & CPU_TRACE_FLAG) {
flags |= CPU_TRACE_EXCEPTION;
}
// Process pending interrupt (if any)
if (flags & CPU_CHECK_IRQ) {
if (checkForIrq()) goto done;
}
// If the CPU is stopped, poll the IPL lines and return
if (flags & CPU_IS_STOPPED) {
pollIrq();
sync(MIMIC_MUSASHI ? 1 : 2);
return;
}
// If logging is enabled, record the executed instruction
if (flags & CPU_LOG_INSTRUCTION) {
debugger.logInstruction();
}
// Execute the instruction
reg.pc += 2;
(this->*exec[queue.ird])(queue.ird);
done:
// Check if a breakpoint has been reached
if (flags & CPU_CHECK_BP)
if (debugger.breakpointMatches(reg.pc)) breakpointReached(reg.pc);
}
In addition to returning directly from this function after executing an exception condition, I have moved breakpoint checking into the "slow execution path". Now, the "quick execution path" only consists of a single call to the instruction handler which should slightly speed up emulation (I guess, the quick execution path is called 99% of the time under normal operating conditions).
I haven't checked in the code yet, but I did some experiments with it in vAmiga. With the new code, I was successful to interrupt the CPU right at the beginning of the VBLANK IRQ handler.
from moira.
Looks like a good solution! Are you going to commit the changes to the repository?
from moira.
New code has been checked in and uploaded.
from moira.
Thanks, code works great so far!
from moira.
Related Issues (19)
- Best m68k disassembler HOT 41
- MMU: Address mapping if table index is zero HOT 2
- Design decision: Use C++ exceptions to emulate address errors and bus errors HOT 2
- 68030 bus error exception frame format HOT 2
- MMU test translate1 fails on real machine HOT 13
- Enforcer test HOT 1
- Dasm Output/alignment for Illegal Instruction in Moira/MoiraDasm_cpp.h HOT 3
- Moira Dasm: word size interpreted as negative HOT 2
- Add support for FC pins HOT 2
- Link instruction apparently broken? HOT 3
- testRunner issue HOT 2
- Breakpoints / Watchpoints are not detected after reset HOT 2
- Jumps to odd exception vectors not handled correctly HOT 2
- exception vector 3 - address error: part of the Moira implementation? HOT 3
- Low level bus signals HOT 2
- MMU test programs needed HOT 3
- 32-bit data bus support HOT 2
- Support caches
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moira.