TASEmulators / BizHawk

BizHawk is a multi-system emulator written in C#. BizHawk provides nice features for casual gamers such as full screen, and joypad support in addition to full rerecording and debugging tools for all system cores.
http://tasvideos.org/BizHawk.html
Other
2.13k stars 380 forks source link

Incorrect SNES Disassembly of CMP #2704

Open Rycona opened 3 years ago

Rycona commented 3 years ago

I find that an immediate CMP (Op Code: 0xC9) in the Debugger window reads and displays the next 2 bytes for the constant when it should be 1. I'm assuming it's not taking the M flag into account.

I'm using the BSNES core on BizHawk 2.6.0. I didn't see any relative fixes posted for 2.6.1.

nattthebear commented 3 years ago

There's some code for this but it's not done. The disassembler itself tracks status, and even will mutate its internal status flag on seeing SEP/REP. But we only run the disassembler a single instruction at a time, passing 0 for flags on each invocation, so that isn't used.

nattthebear commented 3 years ago

@Rycona Would a checkbox to choose M flag in the disassembler be enough for most uses, or does real world code heavily interleave uses of the two?

Rycona commented 3 years ago

I can get around the issue using the standalone BSNES emulator to view/change/test the ASM, so it's not a major problem. It does get a bit inconvenient as the changes I'm trying to make are related to a Lua script I'm also building to work with those ASM changes, which BSNES doesn't support, but again, that's something I can get around with some better methodology and will hopefully get easier as I learn to better comprehend the ASM.

I wouldn't press for such a fix based on solely my situation, when that effort could be placed elsewhere. Before posting, I tried to see if I could fix it myself, but I couldn't quite find where that code was in the repository. Plus, it's a bit daunting to step into such a large and diverse codespace.

YoshiRulz commented 1 year ago

CMP is here: https://github.com/TASEmulators/BizHawk/blob/faba9035b72f65e606ddf12a7631b0fce7bd9100/src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs#L442-L452


Unrelated, this appears to be a typo: https://github.com/TASEmulators/BizHawk/blob/faba9035b72f65e606ddf12a7631b0fce7bd9100/src/BizHawk.Emulation.Cores/CPUs/W65816/Disassembler.cs#L298 fixed in https://github.com/TASEmulators/BizHawk/commit/c10d2927ca6cc00f781883c3828cdef304c33c06