NEW AUTO 3,1 *-------------------------------------- K.PrintF2 >LDYAI K.IOBuf >STYA pIOBuf ldy #S.PS.hStdOut lda (pPs),y sta PrintF.hFILE lda (pStack) Bytecount inc tay lda (pStack),y format LO sta ZPPtr2 iny lda (pStack),y format HI sta ZPPtr2+1 bra K.PrintF2.1 K.FPrintf2 >LDYAI K.IOBuf >STYA pIOBuf lda (pStack) Bytecount inc tay lda (pStack),y format LO sta ZPPtr2 iny lda (pStack),y format HI sta ZPPtr2+1 iny lda (pStack),y hFILE sta PrintF.hFILE bra K.PrintF2.1 K.SPrintf2 stz PrintF.hFILE lda (pStack) Bytecount inc tay lda (pStack),y format LO sta ZPPtr2 iny lda (pStack),y format HI sta ZPPtr2+1 iny lda (pStack),y str LO sta pIOBuf iny lda (pStack),y str HI sta pIOBuf+1 *-------------------------------------- K.PrintF2.1 sty PrintF2.Exit.Cnt+1 Total bytes to POP stz PrintF.Cnt stz PrintF.Cnt+1 .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 ?????? .4 jsr MATH.Dec2ACC32 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 jsr PrintF2.ESC .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 jsr MATH.Hex2ACC32 bcs .99 jsr SHARED.AddYToPtr2 .14 lda ACC32 bra .20 .19 lda PrintFTBL2.OUT,x .20 jsr PrintF.COut bcc .11 *-------------------------------------- .99 bra PrintF2.Exit *-------------------------------------- .8 ldx PrintF.hFILE beq .80 Writing to buffer, append \0 >PUSHW PrintF.Cnt Writing to File/dev... >PUSHWI K.IOBuf txa jsr K.FWrite bcc .81 tay bne .99 >RET 4 0=BLOCKING .80 ldy PrintF.Cnt A=0, Writing to buffer, append \0 sta (pIOBuf),y .81 >LDYA PrintF.Cnt * clc *-------------------------------------- PrintF2.Exit php pha lda pStack sec +Bytecount byte PrintF2.Exit.Cnt adc #$ff SELF MODIFIED sta pStack pla plp PrintF2.Exit.RTS rts *-------------------------------------- PrintF2.LocalGetByte lda (pStack) beq .9 tay dec sta (pStack) lda (pStack),y clc rts .9 lda #E.STACK sec rts *-------------------------------------- PrintF2.ESC jmp (.1,x) .1 .DA PrintF2.B .DA PrintF2.D,PrintF2.DD,PrintF2.U .DA PrintF2.E,PrintF2.F .DA PrintF2.H,PrintF2.HH .DA PrintF2.I,PrintF2.II,PrintF2.L .DA PrintF2.S,PrintF2.SS *-------------------------------------- PrintF2.B jsr PrintF2.LocalGetByte bcs PrintF2.B.RTS ldy #8 .1 asl pha lda #'0'/2 rol jsr PrintF.COut bcs .9 pla dey bne .1 rts .9 ply PrintF2.B.RTS rts *-------------------------------------- PrintF2.I sec signed short .HS 90 BCC PrintF2.D clc unsigned short (BYTE) ldy #1 bra PrintF2.NUM PrintF2.II sec signed int .HS 90 BCC PrintF2.DD clc unsigned int (WORD) ldy #2 bra PrintF2.NUM PrintF2.L sec signed long .HS 90 BCC PrintF2.U clc unsigned long (DWORD) ldy #4 PrintF2.NUM ror ACC32.Sign jsr MATH.ACC32ZERO .1 jsr PrintF2.LocalGetByte bcs PrintF2.B.RTS sta ACC32-1,y dey bne .1 ldx K.PrintF.PadL ldy K.PrintF.PadC rol ACC32.Sign jsr MATH.ACC322STR10 bra PrintF2.StrNum *-------------------------------------- * EXP(8) 1(s) 1significants(31) * http://apple2.org.za/gswv/a2zine/GS.WorldView/Resources/GS.TECH.INFO/AppleSoft/ *-------------------------------------- PrintF2.E sec Force "E+12" .HS 90 BCC PrintF2.F clc lda (pStack) get current stack Ptr sec at least 5 bytes remaining ? sbc #5 bcc PrintF2.StrNum.Err 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 PrintF2.StrNum ldy #0 .2 lda A2osX.NumStrBuf,y beq .8 iny jsr PrintF.COut bcc .2 .9 rts .8 clc rts PrintF2.StrNum.Err lda #E.STACK sec rts *-------------------------------------- PrintF2.S ldy #$ff CSTR .HS 2C bit abs PrintF2.SS ldy #$00 PSTR sty .1+1 jsr PrintF2.LocalGetByte bcs .9 sta ZPPtr1+1 jsr PrintF2.LocalGetByte bcs .9 sta ZPPtr1 lda (ZPPtr1) if CSTR:last char=0, if PSTR:len=0 beq .8 ldy .1+1 .1 lda #$ff Self Modified bne .11 CSTR tya PSTR cmp (ZPPtr1) len check beq .2 .11 iny lda (ZPPtr1),y beq .2 jsr PrintF.COut bcs .9 lda K.PrintF.PadL beq .1 cpy K.PrintF.PadL bne .1 .8 clc rts .2 lda K.PrintF.PadL beq .8 .3 cpy K.PrintF.PadL beq .8 lda K.PrintF.PadC jsr PrintF.COut bcs .9 iny bne .3 * clc .9 rts *-------------------------------------- PrintF2.HH jsr PrintF2.LocalGetByte bcs PrintF2.COut.RTS pha LO byte jsr PrintF2.H plx bcs PrintF2.COut.RTS txa bra PrintF2.H.1 *-------------------------------------- PrintF2.H jsr PrintF2.LocalGetByte bcs PrintF2.COut.RTS PrintF2.H.1 jsr MATH.AToHexAX jsr PrintF.COut bcs PrintF2.COut.RTS txa jmp PrintF.COut PrintF2.COut.RTS rts *-------------------------------------- MAN SAVE USR/SRC/SYS/KERNEL.S.STDIO2 LOAD USR/SRC/SYS/KERNEL.S ASM