Git Product home page Git Product logo

Comments (3)

cavaliercoder avatar cavaliercoder commented on July 25, 2024 1

Thanks, I'll take a closer look.

from r68k.

emoon avatar emoon commented on July 25, 2024

Hi,

This code uses the QuickCheck crate from here https://github.com/BurntSushi/quickcheck and bunch of the code to set up the tests can be found here https://github.com/marhel/r68k/blob/master/emu/src/musashi.rs#L565

from r68k.

marhel avatar marhel commented on July 25, 2024

Yes, there's no separate sources for that, this kind of testing is done by loading the Musashi lib into the process, and interacting with it via Rusts C-interop. Then the test cases uses QuickCheck to come up with a random configuration of registers, status flags and memory, and we try our best to set up both Musashi and r68k cores this way, and then run a single instruction, and compare the effects on both cores afterwards.

The code uses Rust macros heavily, such as;

qc!(MASK_OUT_Y, OP_CMPI_32_PD, qc_cmpi_32_pd);

This macro generate a test function called qc_cmpi_32_pd, to test a particular variation of the CMP instruction (32-bit immediate value with address register postdecrement). The mask MASK_OUT_Y, tells us which bits in the opcode can vary (in this case, the 'Y' register part may vary, which controls which address register is used), because we loop to cover all opcode variants explicitly instead of relying on randomization to hit all opcode variations.

Then we also run completeness tests that runs through all 64K possible opcodes, (1K per test) such as:

qc_allow_exception!(BLOCK_MASK, BLOCK_7K, qc_block7k);

Which does the same thing. The reason we differentiate between these cases, and don't randomize the exact opcode, are that during initial development with just a few opcodes implemented, it's not helpful to know that the cores differ when asked to execute, say, opcode 0x4313 with some values, because you'd need a disassembler to know which operation that was.

Much more helpful when implementing CMP, to see that the instruction effects appears to differ when using A7 postdecrement, say, or (an actual case) ADDA differs when the same register is used as both source and destination

from r68k.

Related Issues (20)

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.