1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-27 15:29:46 +00:00
cc65/libsrc/common/vsprintf.s
uz e4d9fd3bd1 Fixed more bugs, shortened the code where possible.
git-svn-id: svn://svn.cc65.org/cc65/trunk@4257 b7a2c559-68d2-44c3-8de9-860c34a00d81
2009-09-28 18:39:55 +00:00

38 lines
933 B
ArmAsm

;
; 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