A2osX/SYS/KERNEL.S.STDIO2.S.txt

714 lines
14 KiB
Plaintext
Raw Normal View History

2019-09-04 15:35:50 +00:00
NEW
AUTO 3,1
2020-02-14 16:32:52 +00:00
*/--------------------------------------
* # PrintF (BLOCKING)
* # FPrintF (BLOCKING)
* # SPrintF
* Prints C-Style String
* ## C
2020-02-16 20:45:16 +00:00
* `int printf ( const char *format, ... );`
* `int fprintf ( short int stream, const char *format, ... );`
* `int sprintf ( char *str, const char *format, ... );`
2020-02-14 16:32:52 +00:00
* ## ASM
* **In:**
* PrintF : (example is for printing Y,A as integer : format="%I", 2 bytes)
* `>PUSHW format`
* `>PUSHW i`
* `...`
* `>PUSHBI 2` #bytecount
2020-02-28 07:21:46 +00:00
* `>SYSCALL PrintF`
2020-02-14 16:32:52 +00:00
* FPrintF :
* `>PUSHB hFILE`
* `>PUSHW format`
* `>PUSHW i`
* `...`
* `>PUSHBI 2` #bytecount
* `>SYSCALL fprintf`
* SPrintF :
* `>PUSHW str`
* `>PUSHW format`
* `>PUSHW i`
* `...`
* `>PUSHBI 2` #bytecount
* `>SYSCALL sprintf`
* ## RETURN VALUE
* CC : success, Y,A = bytes sent
* CS : error, A = code from Output
* Specifiers :
* + %b : pull 1 byte to Print BIN
* + %d : pull 1 byte unsigned DEC 0..255
* + %D : pull 2 bytes unsigned DEC 0..65535
* + %u : pull 4 bytes long unsigned DEC 0..4294967295
* + %e : pull 5 Bytes float (-)1.23456789e+12
* + %f : pull 5 Bytes float (-)3.1415
* + %h : pull 1 byte to Print HEX
* + %H : pull 2 bytes to Print HEX
* + %i : pull 1 byte to Print signed DEC -128..127
* + %I : pull 2 bytes to Print signed DEC -32768..32767
* + %L : pull 4 bytes signed DEC -2147483648..2147483647
* + %s : pull 2 bytes ptr to C-Style String
* + %S : pull 2 bytes ptr to P-Style String
* + \b : Print 'BS' (08)
* + \e : Print 'ESC' ($1B,27)
* + \f : Print 'FF' ($0C,12)
* + \n : Print 'LF' ($0A,10)
* + \r : Print 'CR' ($0D,13)
* + \t : Print 'TAB' ($09,09)
* + \v : Print 'VT' ($0B,11)
* + \xHH : Print byte with hexadecimal value HH (1 to 2 digits)
* + \\\\ : Print \
* + \\% : Print %
* Modifiers for len and padding :
* + %d : '9' '12'
* + %2d : ' 9' '12'
* + %02d : '09' '12'
* + %11s : 'ABCDEFGH '
* + %011s : 'ABCDEFGH000'
* + %2f : '3.14'
*\--------------------------------------
.DUMMY
2020-04-13 17:04:02 +00:00
.OR ZPTMP+5 5 Bytes
2020-02-14 16:32:52 +00:00
PrintF.Cnt .BS 2
PrintF.hFILE .BS 1
2020-04-13 17:04:02 +00:00
STDIO.StackBytePtr .BS 1
STDIO.ExitPopCnt .BS 1
2020-02-14 16:32:52 +00:00
.ED
2019-09-04 15:35:50 +00:00
*--------------------------------------
2020-02-14 16:32:52 +00:00
K.PrintF.PadL .EQ FAC+5
K.PrintF.PadC .EQ ARG.SIGN
*--------------------------------------
2020-02-16 20:45:16 +00:00
K.PrintF ldy #S.PS.hStdOut
2020-02-28 07:21:46 +00:00
lda (pPS),y
2019-09-04 15:35:50 +00:00
sta PrintF.hFILE
2020-03-10 16:42:07 +00:00
ldx #1
.HS 2C BIT ABS
2020-02-14 16:32:52 +00:00
*--------------------------------------
2020-03-10 16:42:07 +00:00
K.FPrintf ldx #2
.HS 2C BIT ABS
2020-02-14 16:32:52 +00:00
*--------------------------------------
2020-03-10 16:42:07 +00:00
K.SPrintf ldx #3
2019-09-04 15:35:50 +00:00
*--------------------------------------
2020-04-13 17:04:02 +00:00
K.PrintF.1 sec format string->ptr2
jsr STDIO.GetParams
stx pIOBuf
sta pIOBuf+1 Output buffer->pIOBuf
sty STDIO.ExitPopCnt Total bytes to POP
2019-09-04 15:35:50 +00:00
.1 jsr SHARED.GetCharPtr2
bne .22
jmp .8 end of format..
.22 cmp #'%'
bne .10
stz K.PrintF.PadL
stz K.PrintF.PadC
lda (ZPPtr2)
beq .7 end of format... print % and exit
jsr ZP.IsDigit
bcs .6 no digit....go check specifier
cmp #'0' ...a 0...mmm... padding char?
bne .4
sta K.PrintF.PadC
jsr SHARED.NextCharPtr2 skip 0 ...
lda (ZPPtr2)
beq .7
jsr ZP.IsDigit
bcs .6 %0x ??????
2020-03-16 06:50:15 +00:00
.4 jsr MATH32.Dec2ACC32
2019-09-04 15:35:50 +00:00
bcs .99
lda ACC32
sta K.PrintF.PadL
lda K.PrintF.PadC
bne .5
lda #C.SPACE
sta K.PrintF.PadC
.5 jsr SHARED.AddYToPtr2 skip all processed chars
lda (ZPPtr2)
beq .7
.6 ldx #PrintFTBL1.Cnt-1 do we have a %x command?
.61 cmp PrintFTBL1,x
beq .62
dex
bpl .61
bra .20 unknown ...
.62 jsr SHARED.NextCharPtr2
txa yes, jmp to it!
asl
tax
2020-02-14 16:32:52 +00:00
jsr PrintF.ESC
2019-09-04 15:35:50 +00:00
.11 bcc .1
bra .99
.7 lda #'%'
bra .20
*--------------------------------------
.10 cmp #'\'
bne .20
jsr SHARED.GetCharPtr2
beq .99
ldx #PrintFTBL2.Cnt-1
.12 cmp PrintFTBL2,x
beq .19
dex
bpl .12
cmp #'x' \xHH
bne .1
2020-03-16 06:50:15 +00:00
jsr MATH32.Hex2ACC32
2019-09-04 15:35:50 +00:00
bcs .99
2020-03-04 16:38:32 +00:00
2019-09-04 15:35:50 +00:00
jsr SHARED.AddYToPtr2
.14 lda ACC32
bra .20
.19 lda PrintFTBL2.OUT,x
2020-03-23 07:08:27 +00:00
.20 jsr PrintF.PutC
2019-09-04 15:35:50 +00:00
bcc .11
2019-10-03 06:25:27 +00:00
*--------------------------------------
2020-03-04 16:38:32 +00:00
.99 lda #E.BADARG
sec
jmp STDIO.Exit
2019-10-03 06:25:27 +00:00
*--------------------------------------
2019-09-04 15:35:50 +00:00
.8 ldx PrintF.hFILE
beq .80 Writing to buffer, append \0
2020-03-04 16:38:32 +00:00
2019-09-04 15:35:50 +00:00
>PUSHW PrintF.Cnt Writing to File/dev...
>PUSHWI K.IOBuf
txa
jsr K.FWrite
bcc .81
tay
2020-03-04 16:38:32 +00:00
bne .9
2019-09-04 15:35:50 +00:00
>RET 4 0=BLOCKING
2020-02-19 16:42:05 +00:00
2019-09-04 15:35:50 +00:00
.80 ldy PrintF.Cnt A=0, Writing to buffer, append \0
sta (pIOBuf),y
2020-03-04 16:38:32 +00:00
clc
2019-09-04 15:35:50 +00:00
.81 >LDYA PrintF.Cnt
* clc
2020-03-04 16:38:32 +00:00
.9 jmp STDIO.Exit
2019-09-04 15:35:50 +00:00
*--------------------------------------
2020-02-14 16:32:52 +00:00
PrintFTBL1 .AS "bdDuefhHiILsS"
PrintFTBL1.Cnt .EQ *-PrintFTBL1
PrintFTBL2 .AS "abefnrtv\%"
PrintFTBL2.Cnt .EQ *-PrintFTBL2
PrintFTBL2.OUT .HS 07.08.1B.0C.0A.0D.09.0B \a\b\e\f\n\r\t\v
.DA #'\' \\
.DA #'%' \%
2019-09-04 15:35:50 +00:00
*--------------------------------------
2020-02-14 16:32:52 +00:00
PrintF.ESC jmp (.1,x)
.1 .DA PrintF.B
.DA PrintF.D,PrintF.DD,PrintF.U
.DA PrintF.E,PrintF.F
.DA PrintF.H,PrintF.HH
.DA PrintF.I,PrintF.II,PrintF.L
.DA PrintF.S,PrintF.SS
2019-09-04 15:35:50 +00:00
*--------------------------------------
2020-02-19 16:42:05 +00:00
PrintF.B jsr STDIO.GetStackByte
2020-02-14 16:32:52 +00:00
bcs PrintF.B.RTS
2019-09-04 15:35:50 +00:00
ldy #8
.1 asl
pha
lda #'0'/2
rol
2020-03-23 07:08:27 +00:00
jsr PrintF.PutC
2019-09-04 15:35:50 +00:00
bcs .9
pla
dey
bne .1
rts
.9 ply
2020-02-14 16:32:52 +00:00
PrintF.B.RTS
2019-09-04 15:35:50 +00:00
rts
*--------------------------------------
2020-02-14 16:32:52 +00:00
PrintF.I sec signed short
2019-09-04 15:35:50 +00:00
.HS 90 BCC
2020-02-14 16:32:52 +00:00
PrintF.D clc unsigned short (BYTE)
2019-09-04 15:35:50 +00:00
ldy #1
2020-02-14 16:32:52 +00:00
bra PrintF.NUM
2020-03-25 07:19:20 +00:00
2020-02-14 16:32:52 +00:00
PrintF.II sec signed int
2019-09-04 15:35:50 +00:00
.HS 90 BCC
2020-02-14 16:32:52 +00:00
PrintF.DD clc unsigned int (WORD)
2019-09-04 15:35:50 +00:00
ldy #2
2020-02-14 16:32:52 +00:00
bra PrintF.NUM
2019-09-04 15:35:50 +00:00
2020-02-14 16:32:52 +00:00
PrintF.L sec signed long
2019-09-04 15:35:50 +00:00
.HS 90 BCC
2020-02-14 16:32:52 +00:00
PrintF.U clc unsigned long (DWORD)
2019-09-04 15:35:50 +00:00
ldy #4
2020-02-14 16:32:52 +00:00
PrintF.NUM ror ACC32.Sign
2020-03-16 06:50:15 +00:00
jsr MATH32.ACC32ZERO
2020-03-25 07:19:20 +00:00
2020-02-19 16:42:05 +00:00
.1 jsr STDIO.GetStackByte
2020-02-14 16:32:52 +00:00
bcs PrintF.B.RTS
2019-09-04 15:35:50 +00:00
sta ACC32-1,y
dey
bne .1
ldx K.PrintF.PadL
ldy K.PrintF.PadC
rol ACC32.Sign
2020-03-16 06:50:15 +00:00
jsr MATH32.ACC322STR10
2020-02-14 16:32:52 +00:00
bra PrintF.StrNum
2019-09-04 15:35:50 +00:00
*--------------------------------------
* EXP(8) 1(s) 1significants(31)
* http://apple2.org.za/gswv/a2zine/GS.WorldView/Resources/GS.TECH.INFO/AppleSoft/
*--------------------------------------
2020-02-14 16:32:52 +00:00
PrintF.E sec Force "E+12"
2019-09-04 15:35:50 +00:00
.HS 90 BCC
2020-02-14 16:32:52 +00:00
PrintF.F clc
2019-09-04 15:35:50 +00:00
lda (pStack) get current stack Ptr
sec at least 5 bytes remaining ?
sbc #5
2020-02-14 16:32:52 +00:00
bcc PrintF.StrNum.Err
2019-09-04 15:35:50 +00:00
sta (pStack)
* sec
adc pStack
ldy pStack+1 A,Y = float
ldx #FPU.SETFAC
jsr GP.ROMCALL
ldy #A2osX.NumStrBuf+1 FOUT.1 will do a DEY
ldx #FPU.FOUT
jsr GP.ROMCALL
2020-02-14 16:32:52 +00:00
PrintF.StrNum ldy #0
2019-09-04 15:35:50 +00:00
.2 lda A2osX.NumStrBuf,y
beq .8
iny
2020-03-23 07:08:27 +00:00
jsr PrintF.PutC
2019-09-04 15:35:50 +00:00
bcc .2
.9 rts
2020-03-10 16:42:07 +00:00
2019-09-04 15:35:50 +00:00
.8 clc
rts
2020-02-14 16:32:52 +00:00
PrintF.StrNum.Err
2019-09-04 15:35:50 +00:00
lda #E.STACK
sec
rts
*--------------------------------------
2020-02-14 16:32:52 +00:00
PrintF.S ldy #$ff CSTR
2019-09-04 15:35:50 +00:00
.HS 2C bit abs
2020-02-14 16:32:52 +00:00
PrintF.SS ldy #$00 PSTR
2019-09-04 15:35:50 +00:00
sty .1+1
2020-02-19 16:42:05 +00:00
jsr STDIO.GetStackByte
2019-09-04 15:35:50 +00:00
bcs .9
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
sta ZPPtr1+1
2020-02-19 16:42:05 +00:00
jsr STDIO.GetStackByte
2019-09-04 15:35:50 +00:00
bcs .9
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
sta ZPPtr1
lda (ZPPtr1) if CSTR:last char=0, if PSTR:len=0
beq .8
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
ldy .1+1
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
.1 lda #$ff Self Modified
bne .11 CSTR
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
tya PSTR
cmp (ZPPtr1) len check
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
beq .2
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
.11 iny
lda (ZPPtr1),y
beq .2
2020-03-23 07:08:27 +00:00
jsr PrintF.PutC
2019-09-04 15:35:50 +00:00
bcs .9
lda K.PrintF.PadL
beq .1
cpy K.PrintF.PadL
bne .1
.8 clc
rts
2020-03-10 16:42:07 +00:00
2019-09-04 15:35:50 +00:00
.2 lda K.PrintF.PadL
beq .8
2020-05-04 20:46:21 +00:00
2019-09-04 15:35:50 +00:00
.3 cpy K.PrintF.PadL
beq .8
2020-05-04 20:46:21 +00:00
2019-10-03 06:25:27 +00:00
lda K.PrintF.PadC
2020-03-23 07:08:27 +00:00
jsr PrintF.PutC
2019-09-04 15:35:50 +00:00
bcs .9
2020-03-10 16:42:07 +00:00
2019-09-04 15:35:50 +00:00
iny
bne .3
* clc
.9 rts
*--------------------------------------
2020-02-19 16:42:05 +00:00
PrintF.HH jsr STDIO.GetStackByte
2020-03-23 07:08:27 +00:00
bcs PrintF.PutC.RTS
2019-09-04 15:35:50 +00:00
pha LO byte
2020-02-19 16:42:05 +00:00
jsr STDIO.GetStackByte
2020-01-22 21:52:00 +00:00
plx
2020-03-23 07:08:27 +00:00
bcs PrintF.PutC.RTS
2020-01-22 21:52:00 +00:00
pha
txa
2020-02-14 16:32:52 +00:00
jsr PrintF.H.1
2019-09-04 15:35:50 +00:00
plx
2020-03-23 07:08:27 +00:00
bcs PrintF.PutC.RTS
2019-09-04 15:35:50 +00:00
txa
2020-02-14 16:32:52 +00:00
bra PrintF.H.1
2019-09-04 15:35:50 +00:00
*--------------------------------------
2020-02-19 16:42:05 +00:00
PrintF.H jsr STDIO.GetStackByte
2020-03-23 07:08:27 +00:00
bcs PrintF.PutC.RTS
2020-03-16 06:50:15 +00:00
PrintF.H.1 jsr MATH32.AToHexAX
2020-03-23 07:08:27 +00:00
jsr PrintF.PutC
bcs PrintF.PutC.RTS
2019-09-04 15:35:50 +00:00
txa
2020-02-14 16:32:52 +00:00
*--------------------------------------
2020-03-23 07:08:27 +00:00
PrintF.PutC phy
2020-02-14 16:32:52 +00:00
ldy PrintF.Cnt
sta (pIOBuf),y
ply
inc PrintF.Cnt
bne .8
lda PrintF.hFILE
bne .9
inc pIOBuf+1
inc PrintF.Cnt+1
.8 clc
rts
2020-03-10 16:42:07 +00:00
2020-02-14 16:32:52 +00:00
.9 lda #E.BUF
sec
2020-03-23 07:08:27 +00:00
PrintF.PutC.RTS rts
2020-02-14 16:32:52 +00:00
*/--------------------------------------
2020-02-16 20:45:16 +00:00
* # ScanF (BLOCKING)
* # FScanF (BLOCKING)
2020-02-14 16:32:52 +00:00
* # SScanF
* Read formatted data from string
* ## C
2020-02-16 20:45:16 +00:00
* `int scanf(const char *format, ...);`
* `int fscanf(short int stream, const char *format, ...);`
2020-02-14 16:32:52 +00:00
* `int sscanf ( const char *s, const char *format, ... );`
* ## ASM
* **In:**
2020-02-16 20:45:16 +00:00
* ScanF :
* `>PUSHW format`
* `>PUSHW ptr`
* `...`
* `>PUSHB bytecount`
* `>SYSCALL scanf`
* FScanF :
* `>PUSHB stream`
* `>PUSHW format`
* `>PUSHW ptr`
* `...`
* `>PUSHB bytecount`
* `>SYSCALL fscanf`
* SScanF :
2020-02-14 16:32:52 +00:00
* `>PUSHW s`
* `>PUSHW format`
2020-02-16 20:45:16 +00:00
* `>PUSHW ptr`
* `...`
* `>PUSHB bytecount`
* `>SYSCALL sscanf`
* Specifiers :
2020-02-14 16:32:52 +00:00
* + %i : short int
* + %d : byte
* + %I : int
* + %D : word
* + %L : long int
* + %U : dword
* + %h : HEX byte
* + %H : HEX word
* + %s : string
* TODO : %10s
* ## RETURN VALUE
* A = Number of arguments filled.
*\--------------------------------------
2020-02-16 20:45:16 +00:00
K.ScanF ldy #S.PS.hStdIn
2020-02-28 07:21:46 +00:00
lda (pPS),y
2020-02-16 20:45:16 +00:00
sta PrintF.hFILE
2020-03-10 16:42:07 +00:00
ldx #1
.HS 2C BIT ABS
2020-02-16 20:45:16 +00:00
*--------------------------------------
2020-03-10 16:42:07 +00:00
K.FScanF ldx #2
.HS 2C BIT ABS
2020-02-16 20:45:16 +00:00
*--------------------------------------
2020-03-10 16:42:07 +00:00
K.SScanF ldx #3
2020-02-16 20:45:16 +00:00
*--------------------------------------
2020-04-13 17:04:02 +00:00
K.SScanF.1 clc format string->ptr1
jsr STDIO.GetParams
stx ZPPtr2
sta ZPPtr2+1 Output buffer->ZPPtr2
sty STDIO.ExitPopCnt Total bytes to POP
2020-04-02 06:32:25 +00:00
2020-03-25 07:19:20 +00:00
ldx PrintF.hFILE
beq .1
>PUSHWI 256
>PUSHW pIOBuf
txa
jsr K.FGetS
bcc .1
tax
bne PrintF.PutC.RTS
>RET 4
2020-04-02 06:32:25 +00:00
.1 jsr SHARED.GetCharPtr1 End Of format?
2020-02-14 16:32:52 +00:00
beq .8
cmp #'%' Escape ?
beq .2
cmp #C.SPACE Space ?
beq .12
2020-03-23 07:08:27 +00:00
sta .11+1
2020-04-02 06:32:25 +00:00
jsr SHARED.GetCharPtr2
beq .9
2020-03-23 07:08:27 +00:00
.11 cmp #$ff Same char in string?
beq .1
bra .9
2020-02-14 16:32:52 +00:00
2020-04-02 06:32:25 +00:00
.12 jsr SHARED.GetCharPtr2
beq .9
cmp #C.SPACE
bne .9
2020-02-14 16:32:52 +00:00
2020-04-02 06:32:25 +00:00
.13 jsr SHARED.GetCharPtr2
2020-03-23 07:08:27 +00:00
cmp #C.SPACE another space ?
2020-04-02 06:32:25 +00:00
beq .13
2020-02-14 16:32:52 +00:00
2020-04-02 06:32:25 +00:00
bra .1
2020-02-14 16:32:52 +00:00
2020-04-02 06:32:25 +00:00
.2 jsr SHARED.GetCharPtr1 Get specifier after %
2020-02-14 16:32:52 +00:00
beq .9 unexpected End of format after "%" ?
ldx #K.SScanFJMP-K.SScanFTBL-2
.3 cmp K.SScanFTBL,x
beq .4
dex
dex
bpl .3
.9 lda #MLI.E.EOF
sec
2020-02-19 16:42:05 +00:00
jmp STDIO.Exit
2020-02-14 16:32:52 +00:00
2020-02-19 16:42:05 +00:00
.4 jsr STDIO.GetStackByte
bcs .9
2020-04-07 06:01:38 +00:00
sta ZPPtr3+1
2020-02-19 16:42:05 +00:00
jsr STDIO.GetStackByte
2020-02-14 16:32:52 +00:00
bcs .9
2020-04-07 06:01:38 +00:00
sta ZPPtr3
2020-02-19 16:42:05 +00:00
2020-02-14 16:32:52 +00:00
jsr .5
bcs .9 out of Ptr on stack
inc .8+1 parsed one more arg!
bra .1
.8 lda #$ff SELF MODIFIED Arg processed
clc
2020-02-19 16:42:05 +00:00
jmp STDIO.Exit
2020-02-14 16:32:52 +00:00
*--------------------------------------
.5 jmp (K.SScanFJMP,x)
*--------------------------------------
K.SScanFTBL .DA #'i,#1,#'d,#1,#'I,#2,#'D,#2,#'l,#4,#'u,#4,#'h,#1,#'H,#2,#'s,#2
K.SScanFJMP .DA K.SScanF.I
.DA K.SScanF.D
.DA K.SScanF.II
.DA K.SScanF.DD
.DA K.SScanF.L
.DA K.SScanF.U
.DA K.SScanF.H
.DA K.SScanF.HH
.DA K.SScanF.S
*--------------------------------------
K.SScanF.I
K.SScanF.D
K.SScanF.II
K.SScanF.DD
K.SScanF.L
K.SScanF.U lda K.SScanFTBL+1,x Get VAR size
pha Save VAL size
2020-03-16 06:50:15 +00:00
jsr MATH32.Dec2ACC32
2020-02-14 16:32:52 +00:00
bra K.SScanF.GetVAL
*--------------------------------------
K.SScanF.HH
K.SScanF.H lda K.SScanFTBL+1,x Get VAR size
pha
2020-03-16 06:50:15 +00:00
jsr MATH32.Hex2ACC32
2020-02-14 16:32:52 +00:00
2020-04-02 06:32:25 +00:00
K.SScanF.GetVAL jsr SHARED.AddYToPtr2 Y=char count parsed
2020-02-14 16:32:52 +00:00
.1 ply get back VAL size
.2 lda ACC32-1,y
dey
sta (ZPPtr3),y
bne .2
.9 rts
*--------------------------------------
K.SScanF.S ldy #$ff
.1 iny
2020-04-02 06:32:25 +00:00
lda (ZPPtr2),y Get char in string to scan
2020-02-14 16:32:52 +00:00
sta (ZPPtr3),y store in param ptr
beq K.SScanF.Fwd end of string to scan ?
2020-04-02 06:32:25 +00:00
cmp (ZPPtr1) match format next char ?
2020-02-14 16:32:52 +00:00
beq .2
cmp #C.SPACE is it a space ?
bne .1
.2 lda #0 add \0 to param ptr
sta (ZPPtr3),y
2020-04-02 06:32:25 +00:00
K.SScanF.Fwd jmp SHARED.AddYToPtr2 Y=char count parsed
2020-03-23 07:08:27 +00:00
*--------------------------------------
2020-04-13 17:04:02 +00:00
* IN:
* CC : format in ZPPtr1
* CS : format in ZPPtr2
2020-03-10 16:42:07 +00:00
* X = 3 : get format & buffer
* X = 2 : get format & hFile
* X = 1 : get format only
2020-04-13 17:04:02 +00:00
* OUT:
* X = Buf LO
* A = Buf HI
* format on stack
* Y = BytePtr
2020-03-10 16:42:07 +00:00
*--------------------------------------
2020-04-13 17:04:02 +00:00
STDIO.GetParams stz PrintF.Cnt
2020-03-25 07:19:20 +00:00
stz PrintF.Cnt+1
lda (pStack) Bytecount
2020-03-04 16:38:32 +00:00
2020-02-14 16:32:52 +00:00
tay
2020-04-13 17:04:02 +00:00
sty STDIO.StackBytePtr
2020-02-19 16:42:05 +00:00
2020-03-04 16:38:32 +00:00
iny
2020-02-19 16:42:05 +00:00
lda (pStack),y format LO
2020-04-13 17:04:02 +00:00
pha
2020-03-23 07:08:27 +00:00
2020-02-19 16:42:05 +00:00
iny
lda (pStack),y format HI
2020-04-13 17:04:02 +00:00
bcs .10
2020-04-02 06:32:25 +00:00
sta ZPPtr1+1
2020-04-13 17:04:02 +00:00
pla
sta ZPPtr1
bra .11
2020-02-19 16:42:05 +00:00
2020-04-13 17:04:02 +00:00
.10 sta ZPPtr2+1
pla
sta ZPPtr2
.11 dex
2020-03-10 16:42:07 +00:00
beq .1
dex
beq .2
.3 stz PrintF.hFILE
2020-02-19 16:42:05 +00:00
2020-03-23 07:08:27 +00:00
iny
2020-02-19 16:42:05 +00:00
lda (pStack),y str LO
2020-04-13 17:04:02 +00:00
tax
2020-03-23 07:08:27 +00:00
2020-02-19 16:42:05 +00:00
iny
lda (pStack),y str HI
2020-04-13 17:04:02 +00:00
2020-02-19 16:42:05 +00:00
rts
2020-03-10 16:42:07 +00:00
2020-03-23 07:08:27 +00:00
.2 iny
lda (pStack),y hFILE
2020-03-10 16:42:07 +00:00
sta PrintF.hFILE
2020-04-13 17:04:02 +00:00
.1 ldx #K.IOBuf
2020-02-19 16:42:05 +00:00
lda /K.IOBuf
2020-04-13 17:04:02 +00:00
STDIO.GetParams.RTS
2020-02-19 16:42:05 +00:00
rts
2020-02-14 16:32:52 +00:00
*--------------------------------------
2020-04-13 17:04:02 +00:00
STDIO.GetStackPtr
jsr STDIO.GetStackByte
bcs STDIO.GetParams.RTS
tax
*--------------------------------------
STDIO.GetStackByte
2020-02-14 16:32:52 +00:00
phy
2020-04-13 17:04:02 +00:00
ldy STDIO.StackBytePtr
2020-03-04 16:38:32 +00:00
beq .9
2020-02-14 16:32:52 +00:00
lda (pStack),y
2020-04-13 17:04:02 +00:00
dec STDIO.StackBytePtr
2020-03-04 16:38:32 +00:00
2020-02-14 16:32:52 +00:00
ply
clc
rts
.9 lda #E.STACK
2020-03-04 16:38:32 +00:00
ply
2020-02-14 16:32:52 +00:00
sec
2019-09-04 15:35:50 +00:00
rts
*--------------------------------------
2020-02-19 16:42:05 +00:00
STDIO.Exit php
pha
2020-03-04 16:38:32 +00:00
2020-02-19 16:42:05 +00:00
lda pStack
2020-04-10 11:22:09 +00:00
sec
2020-04-13 17:04:02 +00:00
adc STDIO.ExitPopCnt
2020-02-19 16:42:05 +00:00
sta pStack
2020-03-04 16:38:32 +00:00
2020-02-19 16:42:05 +00:00
pla
plp
rts
2020-02-16 20:45:16 +00:00
*--------------------------------------
2019-09-04 15:35:50 +00:00
MAN
SAVE USR/SRC/SYS/KERNEL.S.STDIO2
LOAD USR/SRC/SYS/KERNEL.S
ASM