2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2017-08-23 15:05:29 +00:00
|
|
|
|
PREFIX /A2OSX.BUILD
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* # FPutC.AY
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Print A (char) to Node
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* A : char to print
|
|
|
|
|
* Y = hFILE
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FPutC.AY sta K.PutC.Char
|
|
|
|
|
sty K.PutC.Node
|
|
|
|
|
tya
|
|
|
|
|
phy
|
|
|
|
|
bne K.PutChar.A.1
|
|
|
|
|
K.PutChar.A.8 ply
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # PutChar.A
|
|
|
|
|
* Print A (char) to StdOut
|
|
|
|
|
* ## In:
|
|
|
|
|
* A : char to print
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.PutChar.A sta K.PutC.Char
|
|
|
|
|
phy
|
|
|
|
|
ldy #S.PS.hStdOut
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
beq K.PutChar.A.8 NUL
|
|
|
|
|
|
|
|
|
|
phx
|
|
|
|
|
|
|
|
|
|
K.PutChar.A.1 sta K.PutC.Node
|
|
|
|
|
jsr K.GetMemPtr.A
|
|
|
|
|
>STYA pDev
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.T
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
asl
|
|
|
|
|
tax
|
|
|
|
|
jsr K.PutChar.A.Jmp
|
|
|
|
|
|
|
|
|
|
plx
|
|
|
|
|
ply
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.PutChar.A.Jmp jmp (.1,x)
|
|
|
|
|
.1 .DA K.PutChar.A.REG
|
|
|
|
|
.DA STDIO.IOERR DIR
|
|
|
|
|
.DA K.PutChar.A.CDEV
|
|
|
|
|
.DA STDIO.IOERR BDEV
|
|
|
|
|
.DA STDIO.IOERR LNK
|
|
|
|
|
.DA STDIO.IOERR DSOCK
|
|
|
|
|
.DA K.PutChar.A.SSOCK
|
|
|
|
|
.DA K.PutChar.A.FIFO
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.PutChar.A.REG lda K.PutC.Node
|
|
|
|
|
ldy K.PutC.Char
|
|
|
|
|
jmp K.FWrite.AY
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.PutChar.A.CDEV ldy #S.NODE.DEV.JMP
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
sta .1+1
|
|
|
|
|
iny
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
sta .1+2
|
|
|
|
|
lda K.PutC.Char
|
|
|
|
|
ldx #DEVMGR.WRITE
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.PutChar.A.SSOCK
|
|
|
|
|
lda (pDev) #S.NODE.HANDLER
|
|
|
|
|
jsr K.GetMemPtr.A
|
|
|
|
|
>STYA .1
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.SSOCK.HSKT
|
|
|
|
|
>PUSHB (pDev),y
|
|
|
|
|
>PUSHB K.PutC.Char
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.SSOCK.WRITE
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
tax Function Offset for write
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.PutChar.A.FIFO
|
|
|
|
|
ldy #S.NODE.FIFO.S
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
beq .9 Remote PS did not opened yet the pipe
|
|
|
|
|
cmp #S.NODE.FIFO.S.Closed
|
|
|
|
|
beq .99 Remote PS closed the Pipe
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.FIFO.hMem
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
jsr K.GetMemPtr.A
|
|
|
|
|
>STYA .1+2
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.FIFO.Head
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
inc
|
|
|
|
|
dey #S.NODE.FIFO.Tail
|
|
|
|
|
cmp (pDev),y
|
|
|
|
|
beq .9 FIFO is full
|
|
|
|
|
iny
|
|
|
|
|
sta (pDev),y
|
|
|
|
|
tay
|
|
|
|
|
lda K.PutC.Char
|
|
|
|
|
.1 sta $ffff,y
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
2017-10-26 16:01:54 +00:00
|
|
|
|
.9 lda #MLI.E.VOLFULL
|
2017-09-29 14:57:20 +00:00
|
|
|
|
.HS 2C bit abs
|
2017-10-26 16:01:54 +00:00
|
|
|
|
.99 lda #MLI.E.EOF
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.PutC.Char .BS 1
|
|
|
|
|
K.PutC.Node .BS 1
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # GetChar
|
|
|
|
|
* Get char from StdIn
|
|
|
|
|
* ## In:
|
|
|
|
|
* none.
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
* A = char
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.GetChar ldy #S.PS.hStdIn
|
|
|
|
|
lda (pPs),y
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # GetC.A
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Get char from Node
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* A = hFILE
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
* A = char
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.GetC.A sta K.PutC.Node
|
|
|
|
|
jsr K.GetMemPtr.A
|
|
|
|
|
>STYA pDev
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.T
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
asl
|
|
|
|
|
tax
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
|
|
|
|
|
.1 .DA K.GetC.REG
|
|
|
|
|
.DA STDIO.IOERR DIR
|
|
|
|
|
.DA K.GetC.CDEV
|
|
|
|
|
.DA STDIO.IOERR BDEV
|
|
|
|
|
.DA STDIO.IOERR LNK
|
|
|
|
|
.DA STDIO.IOERR DSOCK
|
|
|
|
|
.DA K.GetC.SSOCK
|
|
|
|
|
.DA K.GetC.FIFO
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.GetC.REG lda K.PutC.Node
|
|
|
|
|
jmp K.FRead.A
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.GetC.CDEV ldx #DEVMGR.READ
|
|
|
|
|
ldy #S.NODE.DEV.JMP
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
sta .1+1
|
|
|
|
|
iny
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
sta .1+2
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.GetC.SSOCK lda (pDev) #S.NODE.HANDLER
|
|
|
|
|
jsr K.GetMemPtr.A
|
|
|
|
|
>STYA .1
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.SSOCK.READ
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
tax Function Offset for READ
|
|
|
|
|
|
|
|
|
|
ldy #S.NODE.SSOCK.HSKT
|
|
|
|
|
lda (pDev),y
|
|
|
|
|
|
|
|
|
|
.1 jmp $ffff
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.GetC.FIFO
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FPutS
|
|
|
|
|
* Write String to FILE
|
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHW : CPtr
|
|
|
|
|
* PUSHB : hFILE
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FPutS
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # PutS.YA
|
|
|
|
|
* Write String to StdOut
|
|
|
|
|
* ## In:
|
|
|
|
|
* Y,A : CPtr
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.PutS.YA
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FGetS
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Read String From Node
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHW : CPtr
|
|
|
|
|
* PUSHB : hFILE
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FGetS
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # GetS.YA
|
|
|
|
|
* Read String From StdIn
|
|
|
|
|
* ## In:
|
|
|
|
|
* Y,A : CPtr
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC = success
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.GetS.YA
|
|
|
|
|
bra *
|
|
|
|
|
*/--------------------------------------
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* # FOpen
|
|
|
|
|
* Open a file
|
|
|
|
|
* ## In :
|
|
|
|
|
* PUSHW = AUXTYPE
|
|
|
|
|
* PUSHB = TYPE
|
|
|
|
|
* PUSHB = MODE
|
|
|
|
|
* SYS.FOpen.R : if R and !exists -> ERROR
|
|
|
|
|
* SYS.FOpen.W : if W and !exists -> CREATE
|
|
|
|
|
* SYS.FOpen.A : Append
|
|
|
|
|
* SYS.FOpen.T : Open/Append in Text mode
|
|
|
|
|
* SYS.FOpen.X : Create if not exists
|
|
|
|
|
* PUSHW = PATH (PSTR)
|
|
|
|
|
* ## Out :
|
|
|
|
|
* CC : A = hFILE
|
|
|
|
|
* CS : A = EC
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FOpen jsr PFT.CheckPathSTK
|
|
|
|
|
jsr STDIO.PullMLIPath
|
|
|
|
|
>PULLB K.FOpen.MODE
|
|
|
|
|
>PULLB K.FOpen.TYPE
|
|
|
|
|
>PULLW K.FOpen.AUXTYPE
|
|
|
|
|
|
|
|
|
|
>MLICALL MLIGETFILEINFO
|
|
|
|
|
bcc K.FOpen.10 Already Exists
|
|
|
|
|
|
|
|
|
|
bit K.FOpen.MODE Create if not exists ?
|
|
|
|
|
bpl K.FOpen.9 No, return MLI error
|
|
|
|
|
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda #S.FI.A.FULL Yes, Create...
|
2017-08-24 12:46:48 +00:00
|
|
|
|
sta K.MLI.PARAMS+3 Access
|
|
|
|
|
lda K.FOpen.TYPE
|
|
|
|
|
sta K.MLI.PARAMS+4 File type
|
|
|
|
|
>LDYA K.FOpen.AUXTYPE
|
|
|
|
|
>STYA K.MLI.PARAMS+5 Aux type
|
2017-10-27 14:56:46 +00:00
|
|
|
|
lda #S.FI.ST.STD
|
2017-08-24 12:46:48 +00:00
|
|
|
|
sta K.MLI.PARAMS+7
|
|
|
|
|
|
|
|
|
|
ldx #3
|
|
|
|
|
|
|
|
|
|
.1 lda DATELO,x
|
|
|
|
|
sta K.MLI.PARAMS+8,x
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
>MLICALL MLICREATE
|
|
|
|
|
bcc K.FOpen.10
|
|
|
|
|
K.FOpen.9 rts
|
|
|
|
|
|
|
|
|
|
K.FOpen.10 >LDYAI S.NODE.REG
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.GetMem0.YA
|
2017-08-24 12:46:48 +00:00
|
|
|
|
bcs K.FOpen.9
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
2017-10-09 15:30:48 +00:00
|
|
|
|
stx .8+1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
|
|
|
|
jsr STDIO.SetIOBUF
|
|
|
|
|
bcs .98
|
|
|
|
|
|
|
|
|
|
>MLICALL MLIOPEN
|
|
|
|
|
bcs .98
|
|
|
|
|
|
|
|
|
|
lda K.MLI.PARAMS+5 get ref_num
|
|
|
|
|
ldy #S.NODE.REG.REF
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
sta K.MLI.PARAMS+1 Next MLI Calls are REF_NUM based
|
|
|
|
|
|
|
|
|
|
lda K.FOpen.MODE
|
|
|
|
|
bit #SYS.FOpen.W
|
|
|
|
|
beq .20 Write mode ?
|
|
|
|
|
|
|
|
|
|
and #SYS.FOpen.A Append ?
|
|
|
|
|
bne .11 yes, go to end of file
|
|
|
|
|
|
|
|
|
|
stz K.MLI.PARAMS+2
|
|
|
|
|
stz K.MLI.PARAMS+3
|
|
|
|
|
stz K.MLI.PARAMS+4
|
|
|
|
|
>MLICALL MLISETEOF no, reset size to 0
|
|
|
|
|
bcs .98
|
|
|
|
|
bra .20
|
|
|
|
|
|
|
|
|
|
.11 >MLICALL MLIGETEOF
|
|
|
|
|
bcs .98
|
|
|
|
|
|
|
|
|
|
>MLICALL MLISETMARK
|
|
|
|
|
bcs .98
|
|
|
|
|
|
|
|
|
|
.20 lda K.FOpen.MODE
|
|
|
|
|
and #SYS.FOpen.T Text Mode ?
|
|
|
|
|
beq .30
|
|
|
|
|
|
|
|
|
|
lda #$FF
|
|
|
|
|
sta K.MLI.PARAMS+2
|
|
|
|
|
lda #$0D
|
|
|
|
|
sta K.MLI.PARAMS+3
|
|
|
|
|
>MLICALL MLINEWLINE
|
|
|
|
|
|
|
|
|
|
.30 ldy #S.NODE.T
|
|
|
|
|
lda #S.NODE.T.REG
|
|
|
|
|
sta (ZPPtr1),y
|
2017-10-09 15:30:48 +00:00
|
|
|
|
.8 lda #$ff Self Modified
|
2017-08-24 12:46:48 +00:00
|
|
|
|
clc
|
|
|
|
|
rts CC
|
|
|
|
|
|
|
|
|
|
.98 pha save MLI error
|
2017-10-09 15:30:48 +00:00
|
|
|
|
lda .8+1
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.FClose.A.1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
pla get back MLI error
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.FOpen.MODE .BS 1
|
|
|
|
|
K.FOpen.TYPE .BS 1
|
|
|
|
|
K.FOpen.AUXTYPE .BS 2
|
|
|
|
|
*/--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
* # FClose.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* Close a file
|
|
|
|
|
* ## In :
|
|
|
|
|
* A = hFILE
|
|
|
|
|
* ## Out :
|
|
|
|
|
*\--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
K.FClose.A jsr PFT.CheckNodeA
|
2017-08-24 12:46:48 +00:00
|
|
|
|
pha
|
2017-08-25 06:37:21 +00:00
|
|
|
|
jsr K.GetMemPtr.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
pla
|
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
K.FClose.A.1 sta K.FClose.A.2+1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
ldy #S.NODE.REG.REF
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .1
|
|
|
|
|
sta K.MLI.PARAMS+1
|
|
|
|
|
>MLICALL MLICLOSE
|
|
|
|
|
|
|
|
|
|
.1 ldy #S.NODE.REG.IOBUF
|
|
|
|
|
lda (ZPPtr1),y
|
2017-08-25 06:37:21 +00:00
|
|
|
|
beq K.FClose.A.2
|
|
|
|
|
jsr K.FreeMem.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
|
2017-08-25 06:37:21 +00:00
|
|
|
|
K.FClose.A.2 lda #$ff Self Modified
|
|
|
|
|
jmp K.FreeMem.A
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*/--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
* # FRead.A
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Read ONE byte (A) from file (Y)
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* ## In :
|
|
|
|
|
* A = hFILE
|
|
|
|
|
* ## Out :
|
|
|
|
|
* A = Byte Read
|
|
|
|
|
*\--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
K.FRead.A jsr PFT.CheckNodeA
|
2017-08-24 12:46:48 +00:00
|
|
|
|
ldx #MLIREAD
|
|
|
|
|
bra K.FReadWrite.0
|
|
|
|
|
*/--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
* # FWrite.AY
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Write ONE byte (A) To file (Y)
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* A = hFILE
|
|
|
|
|
* Y = char
|
|
|
|
|
* # Out:
|
|
|
|
|
* Y,A = Bytes Written
|
|
|
|
|
*\--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
K.FWrite.AY jsr PFT.CheckNodeA
|
|
|
|
|
sty K.FWrite.AY.Buf
|
2017-08-24 12:46:48 +00:00
|
|
|
|
ldx #MLIWRITE
|
|
|
|
|
K.FReadWrite.0 jsr STDIO.GetRefNum
|
2017-08-25 06:37:21 +00:00
|
|
|
|
>LDYAI K.FWrite.AY.Buf
|
2017-08-24 12:46:48 +00:00
|
|
|
|
>STYA K.MLI.PARAMS+2
|
|
|
|
|
lda #1
|
|
|
|
|
sta K.MLI.PARAMS+4
|
|
|
|
|
stz K.MLI.PARAMS+5
|
|
|
|
|
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
|
2017-11-05 21:23:21 +00:00
|
|
|
|
jsr GP.MLICall
|
2017-08-24 12:46:48 +00:00
|
|
|
|
bcs .9
|
2017-08-25 06:37:21 +00:00
|
|
|
|
lda K.FWrite.AY.Buf
|
2017-08-24 12:46:48 +00:00
|
|
|
|
.9 rts
|
2017-08-25 06:37:21 +00:00
|
|
|
|
K.FWrite.AY.Buf .BS 1
|
2017-08-24 12:46:48 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FRead
|
|
|
|
|
* Read bytes from file
|
|
|
|
|
* ## In :
|
|
|
|
|
* PUSHW = Dest Ptr
|
|
|
|
|
* PUSHW = Bytes To Read
|
|
|
|
|
* PUSHB = hFILE
|
|
|
|
|
* ## Out :
|
|
|
|
|
* Y,A = Bytes Read
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FRead jsr PFT.CheckNodeSTK
|
|
|
|
|
ldx #MLIREAD
|
|
|
|
|
bra K.FReadWrite.1
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # FWrite
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Write bytes to file
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHW = Src Ptr
|
|
|
|
|
* PUSHW = Bytes To Write
|
|
|
|
|
* PUSHB = hFILE
|
|
|
|
|
* # Out:
|
|
|
|
|
* Y,A = Bytes Written
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FWrite jsr PFT.CheckNodeSTK
|
|
|
|
|
ldx #MLIWRITE
|
|
|
|
|
K.FReadWrite.1 >PULLA
|
|
|
|
|
jsr STDIO.GetRefNum
|
2017-08-25 15:02:16 +00:00
|
|
|
|
>PULLW K.MLI.PARAMS+4
|
|
|
|
|
>PULLW K.MLI.PARAMS+2
|
|
|
|
|
|
|
|
|
|
lda #4 Param Count = 4 for MLIREAD & MLIWRITE
|
2017-11-05 21:23:21 +00:00
|
|
|
|
jsr GP.MLICall
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
>LDYA K.MLI.PARAMS+6
|
|
|
|
|
.9 rts
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* # FFlush.A
|
2017-08-23 15:05:29 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* A = hFILE
|
|
|
|
|
*\--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
K.FFlush.A jsr PFT.CheckNodeA
|
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>MLICALL MLIFLUSH
|
|
|
|
|
rts
|
|
|
|
|
*/-------------------------------------
|
|
|
|
|
* # FSeek
|
2017-10-10 15:40:23 +00:00
|
|
|
|
* Set the file-position indicator for hFILE
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* ## In:
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* PUSHW = Ptr to Offset (DWORD)
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* PUSHB = From
|
|
|
|
|
* PUSHB = hFILE
|
|
|
|
|
*\-------------------------------------
|
|
|
|
|
K.FSeek jsr PFT.CheckNodeSTK
|
|
|
|
|
>PULLA
|
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>PULLA FROM
|
2017-08-23 15:05:29 +00:00
|
|
|
|
tax
|
2017-10-09 15:30:48 +00:00
|
|
|
|
>PULLW ZPPtr1
|
|
|
|
|
cpx #SYS.FSeek.END+1
|
|
|
|
|
bcs .98
|
|
|
|
|
txa
|
|
|
|
|
asl
|
|
|
|
|
tax
|
|
|
|
|
|
|
|
|
|
jmp (.1,x)
|
|
|
|
|
|
|
|
|
|
.1 .DA .10
|
|
|
|
|
.DA .20
|
|
|
|
|
.DA .30
|
|
|
|
|
* K.FSeek.SET
|
|
|
|
|
.10 stz K.MLI.PARAMS+2
|
2017-08-25 15:02:16 +00:00
|
|
|
|
stz K.MLI.PARAMS+3
|
|
|
|
|
stz K.MLI.PARAMS+4
|
|
|
|
|
bra .8
|
|
|
|
|
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* K.FSeek.CUR
|
|
|
|
|
.20 >MLICALL MLIGETMARK
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcc .8
|
|
|
|
|
rts
|
|
|
|
|
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* K.FSeek.END
|
|
|
|
|
.30 >MLICALL MLIGETEOF
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-10-09 15:30:48 +00:00
|
|
|
|
.8 ldy #0
|
|
|
|
|
ldx #3 3 bytes, 24 bits!!!
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
clc
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-10-09 15:30:48 +00:00
|
|
|
|
.81 lda K.MLI.PARAMS+2,y
|
|
|
|
|
adc (ZPPtr1),y
|
|
|
|
|
sta K.MLI.PARAMS+2,y
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
2017-10-09 15:30:48 +00:00
|
|
|
|
iny
|
|
|
|
|
dex
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bne .81
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .99 Offset out of range!
|
|
|
|
|
|
2017-12-12 16:35:16 +00:00
|
|
|
|
.82 >MLICALL MLISETMARK
|
|
|
|
|
bcc .9
|
|
|
|
|
cmp #MLI.E.BEYEOF
|
|
|
|
|
bne .9
|
|
|
|
|
>MLICALL MLISETEOF
|
|
|
|
|
bcc .82
|
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.9 rts
|
|
|
|
|
|
2017-10-26 16:01:54 +00:00
|
|
|
|
.98 lda #K.E.SYN
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.HS 2C bit abs
|
2017-10-26 16:01:54 +00:00
|
|
|
|
.99 lda #K.E.FTB
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* # FEOF.A
|
2017-10-10 15:40:23 +00:00
|
|
|
|
* Test the end-of-file indicator for hFILE
|
2017-08-23 15:05:29 +00:00
|
|
|
|
* ## In:
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* A = hFILE
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC :
|
|
|
|
|
* A=0 EOF
|
|
|
|
|
* A !=0 NOT EOF
|
|
|
|
|
* CS :
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*\--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
K.FEOF.A jsr PFT.CheckNodeA
|
|
|
|
|
jsr STDIO.GetRefNum
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
|
|
|
|
>MLICALL MLIGETMARK
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bcs .9
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
|
|
|
|
ldy #2
|
|
|
|
|
|
|
|
|
|
.1 lda K.MLI.PARAMS+2,y
|
|
|
|
|
sta K.FEOF.A.MARK,y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2017-08-25 15:02:16 +00:00
|
|
|
|
|
|
|
|
|
>MLICALL MLIGETEOF
|
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-10-09 15:30:48 +00:00
|
|
|
|
ldy #2
|
|
|
|
|
|
|
|
|
|
.2 lda K.MLI.PARAMS+2,y
|
|
|
|
|
eor K.FEOF.A.MARK,y
|
2017-08-25 15:02:16 +00:00
|
|
|
|
bne .8
|
2017-10-09 15:30:48 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .2
|
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-08-25 15:02:16 +00:00
|
|
|
|
K.FEOF.A.MARK .BS 3
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* # FTell
|
2017-10-10 15:40:23 +00:00
|
|
|
|
* Return the current value of the file-position indicator
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHW = Ptr to Offset (DWORD)
|
|
|
|
|
* PUSHB = hFILE
|
|
|
|
|
* ## Out:
|
|
|
|
|
* Offset = Offset
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.FTell jsr PFT.CheckNodeSTK
|
|
|
|
|
>PULLA
|
|
|
|
|
jsr STDIO.GetRefNum
|
|
|
|
|
>PULLW ZPPtr1
|
|
|
|
|
>MLICALL MLIGETMARK
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
ldy #3
|
|
|
|
|
|
|
|
|
|
lda #0
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
|
|
|
|
|
dey
|
|
|
|
|
|
|
|
|
|
.1 lda K.MLI.PARAMS+2,y
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* # Remove.YA
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*\--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
K.Remove.YA jsr PFT.CheckPathYA
|
|
|
|
|
jsr STDIO.SetMLIPathYA
|
|
|
|
|
>MLICALL MLIDESTROY
|
|
|
|
|
rts
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* # Rename
|
|
|
|
|
* Rename a file
|
|
|
|
|
* ## In :
|
|
|
|
|
* PUSHW = New Name
|
|
|
|
|
* PUSHW = Old Name
|
|
|
|
|
* ## Out :
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*\--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
K.Rename jsr PFT.CheckPathSTK
|
|
|
|
|
jsr STDIO.PullMLIPath
|
|
|
|
|
>PULLW .1+1
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda $ffff,y Self Modified
|
|
|
|
|
beq .8
|
|
|
|
|
iny
|
|
|
|
|
sta K.Buf256,y
|
|
|
|
|
cpy #MLI.MAXPATH
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.8 sty K.Buf256
|
|
|
|
|
>LDYAI K.Buf256
|
|
|
|
|
>STYA K.MLI.PARAMS+3
|
|
|
|
|
|
2017-11-05 21:23:21 +00:00
|
|
|
|
>MLICALL MLIRENAME
|
2017-08-23 15:05:29 +00:00
|
|
|
|
rts
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # SScanF
|
2017-12-13 06:38:43 +00:00
|
|
|
|
* Scan a C-String (in progress)
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHW PTR to target buffer
|
|
|
|
|
* PUSHW PSTR pattern (ex: "%d.%d.%d.%d")
|
|
|
|
|
* %d : byte
|
|
|
|
|
* PUSHW PSTR to scan (ex: "192.168.1.5")
|
|
|
|
|
* ## Out:
|
|
|
|
|
*\--------------------------------------
|
2017-10-27 14:56:46 +00:00
|
|
|
|
K.SScanF jsr PullP1P2P3
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
|
|
|
|
ldy #0 Y = PTR in pattern
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
|
|
|
|
beq .9
|
|
|
|
|
tax X = COUNT to scan
|
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .1
|
|
|
|
|
inc ZPPtr1+1
|
|
|
|
|
|
|
|
|
|
.1 txa End Of String?
|
|
|
|
|
beq .8
|
|
|
|
|
tya
|
|
|
|
|
cmp (ZPPtr2) End of pattern?
|
|
|
|
|
beq .8
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
cmp #'%' Escape?
|
|
|
|
|
beq .2
|
|
|
|
|
cmp (ZPPtr1) Same char?
|
|
|
|
|
bne .9
|
|
|
|
|
jsr K.SScanF.IncPtr1
|
|
|
|
|
bne .1
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 tya
|
|
|
|
|
cmp (ZPPtr2) unexpected End of pattern after "%" ?
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
cmp #'d' BYTE ?
|
|
|
|
|
bne .3
|
|
|
|
|
|
2017-10-13 15:28:09 +00:00
|
|
|
|
* stz ASCBUF
|
2017-08-24 06:47:31 +00:00
|
|
|
|
.20 lda (ZPPtr1)
|
2017-10-10 15:40:23 +00:00
|
|
|
|
jsr STDIO.IsDigit
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bcs .21
|
|
|
|
|
phx
|
2017-10-13 15:28:09 +00:00
|
|
|
|
* inc ASCBUF
|
|
|
|
|
* ldx ASCBUF
|
|
|
|
|
* sta ASCBUF,x
|
2017-08-24 06:47:31 +00:00
|
|
|
|
plx
|
|
|
|
|
jsr K.SScanF.IncPtr1
|
|
|
|
|
bne .20 end of string ?
|
|
|
|
|
|
2017-10-10 15:40:23 +00:00
|
|
|
|
.21
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* jsr DEC2HEX AToF MIGRATION
|
|
|
|
|
|
|
|
|
|
bra *
|
|
|
|
|
|
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
lda HEXBUF
|
|
|
|
|
sta (ZPPtr3)
|
|
|
|
|
inc ZPPtr3
|
|
|
|
|
bne .1
|
|
|
|
|
inc ZPPtr3+1
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.3 cmp #'D' WORD ?
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.4 cmp #'s' STRING ?
|
|
|
|
|
bne .9
|
|
|
|
|
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.SScanF.IncPtr1
|
|
|
|
|
dex
|
|
|
|
|
beq .1
|
|
|
|
|
inc ZPPtr1
|
|
|
|
|
bne .1
|
|
|
|
|
inc ZPPtr1+1 never Zero
|
|
|
|
|
.1 rts
|
|
|
|
|
*/--------------------------------------
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* # PrintF.YA/SPrintF.YA/FPrintF.YA
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* Prints C-Style String
|
|
|
|
|
* ## In:
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* PrintF.YA :
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* Y,A = PTR to CStr
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* SPrintF.YA :
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* Y,A = PTR to CStr
|
|
|
|
|
* PULLW = Ptr to Dst Buffer
|
2017-08-24 12:46:48 +00:00
|
|
|
|
* FPrintF.YA :
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* Y,A = PTR to CStr
|
|
|
|
|
* PULLB = hNode
|
|
|
|
|
* ## Out:
|
|
|
|
|
* CC : success
|
|
|
|
|
* CS : error code from Output
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* Specifiers :
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* %b : pull 1 byte to Print BIN
|
|
|
|
|
* %B : pull 2 bytes to Print BIN
|
|
|
|
|
* %d : pull 1 byte unsigned DEC 0..255
|
|
|
|
|
* %D : pull 2 bytes unsigned DEC 0..65535
|
|
|
|
|
* %u : pull 2 bytes PTR to 4 bytes long unsigned DEC 0..4294967295
|
2017-10-16 15:41:48 +00:00
|
|
|
|
* %e : pull 2 bytes PTR to 5 Bytes float (-)1.23456789e+12
|
|
|
|
|
* %f : pull 2 bytes PTR to 5 Bytes float (-)3.1415
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* %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 2 bytes PTR to 4 bytes signed DEC -2147483648..2147483647
|
|
|
|
|
* %n : pull 1 byte to Print low Nibble HEX
|
|
|
|
|
* %N : pull 1 byte to Print high Nibble HEX
|
|
|
|
|
* %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)
|
|
|
|
|
* \\\\ : Print \
|
|
|
|
|
* \% : Print %
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* Modifiers for len and padding :
|
2017-08-24 06:47:31 +00:00
|
|
|
|
* %d : '9' '12'
|
|
|
|
|
* %2d : ' 9' '12'
|
|
|
|
|
* %02d : '09' '12'
|
|
|
|
|
* %11s : 'ABCDEFGH '
|
|
|
|
|
* %011s : 'ABCDEFGH000'
|
|
|
|
|
* %2f : '3.14'
|
|
|
|
|
*\--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.SPrintF.YA
|
|
|
|
|
* >STYA ZPPtr1
|
2017-09-29 14:57:20 +00:00
|
|
|
|
* >PULLW Printf.Cout.Ptr+1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.FPrintF.YA
|
|
|
|
|
* >STYA ZPPtr1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-08-24 12:46:48 +00:00
|
|
|
|
K.PrintF.YA >STYA ZPPtr1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
iny
|
|
|
|
|
cmp #'%'
|
|
|
|
|
bne .10
|
|
|
|
|
|
|
|
|
|
stz PADLEN
|
|
|
|
|
lda #' '
|
|
|
|
|
sta PADCHAR
|
|
|
|
|
|
|
|
|
|
.2 ldx #PrintFTBL2-PrintFTBL1-1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
.3 cmp PrintFTBL1,x do we have a %x command?
|
|
|
|
|
beq .8 yes, jmp to it!
|
|
|
|
|
dex
|
|
|
|
|
bpl .3 no valid letter...
|
|
|
|
|
|
|
|
|
|
cmp #'0' ...a 0...mmm... padding char?
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
ldx PADLEN PADLEN is not nul, so this 0 is second digit
|
|
|
|
|
bne .5
|
|
|
|
|
|
2017-10-10 15:40:23 +00:00
|
|
|
|
* lda #'0'
|
2017-08-24 06:47:31 +00:00
|
|
|
|
sta PADCHAR no, this is the first 0, so make it PADCHAR
|
|
|
|
|
bra .2
|
|
|
|
|
|
2017-10-10 15:40:23 +00:00
|
|
|
|
.4 jsr STDIO.IsDigit
|
|
|
|
|
bcs .99
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
|
|
|
|
.5 and #$0F we have a digit
|
|
|
|
|
pha save it...
|
|
|
|
|
lda PADLEN starts PADLEN * 10
|
|
|
|
|
asl
|
|
|
|
|
asl A=times 4
|
|
|
|
|
adc PADLEN CC by ASL, A=times 5
|
|
|
|
|
asl times 10
|
|
|
|
|
sta PADLEN
|
|
|
|
|
|
|
|
|
|
pla get back digit
|
|
|
|
|
adc PADLEN
|
|
|
|
|
sta PADLEN
|
|
|
|
|
bra .2 go get next char...
|
|
|
|
|
|
|
|
|
|
.8 phy
|
|
|
|
|
txa
|
|
|
|
|
asl
|
|
|
|
|
tax
|
|
|
|
|
jsr PrintFESC
|
|
|
|
|
ply
|
|
|
|
|
bcc .1
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.10 cmp #'\'
|
|
|
|
|
bne .20
|
|
|
|
|
|
|
|
|
|
ldx #PrintFTBL2.OUT-PrintFTBL2-1
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
beq .99
|
|
|
|
|
iny
|
|
|
|
|
|
|
|
|
|
.12 cmp PrintFTBL2,x
|
|
|
|
|
beq .13
|
|
|
|
|
dex
|
|
|
|
|
bpl .12
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.13 lda PrintFTBL2.OUT,x
|
|
|
|
|
|
|
|
|
|
.20 jsr Printf.Cout
|
|
|
|
|
bcc .1
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintFESC jmp (PrintFJMP,x)
|
|
|
|
|
*--------------------------------------
|
2017-10-10 15:40:23 +00:00
|
|
|
|
PrintFTBL1 .AS "bBdDuefhHiILnNsS"
|
2017-08-24 06:47:31 +00:00
|
|
|
|
PrintFTBL2 .AS "befnr\%"
|
|
|
|
|
PrintFTBL2.OUT .HS 08.1B.0C.0A.0D \b\e\f\n\r
|
|
|
|
|
.DA #'\' \\
|
|
|
|
|
.DA #'%' \%
|
2017-10-10 15:40:23 +00:00
|
|
|
|
PrintFJMP .DA PrintF.B,PrintF.BB
|
2017-08-24 06:47:31 +00:00
|
|
|
|
.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.N,PrintF.NN
|
|
|
|
|
.DA PrintF.S,PrintF.SS
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.BB >PULLA
|
|
|
|
|
pha
|
|
|
|
|
jsr PrintF.B
|
|
|
|
|
pla
|
|
|
|
|
bcc PrintF.B.1
|
|
|
|
|
PrintF.BB.RTS rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.B >PULLA
|
|
|
|
|
|
|
|
|
|
PrintF.B.1 ldx #8
|
|
|
|
|
|
|
|
|
|
.1 asl
|
|
|
|
|
pha
|
|
|
|
|
lda #'0'
|
|
|
|
|
adc #0 add Carry
|
|
|
|
|
jsr Printf.Cout
|
|
|
|
|
pla
|
|
|
|
|
bcs PrintF.BB.RTS
|
|
|
|
|
dex
|
|
|
|
|
bne .1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-13 15:28:09 +00:00
|
|
|
|
PrintF.I sec signed short
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.D clc unsigned short (BYTE)
|
|
|
|
|
ldx #0 one byte
|
|
|
|
|
|
|
|
|
|
>PULLB HEXBUF
|
2017-08-24 06:47:31 +00:00
|
|
|
|
stz HEXBUF+1
|
|
|
|
|
bra PrintF.DD.1
|
|
|
|
|
|
2017-10-13 15:28:09 +00:00
|
|
|
|
PrintF.II sec signed int
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.DD clc unsigned int (WORD)
|
|
|
|
|
ldx #1 two bytes
|
|
|
|
|
|
|
|
|
|
>PULLW HEXBUF
|
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
PrintF.DD.1 stz HEXBUF+2
|
|
|
|
|
stz HEXBUF+3
|
|
|
|
|
bra PrintF.U.1
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
|
|
|
|
PrintF.L sec signed long
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.U clc unsigned long (DWORD)
|
|
|
|
|
ldx #3 4 bytes
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-10-13 15:28:09 +00:00
|
|
|
|
>PULLW ZPPtr2
|
|
|
|
|
|
2017-08-24 06:47:31 +00:00
|
|
|
|
ldy #3
|
|
|
|
|
|
|
|
|
|
.1 lda (ZPPtr2),y
|
|
|
|
|
sta HEXBUF,y
|
|
|
|
|
dey
|
|
|
|
|
bpl .1
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
|
|
|
|
PrintF.U.1 bcc .8 unsigned, nothing to check
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
|
|
|
|
lda HEXBUF,x get sign
|
|
|
|
|
bpl .8
|
|
|
|
|
|
|
|
|
|
* sec
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda HEXBUF,y two's complement of X bytes
|
|
|
|
|
eor #$ff
|
|
|
|
|
adc #0
|
|
|
|
|
sta HEXBUF,y
|
|
|
|
|
iny
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
sec tell to print a "-" sign....
|
|
|
|
|
|
|
|
|
|
.8 jmp HEX2DEC
|
2017-10-16 15:41:48 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-13 15:28:09 +00:00
|
|
|
|
* EXP(8) 1(s) 1significants(31)
|
|
|
|
|
* http://apple2.org.za/gswv/a2zine/GS.WorldView/Resources/GS.TECH.INFO/AppleSoft/
|
|
|
|
|
*--------------------------------------
|
2017-10-16 15:41:48 +00:00
|
|
|
|
PrintF.E sec Force "E+12"
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
PrintF.F clc
|
2017-10-27 14:56:46 +00:00
|
|
|
|
>PULLW INDEX
|
|
|
|
|
>ROMCALL SETFAC
|
2017-10-16 15:41:48 +00:00
|
|
|
|
|
|
|
|
|
ldy #3 In order not to trash A2osX.SaveSM,A2osX.SaveSX
|
|
|
|
|
>ROMCALL FOUT
|
|
|
|
|
|
|
|
|
|
ldx #0
|
|
|
|
|
|
|
|
|
|
.2 lda $102,x
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
phx
|
|
|
|
|
jsr Printf.Cout
|
|
|
|
|
plx
|
|
|
|
|
inx
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
|
|
|
|
|
.9 rts
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.HH >PULLA
|
|
|
|
|
pha
|
|
|
|
|
jsr PrintF.H
|
|
|
|
|
pla
|
|
|
|
|
bra PrintF.H.1
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.H >PULLA
|
|
|
|
|
PrintF.H.1 pha
|
|
|
|
|
jsr PrintF.NN.1
|
|
|
|
|
pla
|
2017-10-13 15:28:09 +00:00
|
|
|
|
bra PrintF.N.1
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.N >PULLA
|
|
|
|
|
PrintF.N.1 and #$0F
|
|
|
|
|
bra PrintF.NN.2
|
|
|
|
|
|
|
|
|
|
PrintF.NN >PULLA
|
|
|
|
|
PrintF.NN.1 lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
|
|
|
|
|
PrintF.NN.2 ora #$30
|
|
|
|
|
cmp #$3A
|
|
|
|
|
bcc .1
|
|
|
|
|
adc #6
|
|
|
|
|
.1 jmp Printf.Cout
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
PrintF.S ldy #$ff CSTR
|
|
|
|
|
.HS 2C bit abs
|
|
|
|
|
PrintF.SS ldy #$00 PSTR
|
|
|
|
|
|
|
|
|
|
>PULLW ZPPtr2
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) if CSTR:last char=0, if PSTR:len=0
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
sty .1+1
|
|
|
|
|
|
|
|
|
|
.1 lda #$ff Self Modified
|
|
|
|
|
bne .11 CSTR
|
|
|
|
|
|
|
|
|
|
tya PSTR
|
|
|
|
|
cmp (ZPPtr2) len check
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
.11 iny
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
beq .2
|
|
|
|
|
|
|
|
|
|
jsr Printf.Cout
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
lda PADLEN
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
cpy PADLEN
|
|
|
|
|
bne .1
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.2 lda PADLEN
|
|
|
|
|
beq .8
|
|
|
|
|
|
2017-09-21 15:29:45 +00:00
|
|
|
|
.3 cpy PADLEN
|
|
|
|
|
beq .8
|
|
|
|
|
|
|
|
|
|
lda PADCHAR
|
2017-08-24 06:47:31 +00:00
|
|
|
|
jsr Printf.Cout
|
|
|
|
|
bcs .9
|
|
|
|
|
iny
|
|
|
|
|
bne .3
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
2017-08-25 06:37:21 +00:00
|
|
|
|
Printf.Cout jmp K.PutChar.A
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-09-29 14:57:20 +00:00
|
|
|
|
*Printf.Cout.Ptr sta $ffff Self modified
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-25 15:02:16 +00:00
|
|
|
|
STDIO.PullMLIPath
|
|
|
|
|
>PULLYA
|
|
|
|
|
STDIO.SetMLIPathYA
|
|
|
|
|
>STYA .1+1
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
.1 lda $ffff,y Self Modified
|
|
|
|
|
beq .8
|
|
|
|
|
iny
|
|
|
|
|
sta K.MLI.PATH,y
|
|
|
|
|
cpy #MLI.MAXPATH
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.8 sty K.MLI.PATH
|
|
|
|
|
>LDYAI K.MLI.PATH
|
|
|
|
|
>STYA K.MLI.PARAMS+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
STDIO.SetIOBUF >PUSHWI 1024 get a ProDOS IOBUF
|
|
|
|
|
>PUSHBI S.MEM.F.ALIGN+S.MEM.F.NOMOVE
|
|
|
|
|
jsr K.GetMem
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>STYA K.MLI.PARAMS+3 Save Ptr to IOBUF for MLIOPEN call
|
|
|
|
|
txa
|
|
|
|
|
ldy #S.NODE.REG.IOBUF
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
.9 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
STDIO.GetRefNum jsr K.GetMemPtr.A
|
|
|
|
|
>STYA ZPPtr1
|
|
|
|
|
ldy #S.NODE.REG.REF
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta K.MLI.PARAMS+1
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-26 16:01:54 +00:00
|
|
|
|
STDIO.IOERR lda #MLI.E.IO
|
2017-08-25 15:02:16 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-10 15:40:23 +00:00
|
|
|
|
STDIO.IsDigit cmp #'0'
|
|
|
|
|
bcc .1
|
|
|
|
|
cmp #'9'+1
|
|
|
|
|
rts
|
|
|
|
|
.1 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
2017-10-13 15:28:09 +00:00
|
|
|
|
STDIO.AT10
|
|
|
|
|
*--------------------------------------
|
2017-09-29 14:57:20 +00:00
|
|
|
|
PADLEN .BS 1
|
|
|
|
|
PADCHAR .BS 1
|
|
|
|
|
*--------------------------------------
|
2017-10-13 15:28:09 +00:00
|
|
|
|
*EXP .BS 1
|
|
|
|
|
HEXBUF .BS 4
|
|
|
|
|
bNeg .BS 1
|
|
|
|
|
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
|
|
|
|
*--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* Convert HEXBUF to ASCBUF decimal padded with 0
|
|
|
|
|
*--------------------------------------
|
2017-10-13 15:28:09 +00:00
|
|
|
|
HEX2DEC ror bNeg
|
|
|
|
|
|
|
|
|
|
ldx #4
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
|
|
|
|
.1 stz BCDBUF,x Clear all 5 bytes
|
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
|
|
|
|
sed switch to BCD mode
|
|
|
|
|
|
|
|
|
|
ldx #32 let's roll 32 bits
|
|
|
|
|
|
|
|
|
|
.2 asl HEXBUF
|
|
|
|
|
rol HEXBUF+1
|
|
|
|
|
rol HEXBUF+2
|
|
|
|
|
rol HEXBUF+3
|
|
|
|
|
|
|
|
|
|
ldy #4
|
|
|
|
|
|
|
|
|
|
.3 lda BCDBUF,y
|
|
|
|
|
adc BCDBUF,y
|
|
|
|
|
sta BCDBUF,y
|
|
|
|
|
dey
|
|
|
|
|
bpl .3
|
|
|
|
|
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
cld
|
2017-10-13 15:28:09 +00:00
|
|
|
|
*--------------------------------------
|
|
|
|
|
bit bNeg a -sign to print before digits ?
|
|
|
|
|
bpl .9
|
|
|
|
|
lda #'-'
|
|
|
|
|
jsr Printf.Cout
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
2017-10-13 15:28:09 +00:00
|
|
|
|
.9 lda PADLEN any Len format ?
|
|
|
|
|
beq .4 no
|
|
|
|
|
|
|
|
|
|
lda #10
|
|
|
|
|
sec yes, Print only digits starting at pos 10-padlen
|
|
|
|
|
sbc PADLEN
|
|
|
|
|
|
|
|
|
|
.4 tax x=0 if no padlen, or x=10-padlen
|
|
|
|
|
|
|
|
|
|
.5 txa X range 0 to 9
|
|
|
|
|
lsr CS if lo nibble (1,3,5,7,9)
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
lda BCDBUF,y
|
|
|
|
|
|
|
|
|
|
bcs .6
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
|
|
|
|
lsr
|
2017-10-13 15:28:09 +00:00
|
|
|
|
|
|
|
|
|
.6 and #$0F
|
2017-10-12 15:28:59 +00:00
|
|
|
|
ora #$30
|
|
|
|
|
|
2017-10-13 15:28:09 +00:00
|
|
|
|
cmp #'0' a zero?
|
|
|
|
|
beq .7
|
|
|
|
|
|
|
|
|
|
inc PADLEN found a non zero, Print all digits, even if 0, next time
|
|
|
|
|
ldy #'0'
|
|
|
|
|
sty PADCHAR
|
|
|
|
|
bra .8
|
|
|
|
|
|
|
|
|
|
.7 cpx #9 last digit ?
|
|
|
|
|
beq .8 Print always
|
|
|
|
|
|
|
|
|
|
ldy PADLEN no pad to fill, do not Print 0
|
|
|
|
|
beq .10
|
|
|
|
|
|
|
|
|
|
lda PADCHAR fill with PADCHAR
|
|
|
|
|
|
|
|
|
|
.8 jsr Printf.Cout
|
|
|
|
|
bcs .99
|
|
|
|
|
|
|
|
|
|
.10 inx
|
|
|
|
|
cpx #10
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
.99 rts
|
2017-10-12 15:28:59 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-23 15:05:29 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDIO
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
|
|
|
|
ASM
|