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

An assembly alias of WEXT is considered harmful to toolchains (assembler) #147

Open
a4lg opened this issue Sep 30, 2022 · 0 comments
Open

Comments

@a4lg
Copy link

a4lg commented Sep 30, 2022

Quoting 6.3. FSR, FSRI (version 0.9.11),

Alias:

"WEXT Rd, Rs1, Rs2" == "FSR Rd, Rs1, Rs3, Rs2"

where Rs1 is an even register, Rs3 is an even+1 register, and Rs2[5] == 0.

In here, ensuring that Rs2[5] == 0 is the problem. We might assume that following expansion works:

# wext rd, rs1, rs2
andi rd, rs2, 0x1f         # bit 5 (and upper bits) is set to zero
fsr rd, rs1, (rs1+1), rd

Wrong. If rd is either rs1 or (rs1+1), the result will be most likely incorrect. And former WEXT instruction did not prohibit such register overlap.
We must allocate an independent temporary register for this reason but this is a great pain for toolchains ... at least for GNU Binutils.

So, I propose to make some changes so that the alias WEXT is not what toolchain (specifically, assembler) developers should implement. Removing this alias (or aliases including WEXTI) is an option (though WEXTI alias is not harmful itself).

To note, as a porting guide from former WEXT to recent FSR, this text is not only correct but acceptable. But as an assembler alias, it's not.

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

1 participant