#18 CPU emulation optimization patch


This patch, intended to be applied on top of my
previous ones (1287942 and 1290370), optimizes the
ARM/Thumb emulation, corrects a few minor bugs in the
emulation, and cleans up the code some more. The patch
gives a noticeable speed improvement, on the order of
10-15% depending on the code being run. I'm fairly
confident I haven't broken anything, but testing would
be appreciated.

Note that the patch takes advantage of a couple of GCC
features (function parameters in registers and branch
prediction hints). I've ifdef'd them for GCC, and also
modified the MS-style assembly to match the new C
wrappers, so the code should compile and run fine; but
additional work can probably be done (by someone who
has Visual Studio--I don't) to optimize further for


  • Andrew Church

    Andrew Church - 2005-09-16

    Logged In: YES

    Revised version of the patch, with comment/whitespace fixes
    (no code changes). Also attaching a diff containing all
    three CPU emulation patches, against 2005/9/11 CVS.

  • Pokemonhacker

    Pokemonhacker - 2005-09-27

    Logged In: YES

    Hi !
    I was wondering if you could post somewhere (or email me at
    my sourceforge address) all the files you changed/created so
    I can get a closer look at them (I'm asking that because I
    have no clue on how to apply a .diff file :/).
    And cheers for all your hard work ;)

  • Andrew Church

    Andrew Church - 2005-09-27

    Logged In: YES

    I've attached a zip of all the changed files (note that
    src/arm-new.h and src/thumb.h are zero bytes--the contents
    of those files have been moved to GBA-arm.cpp and
    GBA-thumb.cpp, so the empty files can be deleted).

    Incidentally, diff files can be applied using the "patch"
    program--if you're on Linux or another Unix system, it
    should be preinstalled, and here's one that looks like it
    works on Windows:
    Decompress the patch file, start a command prompt, cd into
    the VBA top directory, and run "patch -p0 <armthumb.diff"
    (including the pathname to wherever you put the diff file).

  • Andrew Church

    Andrew Church - 2005-11-18

    Logged In: YES

    Attaching revised patch (fixing Win32 compilation and
    several cycle timing issues) against current (2005/11/18)
    CVS. Also eliminating the partial patch, since the full
    patch now works.

  • Rib Rdb

    Rib Rdb - 2006-05-11

    Logged In: YES

    You have thumbUI instead of thumbBP for the thumb breakpoint

  • Andrew Church

    Andrew Church - 2006-05-15

    Logged In: YES

    Thanks, fixed.

  • krazydeath

    krazydeath - 2006-10-12

    Logged In: YES

    how do i download this ?

  • Andrew Church

    Andrew Church - 2006-10-12

    Logged In: YES

    Scroll to the bottom of this page and click on the
    "Download" link next to "armthumb-files-2a.zip", then unpack
    the ZIP file in the same directory as the VBA source code
    and compile it as usual. Note that you will need to use the
    CVS source code, not the 1.7.2 distribution (and I haven't
    updated the patch for recent CVS changes, so I don't know if
    it will still work; it would be nice if the new code was
    merged into CVS).

  • Richard Quirk

    Richard Quirk - 2006-11-20

    Logged In: YES
    Originator: NO

    The patch no longer applies to current CVS :(

  • Andrew Church

    Andrew Church - 2006-12-04

    Logged In: YES
    Originator: YES

    Updated patch for 2006/12/4 CVS, including all changes made to the original code (only lightly tested, but it seems to work). Note that if you try to apply this on top of my more recent ++ operator patch (1608454), the patch against src/arm-new.h will fail, but since the file is no longer used with this patch that is not a concern.

  • Andrew Church

    Andrew Church - 2006-12-04

    Merged patch (1287942+1290370+1292942) against 2006/12/4 CVS

  • Squall Leonhart

    Squall Leonhart - 2011-07-28

    looks like this wasn't as tested as you thought, it breaks the zero state flag, though the only game that seems to be affected is v-rally 3


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks