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

Bitwise Operations without opcodes #97

Closed
Tracked by #231
x87 opened this issue Nov 22, 2020 · 3 comments
Closed
Tracked by #231

Bitwise Operations without opcodes #97

x87 opened this issue Nov 22, 2020 · 3 comments
Labels
priority:p2 Medium priority scope:compiler type:feature New feature or request
Milestone

Comments

@x87
Copy link
Collaborator

x87 commented Nov 22, 2020

CLEO Plugin IntOperations brings in an easy way to perform common bitwise operations over integer values. However memorizing opcodes and keywords is not easy. So the compiler should be able to figure the opcode in a similar fashion CLEO arithmetic operations are supported.

Proposed Syntax:

Operation Opcode Expression
AND 0B10 0@ = 1@ & 2@
OR 0B11 0@ = 1@ | 2@
XOR 0B12 0@ = 1@ ^ 2@
NOT 0B13 0@ = ~1@
MOD 0B14 0@ = 1@ % 2@
Shift Right 0B15 0@ = 1@ >> 2@
Shift Left 0B16 0@ = 1@ << 2@
AND (compound assignment) 0B17 0@ &= 1@
OR (compound assignment) 0B18 0@ |= 1@
XOR (compound assignment) 0B19 0@ ^= 1@
NOT (mutable) 0B1A ~0@
MOD (compound assignment) 0B1B 0@ %= 1@
Shift Right (compound assignment) 0B1C 0@ >>= 1@
Shift Left (compound assignment) 0B1D 0@ <<= 1@
@x87 x87 added type:feature New feature or request priority:p2 Medium priority scope:compiler labels Nov 22, 2020
@wmysterio
Copy link

"Proposed Syntax" it a standard syntax by other programming languages. Good propose. This is Cake!

@x87
Copy link
Collaborator Author

x87 commented Oct 9, 2022

SBL documentation: https://library.sannybuilder.com/#/sa/bitwise

@x87
Copy link
Collaborator Author

x87 commented May 15, 2023

consider

var |= (1 << n); // set nth bit
var &= ~(1 << n); // clean nth bit
if (number >> n) & 1; // test nth bit
var ^= (1 << n); // toggle nth bit

@x87 x87 mentioned this issue Jul 1, 2023
46 tasks
@x87 x87 closed this as completed Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority:p2 Medium priority scope:compiler type:feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants