-
Notifications
You must be signed in to change notification settings - Fork 217
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
Incorrect instruction encoding for JAL #89
Comments
I am confident that the encoding is correct. Using GNU
I think that the "Basic" representation is highly misleading. I would suspect it is the reason why you made this issue. In terms of the specification, the immediate for this jal should be Currently all code interacting with Jump (and Branch) immediates uses a divided by 2 representation. It is probably best to replace that with a direct immediate representation. Such a change would require changing the Jump immediate decode and encode as well as all the areas where instructions use them. rars/src/rars/ProgramStatement.java Lines 409 to 426 in 41fff8f
rars/src/rars/riscv/instructions/JAL.java Line 46 in 41fff8f
Thank you for making this issue. If you want to try to fix it, it should be pretty simple aside from confirming all relevant code has been changed. Alternatively, I can fix it in a few days when I am free. |
Indeed, I was confused by the "basic representation". Thank you for your speedy and detailed explanation! |
This was made to address #89. It succesfully makes the basic representation less confusing and matches GNU tools.
This should be fixed now. Let me know if it seems correct to you in the continuous build. |
Yes, now what the "Basic" column shows is in line with what I would expect. |
Minimal test case:
This assembles to:
(This is compact
.text
at 0, but it doesn't matter sinceJAL
is relative)However, according to the spec on page 16, the low order bit of the immediate value is placed at index 21. This would imply the instruction should be encoded as
0x002000ef
-- noting that0x002000ef & (1 << 21) >> 21 = 1
. Also note that JAL technically has a 21-bit immediate, but the lowest order bit is omitted as described on page 15, thus a a relative jump toPC+2
should have a single1
in the lowest order bit of the immediate.The text was updated successfully, but these errors were encountered: