kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

ibit_andnot.c (431B)


      1 /* 32-bit "and-not" / "or-not": x & ~y and x | ~y. On aarch64 these may lower to
      2  * the BIC (bit clear) and ORN (or-not) shifted-register forms. volatile keeps
      3  * both operands live.
      4  *   x = 0xFF, y = 0x0F
      5  *   x & ~y = 0xF0 (240);  (x | ~y) & 0xFF = 0xFF (255)
      6  *   (240 + 255) - 453 = 42. */
      7 int test_main(void) {
      8   volatile int x = 0xFF, y = 0x0F;
      9   int bic = x & ~y;
     10   int orn = (x | ~y) & 0xFF;
     11   return (bic + orn) - 453;
     12 }