]> git.sur5r.net Git - cc65/blob - libsrc/common/vsprintf.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / common / vsprintf.s
1 ;
2 ; int __fastcall__ vsprintf (char* Buf, const char* Format, va_list ap);
3 ;
4 ; Ullrich von Bassewitz, 2009-09-26
5 ;
6
7         .export         _vsprintf
8         .import         pushw0sp, staxysp
9         .import         vsnprintf
10
11
12 ; ----------------------------------------------------------------------------
13 ; vsprintf - formatted output into a buffer
14 ;
15 ; int __fastcall__ vsprintf (char* buf, const char* format, va_list ap);
16 ;
17
18
19 _vsprintf:
20         pha                     ; Save low byte of ap
21         txa
22         pha                     ; Save high byte of op
23
24 ; Build a stackframe for vsnprintf. To do that, we move format one word down,
25 ; and store 0x7FFF (INT_MAX) as size.
26
27         jsr     pushw0sp        ; Get format and push it
28         lda     #$FF
29         ldx     #$7F            ; INT_MAX
30         ldy     #2
31         jsr     staxysp
32
33 ; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will 
34 ; cleanup the C stack
35
36         jmp     vsnprintf
37