ghidra
ghidra copied to clipboard
i8085 OUT instruction discarded by decompiler
Describe the bug The decompiler results are almost complete except for missing the OUT instruction.
I can provide the ROM data or project if needed.
Environment (please complete the following information):
- OS: Linux Arch
- Java Version: OpenJDK Runtime Environment (build 11.0.16.1+1)
- Ghidra Version: Version 10.1.5 Build DEV 2022-Aug-14 1349 UTC
- Ghidra Origin: Arch package
Setting the region to be initialized removes the = ??
from listing view but does not affect ~disassembly~ decompilation (also not after re-create function or clear code and run disassemble again
)
Found the option for saving the decompile debug log :) https://gist.github.com/hjanetzek/4e1bfbdbc7eb6282385084da7c5b426f
You keep saying disassembly, do you mean decompiler, or is the assembly presented incorrectly?
The OUT from z80 is probably how 8085 should be written in SLEIGH, but on master decompiler was still not showing 2 stores even with a fix (make PCODE have a STORE). When loading this function as z80 it does have both,
Thank you for the pointer, I'll have a look.
... sorry about the wrong terminology - it's my first project like this.
Could it suffice to just edit 8085.slaspec file? Yesterday I've changed it to
macro ioWrite(addr,val) {
*[io]:1 addr = val;
}
:OUT IOAddr8 is op0_8=0xd3; IOAddr8 {
ioWrite(IOAddr8, A);
}
And after restart today the OUT instructions show up in decompiled code:
@hjanetzek Can you do me a favor and on the listing view click the button to Edit the Listing fields, then enable the PCode field so I can see what the pcode for the OUT instruction is showing in your binary?
Hi @GhidorahRex - I tried but PCode seems not to possible to activate. The button stays greyed out when clicking or moving to other rows.
Sorry, I forgot to mention: you should be able to right-click it and select "enable field"
ok - there it is
This is the listing after you modified the OUT
instruction to use the macro, correct?
Yes right. now it should be back to the original
Still trying to troubleshoot to get the correct fix, but adding <range space="io"/>
to the global section in 8085.cspec
then restarting ghidra provides a better fix than adding the macro.
LGTM :)
I guess it threw me off, didn't really realize there's two syntax for STORE operations. Didn't expect an issue that big vs just the one instruction/constructor. Out of curiosity is there something weird about that where *[]X = COPY A
is preferred over a STORE. Guessing high PCODE would eventually convert to STORE?
I had a similar issue when decompiling Z80 assembly. Marking the io memory as volatile as described in #2257 was an effective workaround.