abi3.ssa 875 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. type :four = {l, b, w}
  2. data $z = { w 0 }
  3. export
  4. function $test() {
  5. @start
  6. %a =w loadw $z
  7. %y =w add %a, %a
  8. %yl =l extsw %y
  9. %s =l alloc8 16 # allocate a :four struct
  10. %s1 =l add %s, 12 # get address of the w
  11. storel 4, %s # set the l
  12. storew 5, %s1 # set the w
  13. # only the last argument should be on the stack
  14. %f =l add $F, %yl
  15. %x =w call %f(w %y, w 1, w 2, w 3, :four %s, w 6)
  16. # store the result in the
  17. # global variable a
  18. %x1 =w add %y, %x
  19. storew %x1, $a
  20. ret
  21. }
  22. # >>> driver
  23. # #include <stdio.h>
  24. # struct four { long long l; char c; int i; };
  25. # extern void test(void);
  26. # int F(int a0, int a1, int a2, int a3, struct four s, int a6) {
  27. # printf("%d %d %d %d %d %d %d\n",
  28. # a0, a1, a2, a3, (int)s.l, s.i, a6);
  29. # return 42;
  30. # }
  31. # int a;
  32. # int main() { test(); printf("%d\n", a); return 0; }
  33. # <<<
  34. # >>> output
  35. # 0 1 2 3 4 5 6
  36. # 42
  37. # <<<