]> git.sur5r.net Git - cc65/blob - libsrc/conio/cprintf.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / conio / cprintf.s
1 ;
2 ; int cprintf (const char* Format, ...);
3 ;
4 ; Ullrich von Bassewitz, 1.12.2000
5 ;
6
7         .export         _cprintf
8         .import         pushax, addysp, _vcprintf
9         .importzp       sp, ptr1
10
11         .macpack        generic
12
13 ; ----------------------------------------------------------------------------
14 ; Data
15
16 .bss
17
18 ParamSize:      .res    1               ; Number of parameter bytes
19
20 ; ----------------------------------------------------------------------------
21 ; Code
22
23 .code
24
25
26 _cprintf:
27         sty     ParamSize               ; Number of param bytes passed in Y
28
29 ; Calculate a pointer that points to Format
30
31         dey
32         dey                             ; Sub size of Format
33         tya
34         add     sp
35         sta     ptr1
36         ldx     sp+1
37         bcc     @L1
38         inx
39 @L1:    stx     ptr1+1
40
41 ; Push Format
42
43         ldy     #1
44         lda     (ptr1),y
45         tax
46         dey
47         lda     (ptr1),y
48         jsr     pushax
49
50 ; Load va_list (last and __fastcall__ parameter to vfprintf)
51
52         lda     ptr1
53         ldx     ptr1+1
54
55 ; Call vcprintf
56
57         jsr     _vcprintf
58
59 ; Cleanup the stack. We will return what we got from vcprintf
60
61         ldy     ParamSize
62         jmp     addysp
63
64