2 ; int __fastcall__ vcprintf (const char* Format, va_list ap);
4 ; Ullrich von Bassewitz, 2.12.2000
9 .import __printf, _cputc
10 .importzp sp, ptr1, ptr2, ptr3, tmp1
17 ; ----------------------------------------------------------------------------
19 ; Static data for the _vsprintf routine
22 outdesc: ; Static outdesc structure
24 .word out ; Output function pointer
30 ; ----------------------------------------------------------------------------
31 ; Callback routine used for the actual output.
33 ; static void __cdecl__ out (struct outdesc* d, const char* buf, unsigned count)
34 ; /* Routine used for writing */
36 ; /* Fast screen output */
45 ; We're using ptr1 and tmp1, since we know that the cputc routine will not use
46 ; them (they're also used in cputs, so they must be safe).
48 out: jsr popax ; count
65 ; Sum up the total count of characters
67 ldy #0 ; ccount in struct outdesc
68 sty tmp1 ; Initialize tmp1 while we have zero available
77 ; Loop outputting characters
94 ; ----------------------------------------------------------------------------
95 ; vcprintf - formatted console i/o
97 ; int __fastcall__ vcprintf (const char* format, va_list ap)
101 ; /* Setup descriptor */
104 ; /* Do formatting and output */
105 ; _printf (&d, format, ap);
107 ; /* Return bytes written */
115 ; Setup the outdesc structure
119 sta outdesc+1 ; Clear ccount
121 ; Get the format parameter and push it again
130 ; Replace the passed format parameter on the stack by &d - this creates
131 ; exactly the stack frame _printf expects. Parameters will get dropped
134 ldy #2 ; Low byte of d
141 ; Restore ap and call _printf
147 ; Return the number of bytes written.