kit

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

ibit_logic.c (493B)


      1 /* 32-bit bitwise AND/ORR/EOR with register operands. volatile locals defeat
      2  * constant folding so real `and`/`orr`/`eor` (shifted-register form) are
      3  * emitted rather than folded to a mov. Branch-free, no relocs.
      4  *   a = 0xF0, b = 0x3C
      5  *   a & b = 0x30 (48), a | b = 0xFC (252), a ^ b = 0xCC (204)
      6  *   (48 + 252 + 204) - 462 = 42. */
      7 int test_main(void) {
      8   volatile int a = 0xF0, b = 0x3C;
      9   int and_ = a & b;
     10   int or_ = a | b;
     11   int xor_ = a ^ b;
     12   return (and_ + or_ + xor_) - 462;
     13 }