A2osX/BIN/CC.S.FIO.txt

206 lines
3.1 KiB
Plaintext
Raw Permalink Normal View History

2022-08-20 14:37:37 +00:00
NEW
AUTO 3,1
*--------------------------------------
FIO.LoadLIB.o >LDA.G LibCount
cmp #LIBS.MAX
bne .1
lda #E.OOH
sec
.9 rts
.1 clc
adc #hLibNs
tay
lda ArgIndex
sta (pData),y
>PUSHW L.ENV.LIB
>PUSHW pData >PUSHEA.G PathBuf
>SYSCALL GetEnv
bcs .9
>PUSHW pData
lda ArgIndex
>SYSCALL ArgV
>PUSHYA
>SYSCALL strcat
>PUSHW pData
>PUSHW L.LIB.O
>SYSCALL strcat
>PUSHW L.MSG.READING
>PUSHW pData
>PUSHBI 2
>SYSCALL PrintF
>PUSHW pData
>PUSHBI O.RDONLY
>PUSHBI S.FI.T.BIN
>PUSHWZ Aux type
>SYSCALL loadfile
bcs .99
>LDA.G LibCount
clc
adc #hLibOs
tay
txa
sta (pData),y
>INC.G LibCount
clc
.99 rts
*--------------------------------------
FIO.FOpen1st >LDA.G CC.InFileArg
2022-08-20 14:37:37 +00:00
>SYSCALL ArgV
FIO.FOpen phy
2022-08-20 14:37:37 +00:00
pha
>PUSHW L.MSG.READING
pla
pha
>PUSHYA
>PUSHBI 2
>SYSCALL PrintF
pla
ply
>PUSHYA
>PUSHBI O.RDONLY
>PUSHBI S.FI.T.TXT
>PUSHWZ Aux type
>SYSCALL FOpen
bcs .9
tax
>LDA.G hFilePtr
inc
sta (pData),y
tay
txa
sta (pData),y
>LDA.G LineCntPtr
inc
inc
sta (pData),y
tay
lda #0
sta (pData),y
iny
sta (pData),y
.9 rts
*--------------------------------------
FIO.FGetS >LDYA.G LineBufPtr
2022-08-20 14:37:37 +00:00
>STYA ZPLineBufPtr
lda #0
sta (ZPLineBufPtr) set to Empty line
2022-08-20 14:37:37 +00:00
>LDA.G LineCntPtr
tay
lda (pData),y
inc
sta (pData),y
bne .1
iny
lda (pData),y
inc
sta (pData),y
.1 >LDA.G hFilePtr
tay
lda (pData),y
>PUSHA
>PUSHW ZPLineBufPtr
>PUSHWI 255
>SYSCALL FGetS
bcs .9
>LDA.G bVerbose
2022-08-20 14:37:37 +00:00
bpl .8
jsr PrintVerboseMsg
2022-08-20 14:37:37 +00:00
.8
.9 rts
*--------------------------------------
FIO.FClose >LDA.G hFilePtr
2022-08-20 14:37:37 +00:00
cmp #hFilePtr
beq .8
tay
lda (pData),y
>SYSCALL FClose
>LDA.G hFilePtr
dec
sta (pData),y
cmp #hFilePtr
beq .8
>LDA.G LineCntPtr
dec
dec
sta (pData),y NZ
.8 rts
*--------------------------------------
2023-01-26 07:07:08 +00:00
FIO.FCreate lda ZPCCCode
sta PCC.FH+PCC.FH.CONST
sta PCC.FH+PCC.FH.CSSIZE
lda ZPCCCode+1
sta PCC.FH+PCC.FH.CONST+1
sec
sbc #$20
sta PCC.FH+PCC.FH.CSSIZE+1
lda ZPCCData
sta PCC.FH+PCC.FH.DSSIZE
lda ZPCCData+1
sta PCC.FH+PCC.FH.DSSIZE+1
>LDA.G CC.OutFileArg
2022-08-20 14:37:37 +00:00
>SYSCALL ArgV
>STYA ZPPtr1
>PUSHW L.MSG.GENERATING
>PUSHW ZPPtr1
>PUSHBI 2
>SYSCALL PrintF
>PUSHW ZPPtr1
>PUSHBI O.WRONLY+O.CREATE
>PUSHBI S.FI.T.BIN
>PUSHWI $2000 Aux type
>SYSCALL FOpen
bcs .9
>STA.G CC.hOutFile
>PUSHA A = CC.hOutFile
>PUSHW L.PCC.FH
>PUSHWI PCC.FH.L
>SYSCALL FWrite
.9 rts
*--------------------------------------
MAN
SAVE usr/src/bin/cc.s.fio
LOAD usr/src/bin/cc.s
ASM