]> git.sur5r.net Git - cc65/blob - libsrc/common/vscanf.s
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / libsrc / common / vscanf.s
1 ;
2 ; int __fastcall__ vscanf (const char* format, va_list ap);
3 ;
4 ; Ullrich von Bassewitz, 2004-11-27
5 ;
6
7         .export         _vscanf
8         .import         _vfscanf
9         .import         _stdin
10         .import         decsp2
11
12         .include        "zeropage.inc"
13
14
15 ; ----------------------------------------------------------------------------
16 ; int __fastcall__ vscanf (const char* format, va_list ap)
17 ; /* Standard C function */
18 ; {
19 ;     return vfscanf (stdin, format, ap);
20 ; }
21 ;
22
23 .code
24 _vscanf:
25         pha                     ; Save low byte of ap
26
27 ; Decrement the stack pointer by two for the additional parameter.
28
29         jsr     decsp2          ; Won't touch X
30
31 ; Move the format down
32
33         ldy     #2
34         lda     (sp),y          ; Load byte of format
35         ldy     #0
36         sta     (sp),y
37         ldy     #3
38         lda     (sp),y
39         ldy     #1
40         sta     (sp),y
41
42 ; Store stdin into the stack frame
43
44         iny
45         lda     _stdin
46         sta     (sp),y
47         iny
48         lda     _stdin+1
49         sta     (sp),y
50
51 ; Restore the low byte of ap and jump to vfscanf, which will cleanup the stack
52
53         pla
54         jmp     _vfscanf
55