-
Notifications
You must be signed in to change notification settings - Fork 167
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
C.ADDI disassembly inaccurate when immediate value is negative #21
Comments
Any progress on this one? It's been 2 years.... |
This is not a problem with the disassembly of C.ADDI; It appears to be a problem for every instruction with an immediate value.. |
Looking a bit deeper: the following instructions improperly decode signed constants as unsigned: I am assuming that crypto constants, hints, CSR#s, fences and shift amounts are not sign extended. That's 19 lines in 3 files: base, cext, fext (plus defining signed versions of the hex_bits_n functions, or explicitly sign extending in those 19 lines |
@allenjbaum It's remarkable that this remained undetected for several years. |
We've known about it for years, just not a priority as it only affects the human-readable disassembly. If someone wants to fix it then great, but the string<->int handling is a bit nasty, so be warned... |
You're right; it is rather...opaque (not good for something that's supposed to be readable and nasty code should be at least comments) and the hex_bits_n function don't seem to have anything to do with hex; it looks strictly binary to decimal string. I'd really prefer if it was hex (I'm not adept at reading Sail, so I could be misreading that... and no comments ....). |
I tried using the dec_str function in string.sail, and it seems to work well. I'm wondering if it would be possible to solve this issue by making the disassembly display an optional feature or directly changing it to decimal representation. Admittedly, there would be quite a bit of work involved in modifying the corresponding references, but I would like to participate in completing this task. I'm unsure if there is a maintainer willing to accept my pull request (PR), but if it's possible, I will provide detailed explanations of the modifications in my PR. Or is there other thoughts on my proposal? |
Should be closed by #456 |
The opcode
0x1541
should decode intoc.addi x10, -16
(according to Spike). Sail is reporting it asc.addi x10, 48
.It seems to execute correctly; if
x10
is 0, it gets written with0xffffffff_fffffff0
. It's only the immediate value shown in the disassembly that looks incorrect.The text was updated successfully, but these errors were encountered: