2 ; int snprintf (char* buf, size_t size, const char* Format, ...);
4 ; Ullrich von Bassewitz, 2009-09-26
8 .import pushax, addysp, decsp6, _vsnprintf
13 ; ----------------------------------------------------------------------------
18 ParamSize: .res 1 ; Number of parameter bytes
20 ; ----------------------------------------------------------------------------
27 sty ParamSize ; Number of param bytes passed in Y
29 ; We have to push buf/size/format, both in the order they already have on stack.
30 ; To make this somewhat more efficient, we will create space on the stack and
31 ; then do a copy of the complete block instead of pushing each parameter
32 ; separately. Since the size of the arguments passed is the same as the size
33 ; of the fixed arguments, this will allow us to calculate the pointer to the
34 ; fixed size arguments easier (they're just ParamSize bytes away).
38 ; Calculate a pointer to the Format argument
48 ; Now copy buf/size/format
56 ; Load va_list (last and __fastcall__ parameter to vsprintf)
65 ; Cleanup the stack. We will return what we got from vsprintf