2005-02-14 09:21:54 +00:00
|
|
|
;
|
|
|
|
; int cscanf(const char* format, ...);
|
|
|
|
;
|
|
|
|
; 2000-12-01, Ullrich von Bassewitz
|
|
|
|
; 2005-01-01, Greg King
|
|
|
|
;
|
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
.export _cscanf
|
2005-02-14 09:21:54 +00:00
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
.import pushax, addysp, _vcscanf
|
2005-02-14 09:21:54 +00:00
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
.macpack generic
|
|
|
|
.include "zeropage.inc"
|
2005-02-14 09:21:54 +00:00
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
; Code
|
|
|
|
;
|
|
|
|
_cscanf:
|
2005-02-14 09:38:30 +00:00
|
|
|
sty ArgSize ; Number of argument bytes passed in .Y
|
|
|
|
dey ; subtract size of format pointer
|
2005-02-14 09:21:54 +00:00
|
|
|
dey
|
|
|
|
tya
|
|
|
|
|
|
|
|
; Now, calculate the va_list pointer -- which points to format.
|
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
ldx sp+1
|
|
|
|
add sp
|
|
|
|
bcc @L1
|
2005-02-14 09:21:54 +00:00
|
|
|
inx
|
2005-02-14 09:38:30 +00:00
|
|
|
@L1: sta ptr1
|
|
|
|
stx ptr1+1
|
2005-02-14 09:21:54 +00:00
|
|
|
|
|
|
|
; Push a copy of the format pointer onto the stack.
|
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
ldy #1
|
|
|
|
lda (ptr1),y
|
2005-02-14 09:21:54 +00:00
|
|
|
tax
|
|
|
|
dey
|
2005-02-14 09:38:30 +00:00
|
|
|
lda (ptr1),y
|
|
|
|
jsr pushax
|
2005-02-14 09:21:54 +00:00
|
|
|
|
|
|
|
; Load va_list [last and __fastcall__ argument for vcscanf()].
|
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
lda ptr1
|
|
|
|
ldx ptr1+1
|
2005-02-14 09:21:54 +00:00
|
|
|
|
|
|
|
; Call vcscanf().
|
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
jsr _vcscanf
|
2005-02-14 09:21:54 +00:00
|
|
|
|
|
|
|
; Clean up the stack. We will return what we got from vcscanf().
|
|
|
|
|
2005-02-14 09:38:30 +00:00
|
|
|
ldy ArgSize
|
|
|
|
jmp addysp
|
2005-02-14 09:21:54 +00:00
|
|
|
|
|
|
|
; ----------------------------------------------------------------------------
|
|
|
|
; Data
|
|
|
|
;
|
|
|
|
.bss
|
|
|
|
ArgSize:
|
2005-02-14 09:38:30 +00:00
|
|
|
.res 1 ; Number of argument bytes
|
2005-02-14 09:21:54 +00:00
|
|
|
|