Bug 160 - Jaguar RISC: Register checks are too liberal
Summary: Jaguar RISC: Register checks are too liberal
Status: RESOLVED FIXED
Alias: None
Product: RMAC
Classification: Unclassified
Component: Core (show other bugs)
Version: unspecified
Hardware: All All
: Normal normal
Assignee: Shamus Hammons
URL:
Depends on:
Blocks:
 
Reported: 2020-05-11 09:25 CDT by ggn
Modified: 2021-06-07 22:56 CDT (History)
1 user (show)

See Also:


Attachments
Fix the thing, bro! (7.08 KB, application/octet-stream)
2020-05-11 09:25 CDT, ggn
Details

Note You need to log in before you can comment on or make changes to this bug.
Description ggn 2020-05-11 09:25:46 CDT
Created attachment 120 [details]
Fix the thing, bro!

This issue was actually brought to my attention by DrTypo on Atariage: https://atariage.com/forums/topic/234634-rmacrln/?do=findComment&comment=4531624

To quote him directly:

"It seems I've found a bug in the way rmac handles registers. It looks like rmac doesn't care about the "r" in the register name.

"r15" and "15" are the same.

For example, rmac doesn't complain in the following cases:

add 7,1   => assembled to add r7,r1
store 5,(2) => assembled to store r5,(r2)
addq #r31,3 => assembled to addq #31,r3
movei #r8,2 => assembled to movei #8,r2"

So I investigated and it *of course* this had to involve expr() :). One of the two million checks it makes in there is for register tokens, which converts into a CONST and returns it (what?). So there's no distinction there, one could write a complex expression and if the result is between 0 and 31 - bam.

The above does have a certain amount of coolness, I must admit! But no, I think it is too silly. Things shouldn't be that ambiguous. So I shot the relevant expr() code out of orbit which of course is a good starting step for bug #148 at the same time :).

Finally, I noticed that no caller checks the result of EvaluateRegisterFromTokenStream() so I added a small macro to do this and there we go.

Regression suite passes everything as usual, so it's good to go from my side.
Comment 1 Shamus Hammons 2021-06-07 22:56:24 CDT
Thanks for the patch!  Being able to throw away some code from expr.c is a nice bonus.  :-D