kit

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

ibit_long.c (538B)


      1 /* 64-bit bitwise AND/ORR/EOR/NOT on `long`. Exercises the x-register (64-bit)
      2  * forms of and/orr/eor/mvn. volatile defeats folding. Branch-free, no relocs.
      3  *   a = 0xF0, b = 0x3C
      4  *   a & b = 0x30 (48), a | b = 0xFC (252), a ^ b = 0xCC (204)
      5  *   ~a = 0xFFFFFFFFFFFFFF0F; (~a & 0xFF) = 0x0F (15)
      6  *   (48 + 252 + 204 + 15) - 477 = 42. */
      7 int test_main(void) {
      8   volatile long a = 0xF0, b = 0x3C;
      9   long and_ = a & b;
     10   long or_ = a | b;
     11   long xor_ = a ^ b;
     12   long not_ = ~a & 0xFF;
     13   return (int)((and_ + or_ + xor_ + not_) - 477);
     14 }