kit

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

agg_byptr.c (528B)


      1 /* A struct passed BY POINTER (explicit address), the callee reading and writing
      2  * fields through the pointer. Exercises plain field loads/stores at struct
      3  * offsets via a register base (ldr/str [base, #off]). `noinline` forces the
      4  * real call. After accumulate, p.a = 18 + 24 = 42. */
      5 struct Pair {
      6   int a;
      7   int b;
      8 };
      9 __attribute__((noinline)) static void accumulate(struct Pair* p) {
     10   p->a = p->a + p->b;
     11 }
     12 int test_main(void) {
     13   volatile int x = 18, y = 24;
     14   struct Pair p = {x, y};
     15   accumulate(&p);
     16   return p.a;
     17 }