]> git.sur5r.net Git - cc65/commitdiff
Replace vscanf by an assembler version
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 27 Nov 2004 18:23:24 +0000 (18:23 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Sat, 27 Nov 2004 18:23:24 +0000 (18:23 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@3307 b7a2c559-68d2-44c3-8de9-860c34a00d81

libsrc/common/.cvsignore
libsrc/common/Makefile
libsrc/common/vscanf.c [deleted file]
libsrc/common/vscanf.s [new file with mode: 0644]

index d8d6186b314c1505305945afb20f868631e59682..b15eaacc83097a22d7af9217c01b5cf1fed1e824 100644 (file)
@@ -37,7 +37,6 @@ strtok.s
 strxfrm.s
 system.s
 timezone.s
-vscanf.s
 vsscanf.s
 
 
index 43b56ba1cba84253466eeb418beb8b3813491b0b..2aad615caa6963a1fdf4f86acbe2a846e9422517 100644 (file)
@@ -67,7 +67,6 @@ C_OBJS =      _afailed.o      \
                strtok.o        \
                 system.o        \
                 timezone.o      \
-                vscanf.o        \
                 vsscanf.o
 
 
@@ -170,6 +169,7 @@ S_OBJS =    _cwd.o          \
                vfprintf.o      \
                 vfscanf.o       \
                vprintf.o       \
+                vscanf.o        \
                vsprintf.o      \
                zerobss.o
 
diff --git a/libsrc/common/vscanf.c b/libsrc/common/vscanf.c
deleted file mode 100644 (file)
index 0523980..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * vscanf.c
- *
- * Ullrich von Bassewitz (uz@cc65.org), 2004-11-26
- *
- */
-
-
-
-#include <stdio.h>
-
-
-
-/*****************************************************************************/
-/*                                          Code                                    */
-/*****************************************************************************/
-
-
-
-int __fastcall__ vscanf (const char* format, va_list ap)
-/* Standard C function */
-{
-    return vfscanf (stdin, format, ap);
-}
-
-
-
diff --git a/libsrc/common/vscanf.s b/libsrc/common/vscanf.s
new file mode 100644 (file)
index 0000000..038b797
--- /dev/null
@@ -0,0 +1,55 @@
+;
+; int __fastcall__ vscanf (const char* format, va_list ap);
+;
+; Ullrich von Bassewitz, 2004-11-27
+;
+
+       .export         _vscanf
+        .import         _vfscanf
+        .import         _stdin
+        .import         decsp2
+
+        .include        "zeropage.inc"
+
+
+; ----------------------------------------------------------------------------
+; int __fastcall__ vscanf (const char* format, va_list ap)
+; /* Standard C function */
+; {
+;     return vfscanf (stdin, format, ap);
+; }
+;
+
+.code
+_vscanf:
+        pha                     ; Save low byte of ap
+
+; Decrement the stack pointer by two for the additional parameter.
+
+        jsr     decsp2          ; Won't touch X
+
+; Move the format down
+
+        ldy     #2
+        lda     (sp),y          ; Load byte of format
+        ldy     #0
+        sta     (sp),y
+        ldy     #3
+        lda     (sp),y
+        ldy     #1
+        sta     (sp),y
+
+; Store stdin into the stack frame
+
+        iny
+        lda     _stdin
+        sta     (sp),y
+        iny
+        lda     _stdin+1
+        sta     (sp),y
+
+; Restore the low byte of ap and jump to vfscanf, which will cleanup the stack
+
+        pla
+        jmp     _vfscanf
+