boot2

Playing with the boostrap
git clone https://git.ryansepassi.com/git/boot2.git
Log | Files | Refs | README

023-cmpd-simple.c (652B)


      1 // tests/cc-parse/23-cmpd-simple.c — compound assignment on simple lval (§B.3).
      2 // Exercises one op per family: +=, -=, *=, /=, %=, <<=, >>=, &=, ^=, |=.
      3 int main(void) {
      4     int a = 7;     a += 3;     // 10
      5     int b = 7;     b -= 3;     // 4
      6     int c = 7;     c *= 3;     // 21
      7     int d = 12;    d /= 3;     // 4
      8     int e = 7;     e %= 3;     // 1
      9     int f = 1;     f <<= 4;    // 16
     10     int g = 32;    g >>= 1;    // 16
     11     int h = 0xF;   h &= 0xA;   // 10
     12     int i = 0xF;   i ^= 0xA;   // 5
     13     int j = 0;     j |= 7;     // 7
     14     // sum = 10 + 4 + 21 + 4 + 1 + 16 + 16 + 10 + 5 + 7 = 94
     15     return a + b + c + d + e + f + g + h + i + j;
     16 }