A2osX/BIN/CC.S.FIO.txt

210 lines
3.2 KiB
Plaintext
Raw 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.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 bTrace
bpl .8
jsr PrintTraceMsg
.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
*--------------------------------------
FIO.FCreate lda ZPCCCode+1
sta PCC.FH+PCC.FH.CONST+1
sec
sbc #$20
sta PCC.FH+PCC.FH.CSSIZE+1
lda ZPCCCode
sta PCC.FH+PCC.FH.CSSIZE
sta PCC.FH+PCC.FH.CONST
clc
adc ZPCCConst
sta PCC.FH+PCC.FH.LIBS
lda ZPCCCode+1
adc ZPCCConst+1
sta PCC.FH+PCC.FH.LIBS+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