]> git.sur5r.net Git - cc65/blob - libsrc/conio/cscanf.s
Revert "atari5200: fix COLOR defines' names"
[cc65] / libsrc / conio / cscanf.s
1 ;
2 ; int cscanf(const char* format, ...);
3 ;
4 ; 2000-12-01, Ullrich von Bassewitz
5 ; 2005-01-01, Greg King
6 ;
7
8         .export         _cscanf
9
10         .import         pushax, addysp, _vcscanf
11
12         .macpack        generic
13         .include        "zeropage.inc"
14
15 ; ----------------------------------------------------------------------------
16 ; Code
17 ;
18 _cscanf:
19         sty     ArgSize         ; Number of argument bytes passed in .Y
20         dey                     ; subtract size of format pointer
21         dey
22         tya
23
24 ; Now, calculate the va_list pointer -- which points to format.
25
26         ldx     sp+1
27         add     sp
28         bcc     @L1
29         inx
30 @L1:    sta     ptr1
31         stx     ptr1+1
32
33 ; Push a copy of the format pointer onto the stack.
34
35         ldy     #1
36         lda     (ptr1),y
37         tax
38         dey
39         lda     (ptr1),y
40         jsr     pushax
41
42 ; Load va_list [last and __fastcall__ argument for vcscanf()].
43
44         lda     ptr1
45         ldx     ptr1+1
46
47 ; Call vcscanf().
48
49         jsr     _vcscanf
50
51 ; Clean up the stack.  We will return what we got from vcscanf().
52
53         ldy     ArgSize
54         jmp     addysp
55
56 ; ----------------------------------------------------------------------------
57 ; Data
58 ;
59         .bss
60 ArgSize:
61         .res    1               ; Number of argument bytes
62