A2osX/BIN/ASM.S.FIO.txt

347 lines
5.0 KiB
Plaintext
Raw Normal View History

NEW
2019-09-02 06:09:28 +00:00
AUTO 3,1
2015-10-28 16:55:12 +00:00
*---------------------------------------
2020-02-25 16:42:22 +00:00
FIO.Init.RTS rts
FIO.Init >LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2020-02-25 16:42:22 +00:00
bcs FIO.Init.RTS
2021-05-14 20:58:20 +00:00
2020-02-25 16:42:22 +00:00
>STYA ZPLineBuf
txa
>STA.G SRC.hLineBuf
>LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2020-02-25 16:42:22 +00:00
bcs FIO.Init.RTS
2021-05-14 20:58:20 +00:00
2020-02-25 16:42:22 +00:00
>STYA ZPTmpBuf
txa
>STA.G SRC.hTmpBuf
2023-07-22 13:43:25 +00:00
2020-02-25 16:42:22 +00:00
>LDYA L.ASM.6502
2020-02-23 20:01:48 +00:00
FIO.LOAD.CPU >STYA ZPPtr2
2018-01-11 16:34:09 +00:00
2018-10-16 15:48:03 +00:00
ldy #S.PS.hARGV
lda (pPS),y
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
>STYA ZPPtr1
ldy #$ff
ldx #$ff
2023-07-22 13:43:25 +00:00
2019-03-18 16:48:16 +00:00
.1 iny
inx
lda (ZPPtr1),y
2020-02-23 20:01:48 +00:00
sta ASM.CPU.FILE,x
bne .1
2018-01-11 16:34:09 +00:00
lda #'.'
2020-02-23 20:01:48 +00:00
sta ASM.CPU.FILE,x
ldy #$ff
2018-01-11 16:34:09 +00:00
.2 iny
inx
lda (ZPPtr2),y
jsr SRC.IsLetterOrDigit
bcs .3
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
sta ASM.CPU.FILE,x
bra .2
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
.3 stz ASM.CPU.FILE,x
2023-07-22 13:43:25 +00:00
2020-02-27 16:46:40 +00:00
>LDA.G ASM.hCPUFILE
beq .4
2023-07-22 13:43:25 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL FreeMem
2023-07-22 13:43:25 +00:00
2020-02-27 16:46:40 +00:00
>STZ.G ASM.hCPUFILE
2023-07-22 13:43:25 +00:00
2020-08-17 13:03:39 +00:00
.4 >PUSHW L.MSG.CPU.FILE
2020-02-23 20:01:48 +00:00
>PUSHW L.ASM.CPU.FILE
2018-11-26 21:52:49 +00:00
>PUSHBI 2
jsr OUT.Print
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
>PUSHW L.ASM.CPU.FILE
2018-10-02 15:52:30 +00:00
>PUSHBI O.RDONLY
2020-02-23 20:01:48 +00:00
>PUSHBI S.FI.T.BIN
>PUSHWZ Aux type
>SYSCALL LoadFile
bcs .9
2020-02-23 20:01:48 +00:00
txa
2020-02-27 16:46:40 +00:00
>STA.G ASM.hCPUFILE
2023-07-22 13:43:25 +00:00
2018-07-18 15:30:42 +00:00
>SYSCALL GetMemPtr
>STYA ZPPtr1
2018-01-15 06:50:44 +00:00
ldy #ASM.T.AM
lda (ZPPtr1),y
clc
adc ZPPtr1
sta ZPAMPtr
iny
lda (ZPPtr1),y
adc ZPPtr1+1
sta ZPAMPtr+1
iny
lda (ZPPtr1),y
clc
adc ZPPtr1
sta ZPRPtr
iny
lda (ZPPtr1),y
adc ZPPtr1+1
sta ZPRPtr+1
iny
lda (ZPPtr1),y
clc
adc ZPPtr1
sta ZPOpsPtr
iny
lda (ZPPtr1),y
adc ZPPtr1+1
sta ZPOpsPtr+1
2019-10-03 06:25:27 +00:00
.9 rts
*---------------------------------------
FIO.OpenFile >STYA ZPPtr1
2020-02-23 20:01:48 +00:00
>PUSHW L.MSG.SRC.FILE
>PUSHW ZPPtr1
2018-11-26 21:52:49 +00:00
>PUSHBI 2
jsr OUT.Print
2023-07-22 13:43:25 +00:00
2020-02-24 13:33:28 +00:00
>LDA.G SRC.Depth
cmp #IN.MAXDEPTH
bne .1
2023-07-22 13:43:25 +00:00
2019-03-25 07:04:40 +00:00
lda #E.SRC.TOO.MANY.IN
sec
rts
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
.1 >PUSHW ZPPtr1
2020-02-27 16:46:40 +00:00
>PUSHW ZPTmpBuf
>SYSCALL Stat
bcs .99
2023-07-22 13:43:25 +00:00
2020-02-27 16:46:40 +00:00
ldy #S.STAT.P.TYPE
lda (ZPTmpBuf),y
2020-02-23 20:01:48 +00:00
cmp #S.FI.T.TXT
bne .2
2018-01-29 16:48:07 +00:00
2020-02-23 20:01:48 +00:00
ldx #O.RDONLY+O.TEXT
bra .3
2023-07-22 13:43:25 +00:00
2019-10-03 06:25:27 +00:00
.2 cmp #$FA S-C/BAS?
bne .98
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
ldx #O.RDONLY
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
.3 >PUSHW ZPPtr1
txa
>PUSHA
2020-02-27 16:46:40 +00:00
ldy #S.STAT.P.TYPE
lda (ZPTmpBuf),y
>PUSHA
2019-06-07 15:02:51 +00:00
>PUSHWZ
>SYSCALL FOpen
bcs .99
2023-07-22 13:43:25 +00:00
pha
2020-02-28 07:21:46 +00:00
>INC.G SRC.Depth
2023-07-22 13:43:25 +00:00
clc
2020-02-28 07:21:46 +00:00
adc #SRC.hFILES-1
tay
pla
sta (pData),y
2020-02-24 13:33:28 +00:00
>LDA.G SRC.Depth
clc
2020-02-28 07:21:46 +00:00
adc #SRC.hFILETYPES-1
tay
2015-10-28 16:55:12 +00:00
2020-02-27 16:46:40 +00:00
phy
ldy #S.STAT.P.TYPE
lda (ZPTmpBuf),y
ply
sta (pData),y
lda #0
>STA.G SRC.LINENUM
iny
sta (pData),y
2023-07-22 13:43:25 +00:00
clc
rts
2023-07-22 13:43:25 +00:00
2019-03-25 07:04:40 +00:00
.98 lda #E.SRC.INV.TYPE
sec
.99 rts
2015-10-28 16:55:12 +00:00
*---------------------------------------
2020-02-24 13:33:28 +00:00
FIO.ReadLine >LDA.G SRC.Depth
clc
adc #SRC.hFILETYPES-1
tay
lda (pData),y
bmi .10
2018-01-29 16:48:07 +00:00
2021-05-14 20:58:20 +00:00
jsr FIO.GethFile
2019-01-28 07:44:37 +00:00
>PUSHW ZPLineBuf
2021-05-14 20:58:20 +00:00
>PUSHWI 256
jsr FIO.ReadFromFile
2023-07-22 13:43:25 +00:00
bcs .19
2021-05-14 20:58:20 +00:00
tya
beq .13
2018-01-29 16:48:07 +00:00
dey
2019-03-25 07:04:40 +00:00
lda (ZPLineBuf),y
eor #C.CR
beq .22
2021-05-14 20:58:20 +00:00
2019-03-25 07:04:40 +00:00
iny
.22 lda #0 replace ending $0D with $00
.13 sta (ZPLineBuf),y
>INC.G SRC.LINENUM
bne .19
2021-05-14 20:58:20 +00:00
>INC.G SRC.LINENUM+1
2021-05-14 20:58:20 +00:00
.19 rts
2018-01-11 16:34:09 +00:00
*---------------------------------------
2021-05-14 20:58:20 +00:00
.10 jsr FIO.GethFile
2019-01-28 07:44:37 +00:00
>PUSHW ZPTmpBuf
2021-05-14 20:58:20 +00:00
>PUSHWI 3
jsr FIO.ReadFromFile
2023-07-22 13:43:25 +00:00
bcs .19
2015-10-28 16:55:12 +00:00
ldy #1
lda (ZPTmpBuf),y
pha
iny
lda (ZPTmpBuf),y
>STA.G SRC.LINENUM+1
pla
>STA.G SRC.LINENUM
2021-05-14 20:58:20 +00:00
jsr FIO.GethFile
>PUSHW ZPTmpBuf
lda #0 LENHI = 0
>PUSHA
2023-07-22 13:43:25 +00:00
2021-05-14 20:58:20 +00:00
lda (ZPTmpBuf) LEN
sec
sbc #3
2021-05-14 20:58:20 +00:00
bcc .9 LEN should be at least 3
2015-10-28 16:55:12 +00:00
2021-05-14 20:58:20 +00:00
>PUSHA
jsr FIO.ReadFromFile
bcs .9
2021-05-14 20:58:20 +00:00
>LDYA ZPTmpBuf
>STYA ZPPtr1
ldy #0
.1 lda (ZPPtr1)
inc ZPPtr1
bne .11
2021-05-14 20:58:20 +00:00
inc ZPPtr1+1
.11 tax
bmi .2
2021-05-14 20:58:20 +00:00
sta (ZPLineBuf),y
beq .8 Ending 00
2018-01-11 16:34:09 +00:00
iny
bne .1
2021-05-14 20:58:20 +00:00
bra .99
2021-05-14 20:58:20 +00:00
.2 cmp #$C0 REPEAT char?
bne .5
2018-01-12 16:05:04 +00:00
lda (ZPPtr1) Get Repeat Count
inc ZPPtr1
bne .3
2021-05-14 20:58:20 +00:00
inc ZPPtr1+1
2021-05-14 20:58:20 +00:00
.3 tax
2018-01-11 16:34:09 +00:00
lda (ZPPtr1) Get Repeat Char
inc ZPPtr1
bne .4
2021-05-14 20:58:20 +00:00
inc ZPPtr1+1
2021-05-14 20:58:20 +00:00
.4 sta (ZPLineBuf),y
iny
beq .99
2021-05-14 20:58:20 +00:00
dex
bne .4
2018-01-11 16:34:09 +00:00
bra .1
2021-05-14 20:58:20 +00:00
.5 and #$3F Compute blank count
tax
lda #$20
2021-05-14 20:58:20 +00:00
.6 sta (ZPLineBuf),y
iny
beq .99
2021-05-14 20:58:20 +00:00
dex
bne .6
2021-05-14 20:58:20 +00:00
bra .1
2021-05-14 20:58:20 +00:00
.8 clc
.9 rts
2015-10-28 16:55:12 +00:00
2019-03-25 07:04:40 +00:00
.99 lda #E.LINE.TOO.LONG
sec
rts
2015-10-28 16:55:12 +00:00
*--------------------------------------
2021-05-14 20:58:20 +00:00
FIO.GethFile >LDA.G SRC.Depth
clc
adc #SRC.hFILES-1
tay
lda (pData),y
2021-05-14 20:58:20 +00:00
>PUSHA
rts
*--------------------------------------
FIO.ReadFromFile
>SYSCALL FRead
bcs .9
2021-05-14 20:58:20 +00:00
2020-02-23 20:01:48 +00:00
tax $100 byte transfered ?
beq .9
2021-05-14 20:58:20 +00:00
2019-03-25 07:04:40 +00:00
lda #E.LINE.TOO.LONG
sec
.9 rts
2015-10-28 16:55:12 +00:00
*---------------------------------------
2020-02-24 13:33:28 +00:00
FIO.FileClose >LDA.G SRC.Depth
beq .8
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
dec
sta (pData),y
2023-07-22 13:43:25 +00:00
2020-02-23 20:01:48 +00:00
sec
adc #SRC.hFILES-1
tay
lda (pData),y
2020-02-28 07:21:46 +00:00
>SYSCALL FClose
2023-07-22 13:43:25 +00:00
.8 clc
rts
2015-10-28 16:55:12 +00:00
*---------------------------------------
MAN
2020-08-17 13:03:39 +00:00
SAVE usr/src/bin/asm.s.fio
LOAD usr/src/bin/asm.s
2015-10-28 16:55:12 +00:00
ASM