2 ; int fastcall vcscanf(const char* format, va_list ap);
4 ; 2014-09-10, Greg King
10 .import popax, pushax, swapstk
12 .include "../common/_scanf.inc"
23 ; /* Call-back functions:
24 ; ** (Note: These prototypes must NOT be declared with fastcall! They don't
25 ; ** use (getfunc)'s and (ungetfunc)'s last parameter. Leaving it out of these
26 ; ** prototypes makes more efficient code.)
29 ; ----------------------------------------------------------------------------
30 ; /* Read a character from the console, and return it to an internal function */
31 ; static int get(void) {
38 ; cputc(C = cgetc()); /* echo a typed character */
45 ; Return the old, pushed-back character (instead of getting a new one).
52 ; Directly read the keyboard.
56 ; Echo the character to the screen.
65 ; ----------------------------------------------------------------------------
66 ; static int cdecl unget(int c) {
73 jsr popax ; get the first argument
78 ; ----------------------------------------------------------------------------
79 ; int fastcall vcscanf(const char* format, va_list ap) {
80 ; /* Initiate the data structure.
81 ; ** Don't initiate the member that these conio functions don't use.
83 ; static const struct scanfdata d = {
88 ; /* conio is very interactive. So, don't use any pushed-back character.
89 ; ** Start fresh, each time that this function is called.
93 ; /* Call the internal function, and return the result. */
94 ; return _scanf(&d, format, ap);
97 ; Beware: Because ap is a fastcall parameter, we must not destroy .XA.
101 ; ----------------------------------------------------------------------------
102 ; Static, constant scanfdata structure for the _vcscanf routine.
105 d: .addr get ; SCANFDATA::GET
106 .addr unget ; SCANFDATA::UNGET
107 ; .addr 0 ; SCANFDATA::DATA (not used)
110 pha ; Save low byte of ap
112 pha ; Save high byte of ap
116 ; Put &d on the stack in front of the format pointer.
120 jsr swapstk ; Swap .XA with top-of-stack
121 jsr pushax ; Put format pointer back on stack
123 ; Restore ap, and jump to _scanf which will clean up the stack.