kit

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

iarith_addsub.c (410B)


      1 /* iarith: 32-bit integer add and subtract.
      2  *
      3  * volatile operands force real `add w`/`sub w` instructions to be emitted
      4  * (the optimizer cannot fold them to a single mov). No relocs, no branches,
      5  * so all of L0/L1/L2 should round-trip through `cc -S | as`.
      6  *
      7  * (50 + 17) - 25 = 42. */
      8 int test_main(void) {
      9   volatile int a = 50, b = 17, c = 25;
     10   int sum = a + b;
     11   int diff = sum - c;
     12   return diff;
     13 }