2000-12-02 09:04:27 +00:00
|
|
|
;
|
2009-09-28 17:47:33 +00:00
|
|
|
; int __fastcall__ vsprintf (char* Buf, const char* Format, va_list ap);
|
2000-12-01 22:57:32 +00:00
|
|
|
;
|
2009-09-27 12:18:06 +00:00
|
|
|
; Ullrich von Bassewitz, 2009-09-26
|
2000-12-01 22:57:32 +00:00
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
.export _vsprintf
|
|
|
|
.import pushw0sp, staxysp
|
|
|
|
.import vsnprintf
|
2000-12-01 22:57:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
; vsprintf - formatted output into a buffer
|
|
|
|
;
|
2009-09-28 17:47:33 +00:00
|
|
|
; int __fastcall__ vsprintf (char* buf, const char* format, va_list ap);
|
2000-12-01 22:57:32 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
_vsprintf:
|
2013-05-09 11:56:54 +00:00
|
|
|
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,
|
2009-09-28 17:47:33 +00:00
|
|
|
; and store 0x7FFF (INT_MAX) as size.
|
2000-12-01 22:57:32 +00:00
|
|
|
|
2009-09-28 17:47:33 +00:00
|
|
|
jsr pushw0sp ; Get format and push it
|
|
|
|
lda #$FF
|
|
|
|
ldx #$7F ; INT_MAX
|
2009-09-27 12:18:06 +00:00
|
|
|
ldy #2
|
|
|
|
jsr staxysp
|
2002-07-27 07:31:13 +00:00
|
|
|
|
2009-09-28 18:39:55 +00:00
|
|
|
; Contine by jumping to vsnprintf, which expects ap on the CPU stack and will
|
|
|
|
; cleanup the C stack
|
2002-07-27 07:44:51 +00:00
|
|
|
|
2009-09-28 18:39:55 +00:00
|
|
|
jmp vsnprintf
|
2000-12-01 22:57:32 +00:00
|
|
|
|