-
Notifications
You must be signed in to change notification settings - Fork 231
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
Immediate value in hexadecimal when MSB is 1 gives error for Immediate instructions #139
Comments
It looks like it automatically sign extends the immediate into 32-bits before considering the encoding based on the context of the instruction. Therefore, it sign extends It's probably worthwhile to change the way RARS does immediate extension to take into consideration the format of the instruction being used. |
Sorry, I didn't see this issue until now. No notification for it popped up. This is a dup of #134, #103, and #5.
I would like to provide a better error message, but otherwise I think RARS is doing everything correctly. If you consider Since this is a recurring issue, I will give some time to try to make a patch to give better error messages for immediates. I am a little surprised that people do not find the old closed issues though. |
I came up with a solution that I am happy enough with. I am somewhat at a loss for what the best error message would be. My first thought was something like: "Unsigned value is too large to fit into a sign-extended immediate". I am not in a great position to understand what would be most helpful to students though. What would be the best error message for code like |
I believe the C code example is wrong. What would be expected from If changing this behaviour is too complicated, I think the most helpful error message would be similar to your own, but with some explanation that RARS is not just taking the immediate given and sign extending it, which was what I myself expected when this happened to me. |
There are 3 possible ways to choose to handle an issue like this: support unsigned immediates, support them with a warning, or disallow them. Supporting unsigned immediates without a warning is clearly bad to me; if you expect
Changing the behavior is not hard, but I do not believe that would be an improvement as explained above. I agree that some explanation of what RARS is doing is necessary, but I do not know how to convey it well. Having a super long message would be enough, but not ideal and I cannot easily link to a longer explanation. The main reason I was asking for input is the get an actual string to include in the code as the error. |
When using hexadecimal form of an immediate value with a MSB bit of 1 for immediate instructions, an error is thrown, even though both immediate values are 12-bits as the instruction specifies.
For example when attempting to assemble with an instruction such as:
andi t0, a0, 0xF00
The error message is:
However attempting to assemble this instruction
andi t0, a0, -256
instead, is successful.I'm not sure if this issue is being worked on yet. I could try to work on this issue if no one else is working on this.
The text was updated successfully, but these errors were encountered: