2 ; int scanf(const char* Format, ...);
4 ; 2000-12-01, Ullrich von Bassewitz
5 ; 2004-12-31, Greg King
10 .import _stdin, pushax, addysp, _vfscanf
11 .import sp:zp, ptr1:zp
15 ; ----------------------------------------------------------------------------
19 sty ArgSize ; Number of argument bytes passed in .Y
21 ; We are using a (hopefully) clever trick here to reduce code size. On entry,
22 ; the stack pointer points to the last pushed argument of the variable
23 ; argument list. Adding the number of argument bytes, would result in a
24 ; pointer that points _above_ the Format argument.
25 ; Because we have to push stdin anyway, we will do that here, so:
27 ; * we will save the subtraction of 2 (__fixargs__) later;
28 ; * we will have the address of the Format argument which needs to
35 ; Now, calculate the va_list pointer, which does point to Format.
45 ; Push a copy of Format.
54 ; Load va_list [last and __fastcall__ argument to vfscanf()].
63 ; Clean up the stack. We will return what we got from vfscanf().
68 ; ----------------------------------------------------------------------------
73 .res 1 ; Number of argument bytes