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

Pcode incorrect for DUPLEX instructions with two memops #10

Open
toshipiazza opened this issue Feb 14, 2022 · 0 comments · May be fixed by #11
Open

Pcode incorrect for DUPLEX instructions with two memops #10

toshipiazza opened this issue Feb 14, 2022 · 0 comments · May be fixed by #11
Labels
bug Something isn't working

Comments

@toshipiazza
Copy link
Owner

The plugin emits incorrect pcode for the following snippet:

{ R3 = memw(R2+#0x0); memw(R2+#0x0) = #0x0 }

The store should occur after the load, as written. The problem causing the incorrect pcode is that these instructions form a DUPLEX; and in a DUPLEX the slot 0 instruction comes first in program memory, but the slot 1 instruction must always be executed after.

A standard InstructionIterator is insufficient

AddressSet addrSet = new AddressSet(minAddr, maxAddr);
program.getListing().getInstructions(addrSet, true)

Because DUPLEXes will be enumerated in the incorrect (execution) order

@toshipiazza toshipiazza added the bug Something isn't working label Feb 14, 2022
toshipiazza added a commit that referenced this issue Feb 14, 2022
Previously we would emit pcode for instructions in the order they appear
in the listing (order of increasing address). This assumption is
incorrect for DUPLEX instructions.

DUPLEX instructions appear in the listing in swapped order: the slot 0
instruction appears earlier in memory, followed by the slot 1
instruction. But execution order follows the opposite ordering: order of
decreasing slots (so slot 3, 2, 1, 0)

As a result, we would emit incorrect pcode for the following assembly:

{ R3 = memw(R2+#0x0); memw(R2+#0x0) = #0x0 }

As written, the load comes before the store, but since they are DUPLEX
the store would appear before the load, causing the load to be
const-propped. This commit fixes the issue.

Fixes #10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant