boot2

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

115-struct-ret-3word-many-args.c (764B)


      1 /* Struct return >2 words combined with many args.
      2  *
      3  * If a hidden result-pointer convention exists, it would land in arg0
      4  * and shift the visible args by one slot — easy to miscount when also
      5  * spilling >4 args to the stage. This stresses both at once. */
      6 
      7 struct Wide { long a; long b; long c; long d; };     /* 32 bytes */
      8 
      9 struct Wide build(int p0, int p1, int p2, int p3,
     10                   int p4, int p5, int p6, int p7) {
     11     struct Wide w;
     12     w.a = p0 + p1;
     13     w.b = p2 + p3;
     14     w.c = p4 + p5;
     15     w.d = p6 + p7;
     16     return w;
     17 }
     18 
     19 int main(int argc, char **argv) {
     20     struct Wide w = build(1, 2, 3, 4, 5, 6, 7, 8);
     21     if (w.a != 3)  return 1;
     22     if (w.b != 7)  return 2;
     23     if (w.c != 11) return 3;
     24     if (w.d != 15) return 4;
     25     return 0;
     26 }