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

8051 DPTR tracking across functions #4031

Open
phlash opened this issue Feb 23, 2022 · 0 comments
Open

8051 DPTR tracking across functions #4031

phlash opened this issue Feb 23, 2022 · 0 comments

Comments

@phlash
Copy link

phlash commented Feb 23, 2022

Hi folks - I'm struggling to find a solution to what must be a common situation in 8051 disassembly - tracking the value of DPTR across functions that alter it's value, such that subsequent symbol lookups are valid - here's my example:
Screenshot from 2022-02-23 17-03-42

as can be seen: DPTR starts at a known value (0xf9bc), it is then incremented twice (to 0xf9be) and dereferenced to store values in memory. I have labelled these addresses and the labels are correctly displayed. A call is then made to part_save_ptr@dptr which increments DPTR twice more as a side-effect (to 0xf9c0), but this is not propagated back to the caller, which then uses the wrong value for DPTR (0xf9be still) to lookup additional symbols or display an address in memory for the remainder of the calling function. IMO this is worse than ignoring DPTR values, since it is actively confusing!

How should I configure Ghidra to correctly track the DPTR value? Or how can I prevent it from making the wrong assumptions after a function call that modifies DPTR?

I have tried a couple of things (from the manual/tutorials) that do not work:

  • marking the called function in line - this partly works for the decompiler but has no effect on disassembly?
  • declaring DPTR as in/out storage for a parameter to the function - no effect on disassembly.
  • using set register value after the call to force DPTR to 0xf9c0 - no effect on disassembly. This seems broken?

Note that this structure occurs many hundreds of times through this Keil C51 compiled target code - I would be averse to having to manually fix up every call site! 😄

Suggestions gratefully received, Phil.

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

No branches or pull requests

1 participant