Giter VIP home page Giter VIP logo

Comments (5)

dirkwhoffmann avatar dirkwhoffmann commented on June 28, 2024

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.

dirkwhoffmann avatar dirkwhoffmann commented on June 28, 2024

@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.

Bildschirmfoto 2020-01-18 um 13 09 44

from moira.

elmerucr avatar elmerucr commented on June 28, 2024

Looks like a good solution! Are you going to commit the changes to the repository?

from moira.

dirkwhoffmann avatar dirkwhoffmann commented on June 28, 2024

New code has been checked in and uploaded.

from moira.

elmerucr avatar elmerucr commented on June 28, 2024

Thanks, code works great so far!

from moira.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.