Thread overview
AArch64 va_arg()
February 19
Figuring out stdarg for the Arm.

```
#include <stdarg.h>
int square(float a, float b, ...)
{
    va_list args;
    va_start(args, b);
    int i = va_arg(args, int);
    va_end(args);
    return i;
}
```
which compiles to, I kid you not:
```
   0:	d10383ff 	sub	sp, sp, #0xe0   // function prolog
   4:	bd000fe0 	str	s0, [sp, #12]
   8:	bd000be1 	str	s1, [sp, #8]

   c:	f90053e0 	str	x0, [sp, #160]
  10:	f90057e1 	str	x1, [sp, #168]
  14:	f9005be2 	str	x2, [sp, #176]
  18:	f9005fe3 	str	x3, [sp, #184]
  1c:	f90063e4 	str	x4, [sp, #192]
  20:	f90067e5 	str	x5, [sp, #200]
  24:	f9006be6 	str	x6, [sp, #208]
  28:	f9006fe7 	str	x7, [sp, #216]
  2c:	3d8013e2 	str	q2, [sp, #64]
  30:	3d8017e3 	str	q3, [sp, #80]
  34:	3d801be4 	str	q4, [sp, #96]
  38:	3d801fe5 	str	q5, [sp, #112]
  3c:	3d8023e6 	str	q6, [sp, #128]
  40:	3d8027e7 	str	q7, [sp, #144] // initialize va_argsave

  44:	910383e0 	add	x0, sp, #0xe0
  48:	f9000fe0 	str	x0, [sp, #24]
  4c:	910383e0 	add	x0, sp, #0xe0
  50:	f90013e0 	str	x0, [sp, #32]
  54:	910283e0 	add	x0, sp, #0xa0
  58:	f90017e0 	str	x0, [sp, #40]
  5c:	128007e0 	mov	w0, #0xffffffc0            	// #-64
  60:	b90033e0 	str	w0, [sp, #48]
  64:	12800be0 	mov	w0, #0xffffffa0            	// #-96
  68:	b90037e0 	str	w0, [sp, #52]    // va_start(args, b); (filling in va_list)

  6c:	b94033e1 	ldr	w1, [sp, #48]
  70:	f9400fe0 	ldr	x0, [sp, #24]
  74:	7100003f 	cmp	w1, #0x0
  78:	540000ab 	b.lt	8c <square+0x8c>  // b.tstop
  7c:	91002c01 	add	x1, x0, #0xb
  80:	927df021 	and	x1, x1, #0xfffffffffffffff8
  84:	f9000fe1 	str	x1, [sp, #24]
  88:	1400000d 	b	bc <square+0xbc>
  8c:	11002022 	add	w2, w1, #0x8
  90:	b90033e2 	str	w2, [sp, #48]
  94:	b94033e2 	ldr	w2, [sp, #48]
  98:	7100005f 	cmp	w2, #0x0
  9c:	540000ad 	b.le	b0 <square+0xb0>
  a0:	91002c01 	add	x1, x0, #0xb
  a4:	927df021 	and	x1, x1, #0xfffffffffffffff8
  a8:	f9000fe1 	str	x1, [sp, #24]
  ac:	14000004 	b	bc <square+0xbc>
  b0:	f94013e2 	ldr	x2, [sp, #32]
  b4:	93407c20 	sxtw	x0, w1
  b8:	8b000040 	add	x0, x2, x0
  bc:	b9400000 	ldr	w0, [x0]
  c0:	b9003fe0 	str	w0, [sp, #60]   // int i = va_arg(args, int)

  c4:	b9403fe0 	ldr	w0, [sp, #60]   // return i

  c8:	910383ff 	add	sp, sp, #0xe0
  cc:	d65f03c0 	ret                     // epilog
```
February 19
On Wednesday, 19 February 2025 at 09:11:36 UTC, Walter Bright wrote:
> Figuring out stdarg for the Arm.
>
> ```
> which compiles to, I kid you not:
> [ ... ]

this is without any optimization enabled, right?
February 19
On 2/19/2025 8:42 AM, Stefan Koch wrote:
> this is without any optimization enabled, right?

Right.