boot2

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

098-call-7args.c (555B)


      1 /* Function call with > 6 args. Many ABIs only pass 6 in registers; the
      2  * rest go on the stack. This exercises caller stack-arg setup and
      3  * callee parameter access at indices >= 6. */
      4 
      5 int sum7(int a, int b, int c, int d, int e, int f, int g) {
      6     return a + b + c + d + e + f + g;
      7 }
      8 
      9 int sum8(int a, int b, int c, int d, int e, int f, int g, int h) {
     10     return a + b + c + d + e + f + g + h;
     11 }
     12 
     13 int main(int argc, char **argv) {
     14     if (sum7(1, 2, 3, 4, 5, 6, 7) != 28) return 1;
     15     if (sum8(1, 2, 3, 4, 5, 6, 7, 8) != 36) return 2;
     16     return 0;
     17 }