.export __printf
.import popax, pushax, pusheax, decsp6, push1, axlong, axulong
- .import __ctype
.import _ltoa, _ultoa
.import _strlower, _strlen
.importzp sp, ptr1, ptr2, tmp1, regbank, sreg
lda #<CharArg
ldx #>CharArg
jsr pushax
- jsr push1
-CallOutFunc:
- jmp (OutFunc) ; fout (OutData, &CharArg, 1)
+ jsr push1
+ jmp CallOutFunc ; fout (OutData, &CharArg, 1)
; ----------------------------------------------------------------------------
; Decrement the argument list pointer by 2
lda ArgLen
ldx ArgLen+1
jsr pushax
- jmp (OutFunc)
+ jmp CallOutFunc
; ----------------------------------------------------------------------------
; ltoa: Wrapper for _ltoa that pushes all arguments
iny
lda (OutData),y
- sta OutFunc
+ sta CallOutFunc+1
iny
lda (OutData),y
- sta OutFunc+1
+ sta CallOutFunc+2
; Start parsing the format string
ReadMod:
lda (Format),y
- cmp #'F'
- beq @L1 ; Read and ignore this one
- cmp #'N'
- beq @L1 ; Read and ignore this one
- cmp #'h'
- beq @L1 ; Read and ignore this one
- cmp #'L'
- beq @L1 ; Read and ignore this one
- cmp #'l'
+ cmp #'z' ; size_t - same as unsigned
+ beq @L2
+ cmp #'h' ; short - same as int
+ beq @L2
+ cmp #'t' ; ptrdiff_t - same as int
+ beq @L2
+ cmp #'j' ; intmax_t/uintmax_t - same as long
+ beq @L1
+ cmp #'L' ; long double
+ beq @L1
+ cmp #'l' ; long int
bne DoFormat
- lda #$FF
+@L1: lda #$FF
sta IsLong
-@L1: jsr IncFormatPtr
+@L2: jsr IncFormatPtr
jmp ReadMod
; Initialize the argument buffer pointers. We use a static buffer (ArgBuf) to
lda Prec+1
tay
sbc ArgLen+1
- bcc @L1
+ bcs @L1
stx ArgLen
sty ArgLen+1
; Save area for the zero page registers
RegSave: .res 6
-; Stuff from OutData. Is used as a vector and must be aligned
-OutFunc: .word 0
-
; One character argument for OutFunc
CharArg: .byte 0
Str: .word 0
ArgLen: .res 2
+.data
+
+; Stuff from OutData. Is used as a vector and must be aligned
+CallOutFunc: jmp $0000
+
+
+