Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Z80: Decompiler gets confused when mixing interrupt control and stack operations #1208

Open
agatti opened this issue Nov 3, 2019 · 3 comments

Comments

@agatti
Copy link
Contributor

agatti commented Nov 3, 2019

Describe the bug
The decompiler creates an incorrect instruction flow. Maybe it gets confused by stack manipulation and interrupt control code being interleaved rather than nested.

To Reproduce
Steps to reproduce the behavior:

  1. Load the attached test.bin file as a Z80 binary starting at $8000.
  2. Let auto-analysis start - nothing will happen.
  3. Start disassemble from the very first instruction, the decompiler window will fill up with some invalid code.

Expected behavior
In the decompiled code, enableMaskableInterrupts is supposed to appear after the write to DAT_io_00a1, not right after disableMaskableInterrupts.

Screenshots
Screenshot 2019-11-03 05 05 00

Attachments

test.bin.gz

Environment (please complete the following information):

  • OS: macOS 10.14.6
  • Java Version: OpenJDK 11.0.5
  • Ghidra Version: 9.1-DEV built from Ghidra_9.1_build tag
@emteere
Copy link
Contributor

emteere commented Nov 21, 2019

Weird, will try to reproduce.

@cbuschardt
Copy link

Did you remember to mark the io region as volatile in the "Window->Memory Map" window?

@agatti
Copy link
Contributor Author

agatti commented Dec 6, 2019

@cbuschardt Marking the IO region as volatile lets the decompiler work as intended, indeed. Thanks for the tip.

That said, is it still a bug in the decompiler? Values are written to the IO area, so there are fewer assumptions to be made from the data in question.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants