File: vsprintf.s

package info (click to toggle)
cc65 2.19-2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 20,268 kB
  • sloc: ansic: 117,151; asm: 66,339; pascal: 4,248; makefile: 1,009; perl: 607
file content (37 lines) | stat: -rw-r--r-- 973 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
;
; int __fastcall__ vsprintf (char* Buf, const char* Format, va_list ap);
;
; Ullrich von Bassewitz, 2009-09-26
;

        .export         _vsprintf
        .import         pushw0sp, staxysp
        .import         vsnprintf


; ----------------------------------------------------------------------------
; vsprintf - formatted output into a buffer
;
; int __fastcall__ vsprintf (char* buf, const char* format, va_list ap);
;


_vsprintf:
        pha                     ; Save low byte of ap
        txa
        pha                     ; Save high byte of op

; Build a stackframe for vsnprintf. To do that, we move format one word down,
; and store 0x7FFF (INT_MAX) as size.

        jsr     pushw0sp        ; Get format and push it
        lda     #$FF
        ldx     #$7F            ; INT_MAX
        ldy     #2
        jsr     staxysp

; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will 
; cleanup the C stack

        jmp     vsnprintf