Closed philpem closed 4 weeks ago
You can try replacing `local tmp = C + Z;
with local tmp = C || Z;
in the BLS
definition and see if that helps. Normally we wouldn't use addition for conditionals. That seems like an odd syntax to me and the decompiler doesn't like it as much. Similar for the other conditionals.
@GhidorahRex - I can confirm this fixes the issue.
CMP #4, BLS foo
decompiles as (a < 5)
- which is correct, and probably better for a for-loop than a <=
(LE) comparison.
I've applied that patch to my local build - I can submit a PR if you like but it's only a couple of lines (one for the BLS instruction and the same change in BHS/BCC)
Glad it worked for you! I've already got a change ready to go :-)
Describe the bug Decompiled conditionals involving the BLS and BHS/BCC branches produce hard-to-read decompilations.
To Reproduce Disassemble and decompile the following code bytes using the 6805 core.
Note that the conditionals are hard to read:
Expected behavior More readable comparison code, e.g.:
Or even better for the last one:
It would also be nice if the array accesses could be switched to use the C array-dereference form, but the pointer form is arguably correct:
Environment (please complete the following information):
Additional context This may happen on other processor modules, but I've mainly seen it on the 6805 one.