2000-12-02 09:04:27 +00:00
|
|
|
;
|
2000-12-01 22:57:32 +00:00
|
|
|
; int vsprintf (char* Buf, const char* Format, va_list ap);
|
|
|
|
;
|
2009-09-27 12:18:06 +00:00
|
|
|
; Ullrich von Bassewitz, 2009-09-26
|
2000-12-01 22:57:32 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
.export _vsprintf
|
2009-09-27 12:18:06 +00:00
|
|
|
.import ldax0sp, pushax, staxysp
|
|
|
|
.import _vsnprintf
|
2000-12-01 22:57:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
; vsprintf - formatted output into a buffer
|
|
|
|
;
|
2009-09-27 12:18:06 +00:00
|
|
|
; int vsprintf (char* buf, const char* format, va_list ap);
|
2000-12-01 22:57:32 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
_vsprintf:
|
|
|
|
pha ; Save low byte of ap
|
2009-09-27 12:18:06 +00:00
|
|
|
txa
|
|
|
|
pha ; Save high byte of op
|
2000-12-01 22:57:32 +00:00
|
|
|
|
2009-09-27 12:18:06 +00:00
|
|
|
; Build a stackframe for vsnprintf. To do that, we move format one word down,
|
|
|
|
; and store 0x7FF (INT_MAX) as size.
|
2000-12-01 22:57:32 +00:00
|
|
|
|
2009-09-27 12:18:06 +00:00
|
|
|
jsr ldax0sp ; Get format
|
|
|
|
jsr pushax ; And push it
|
|
|
|
lda #$7F
|
|
|
|
ldx #$FF ; INT_MAX
|
|
|
|
ldy #2
|
|
|
|
jsr staxysp
|
2002-07-27 07:31:13 +00:00
|
|
|
|
2009-09-27 12:18:06 +00:00
|
|
|
; Retrieve ap and contine by jumping to _vsnprintf, which will cleanup the stack
|
2002-07-27 07:44:51 +00:00
|
|
|
|
2009-09-27 12:18:06 +00:00
|
|
|
pla
|
|
|
|
tax
|
|
|
|
pla
|
|
|
|
jmp _vsnprintf
|
2000-12-01 22:57:32 +00:00
|
|
|
|