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

Tricore EA calculation #2504

Open
wants to merge 2 commits into
base: next
Choose a base branch
from

Conversation

Rot127
Copy link
Collaborator

@Rot127 Rot127 commented Oct 9, 2024

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

Fixes two issues with address calculation:

Fix absolute address calculations.

Absolute effective addresses are decoded by DecodeBInstruction().
Because they are encoded as normal disp24 value.
To form the EA:
The lower 20bits are shifted by one, and the upper 4bits by 1 (jumps) or 7 (calls).

Fix PC relative disponents.

The ISA sign extends disponents values of 8, 15 and 24 bits.
For address disponents it also shifts the results by 1 for alignment.

The ISA has two writing styles for this though:
sign_ext(dispXX * 2) and sign_ext(dispXX) * 2.

Assuming that sign_ext() always works on the MSB of the value
they are eqivalent. Because:
sign_ext(disp8 * 2) = sign_ext(disp8 * 2 = disp9) = sign_ext(disp9) = sign_ext(disp8) * 2.

This let to confusion before and for the sign_ext(dispXX * 2) case,
and the wrong bit was checked for sign extension (e.g bit 8 for an effective disp9 value).

Test plan

Not yet added.

Closing issues

...

Absolute effective addresses are calculated decoded by DecodeBInstruction().
Because they are encoded as normal disp24 value.
To form the EA:
The lower 20bits are shifted by one, and the upper 4bits by 1 (jumps) or 7 (calls).
@github-actions github-actions bot added the TriCore Arch label Oct 9, 2024
@Rot127
Copy link
Collaborator Author

Rot127 commented Oct 9, 2024

@imbillow Please review this one before I fix the tests.

@Rot127 Rot127 marked this pull request as ready for review October 15, 2024 10:15
@Rot127 Rot127 requested a review from imbillow October 15, 2024 10:16
The ISA sign extends disponents values of 8, 15 and 24 bits.
For address disponents it also shifts the results by 2 for alignment.

The ISA has two writing styles for this though:
sign_ext(dispXX * 2) and sign_ext(dispXX) * 2.

Assuming that sign_ext() always works on the MSB of the value
they are eqivalent. Because:
sign_ext(disp8 * 2) = sign_ext(disp8 * 2 = disp9) = sign_ext(disp9) = sign_ext(disp8) * 2.

This let to confusion before and for the sign_ext(dispXX * 2) case,
and the wrong bit was checked for sign extension (e.g bit 8 for an effective disp9 value).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants