Save a few bytes in printf and scanf.

This commit is contained in:
Stephen Heumann 2023-04-03 13:26:37 -05:00
parent de978dab48
commit fca8c1ef85

110
stdio.asm
View File

@ -4916,20 +4916,20 @@ fm4 cmp #'L' else if *format in ['L','h'] then
inc ~isByte inc ~isByte
fm5 inc4 format ++format fm5 inc4 format ++format
lda [format] find the proper format character lda [format] find the proper format character
and #$00FF
fm6 inc4 format fm6 inc4 format
ldx #fListEnd-fList-4 short M,I
ldx #fListEnd-fList-3
fm7 cmp fList,X fm7 cmp fList,X
beq fm8 beq fm8
dex dex
dex dex
dex dex
dex
bpl fm7 bpl fm7
long M,I
brl ps1 none found - continue brl ps1 none found - continue
fm8 pea ps1-1 push the return address fm8 long M,I
pea ps1-1 push the return address
inx call the subroutine inx call the subroutine
inx
jmp (fList,X) jmp (fList,X)
; ;
; Flag - Read and process a flag character ; Flag - Read and process a flag character
@ -5020,27 +5020,27 @@ val ds 2 value
; ;
; List of format specifiers and the equivalent subroutines ; List of format specifiers and the equivalent subroutines
; ;
fList dc c'%',i1'0',a'~Format_Percent' % fList dc c'%',a'~Format_Percent' %
dc c'a',i1'0',a'~Format_e' a (not formatted correctly) dc c'a',a'~Format_e' a (not formatted correctly)
dc c'A',i1'0',a'~Format_E' A (not formatted correctly) dc c'A',a'~Format_E' A (not formatted correctly)
dc c'f',i1'0',a'~Format_f' f dc c'f',a'~Format_f' f
dc c'F',i1'0',a'~Format_f' F dc c'F',a'~Format_f' F
dc c'e',i1'0',a'~Format_e' e dc c'e',a'~Format_e' e
dc c'E',i1'0',a'~Format_E' E dc c'E',a'~Format_E' E
dc c'g',i1'0',a'~Format_g' g dc c'g',a'~Format_g' g
dc c'G',i1'0',a'~Format_G' G dc c'G',a'~Format_G' G
dc c'n',i1'0',a'~Format_n' n dc c'n',a'~Format_n' n
dc c's',i1'0',a'~Format_s' s dc c's',a'~Format_s' s
dc c'b',i1'0',a'~Format_b' b dc c'b',a'~Format_b' b
dc c'P',i1'0',a'~Format_P' P dc c'P',a'~Format_P' P
dc c'p',i1'0',a'~Format_p' p dc c'p',a'~Format_p' p
dc c'c',i1'0',a'~Format_c' c dc c'c',a'~Format_c' c
dc c'X',i1'0',a'~Format_X' X dc c'X',a'~Format_X' X
dc c'x',i1'0',a'~Format_x' x dc c'x',a'~Format_x' x
dc c'o',i1'0',a'~Format_o' o dc c'o',a'~Format_o' o
dc c'u',i1'0',a'~Format_u' u dc c'u',a'~Format_u' u
dc c'd',i1'0',a'~Format_d' d dc c'd',a'~Format_d' d
dc c'i',i1'0',a'~Format_d' i dc c'i',a'~Format_d' i
fListEnd anop fListEnd anop
end end
@ -6124,7 +6124,7 @@ fm2b inc ~size
fm2c inc ~size fm2c inc ~size
bra fm4 bra fm4
fm3 cmp #'h' 'h' specifies short int fm3 cmp #'h' 'h' specifies short int
bne fm5 bne fm6
inc4 format unless it is 'hh' for char types inc4 format unless it is 'hh' for char types
lda [format] lda [format]
and #$00FF and #$00FF
@ -6133,21 +6133,21 @@ fm3 cmp #'h' 'h' specifies short int
dec ~size dec ~size
fm4 inc4 format ignore the character fm4 inc4 format ignore the character
fm5 lda [format] find the proper format character lda [format] find the proper format character
and #$00FF
fm6 inc4 format fm6 inc4 format
ldx #fListEnd-fList-4 short M,I
ldx #fListEnd-fList-3
fm7 cmp fList,X fm7 cmp fList,X
beq fm8 beq fm8
dex dex
dex dex
dex dex
dex
bpl fm7 bpl fm7
long M,I
brl ps1 none found - continue brl ps1 none found - continue
fm8 pea ps1-1 push the return address fm8 long M,I
pea ps1-1 push the return address
inx call the subroutine inx call the subroutine
inx
jmp (fList,X) jmp (fList,X)
; ;
; GetSize - get a numeric value ; GetSize - get a numeric value
@ -6189,28 +6189,28 @@ val ds 2 value
; ;
; List of format specifiers and the equivalent subroutines ; List of format specifiers and the equivalent subroutines
; ;
fList dc c'd',i1'0',a'~Scan_d' d fList dc c'd',a'~Scan_d' d
dc c'i',i1'0',a'~Scan_i' i dc c'i',a'~Scan_i' i
dc c'u',i1'0',a'~Scan_u' u dc c'u',a'~Scan_u' u
dc c'o',i1'0',a'~Scan_o' o dc c'o',a'~Scan_o' o
dc c'x',i1'0',a'~Scan_x' x dc c'x',a'~Scan_x' x
dc c'X',i1'0',a'~Scan_x' X dc c'X',a'~Scan_x' X
dc c'p',i1'0',a'~Scan_p' p dc c'p',a'~Scan_p' p
dc c'c',i1'0',a'~Scan_c' c dc c'c',a'~Scan_c' c
dc c's',i1'0',a'~Scan_s' s dc c's',a'~Scan_s' s
dc c'b',i1'0',a'~Scan_b' b dc c'b',a'~Scan_b' b
dc c'P',i1'0',a'~Scan_P' P dc c'P',a'~Scan_P' P
dc c'n',i1'0',a'~Scan_n' n dc c'n',a'~Scan_n' n
dc c'a',i1'0',a'~Scan_f' a dc c'a',a'~Scan_f' a
dc c'A',i1'0',a'~Scan_f' A dc c'A',a'~Scan_f' A
dc c'f',i1'0',a'~Scan_f' f dc c'f',a'~Scan_f' f
dc c'F',i1'0',a'~Scan_f' F dc c'F',a'~Scan_f' F
dc c'e',i1'0',a'~Scan_f' e dc c'e',a'~Scan_f' e
dc c'E',i1'0',a'~Scan_f' E dc c'E',a'~Scan_f' E
dc c'g',i1'0',a'~Scan_f' g dc c'g',a'~Scan_f' g
dc c'G',i1'0',a'~Scan_f' G dc c'G',a'~Scan_f' G
dc c'%',i1'0',a'~Scan_percent' % dc c'%',a'~Scan_percent' %
dc c'[',i1'0',a'~Scan_lbrack' [ dc c'[',a'~Scan_lbrack' [
fListEnd anop fListEnd anop
; ;
; Other local data ; Other local data