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

Please add ROR and ROL support #121

Closed
a740g opened this issue Jun 19, 2022 · 1 comment · Fixed by #153
Closed

Please add ROR and ROL support #121

a740g opened this issue Jun 19, 2022 · 1 comment · Fixed by #153
Labels
enhancement New feature or request

Comments

@a740g
Copy link
Contributor

a740g commented Jun 19, 2022

The _SHL and _SHR functions are very handy. However, bitwise Rotate Left and Rotate Right can also be extremely helpful.
Both x86 and x86-64 instruction set have native support for ROL & ROR - https://www.amd.com/system/files/TechDocs/24594.pdf

These can be implemented like how we have SHL & SHR today.

result = _ROL(numericalVariable, numericalValue)
result = _ROR(numericalVariable, numericalValue)
@mkilgore
Copy link
Contributor

Seems reasonable enough to me, I'd be curious to hear from others but it seems like it would fit well along with _SHR, _SHL, and also the bit operations.

The only thing that I think is notable from an implementation perspective is that the size of the operand is more relevant for rotations. So where-as right now we only have a single func__shr implementation that takes an unsigned 64-bit integer, rotations care about the operand size and we'll need separate implementations/overloads/etc. for each supported integer type so that the bits on the end correctly get rotated to the beginning.

It would also be important to define which numbers are valid for rotations. For the rotation count it's probably fine to simply say any positive integer is a valid rotation, as we can mask it with 64/32/16/8 and the rotate will give the same result. Negatives should give an 'illegal function call' error I think.

@mkilgore mkilgore added the enhancement New feature or request label Jun 20, 2022
@RhoSigma-QB64 RhoSigma-QB64 linked a pull request Sep 2, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants