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

Assembler improvement: Distinguish between Rn and n. #6

Closed
tpwrules opened this issue Nov 5, 2019 · 1 comment
Closed

Assembler improvement: Distinguish between Rn and n. #6

tpwrules opened this issue Nov 5, 2019 · 1 comment

Comments

@tpwrules
Copy link
Collaborator

tpwrules commented Nov 5, 2019

Currently, in the Python-based Boneless assembler, there is no difference between specifying a register Rn and the integer n as an argument to an instruction. As a consequence, the instruction SLLI(R3, R2, 1) assembles the same as SLLI(R3, R2, R1). Unfortunately, the second version might mislead one into believing the instruction is shifting R2 by the value of R1 instead of by the constant 1. At least in my experience, this behavior easily creates hard-to-find bugs.

I suggest that using a register where a constant is expected and vice versa should be treated as an error. For problems where being able to interchange a register and its number are useful, the Rn object could have e.g. an attribute containing its number: R3.number == 3 and have e.g. a constructor that takes a register number: Rn(3) == R3. This would eliminate the source of accidental bugs and still allow the flexibility of interchanging registers with their numbers in the syntax.

@whitequark
Copy link
Owner

Fixed in 53faf6b.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants