Skip to content

Bitwise Operations without opcodes #97

Closed

Description

@x87

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@

Activity

  1. added
    type:feature
    priority:p2
    on Nov 22, 2020
  2. wmysterio commented on Nov 22, 2020

    @wmysterio

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

  3. modified the milestone: v3.6.1 on Nov 23, 2020
  4. added this to the v3.9.0 milestone on Sep 8, 2022
  5. x87 commented on May 15, 2023

    @x87
    CollaboratorAuthor

    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
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority:p2scope:compilertype:feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions