mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-03 12:06:05 +00:00
287 lines
5.5 KiB
Plaintext
287 lines
5.5 KiB
Plaintext
NEW
|
||
AUTO 3,1
|
||
.LIST OFF
|
||
.OP 65C02
|
||
.OR $2000
|
||
.TF BIN/STAT
|
||
*--------------------------------------
|
||
.INB INC/MACROS.I
|
||
.INB INC/A2OSX.I
|
||
.INB INC/MLI.I
|
||
.INB INC/MLI.E.I
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR ZPBIN
|
||
ZS.START
|
||
ArgIndex .BS 1
|
||
ArgFile .BS 1
|
||
ZPPTR1 .BS 2
|
||
|
||
bFormatStr .BS 1
|
||
|
||
ZS.END .ED
|
||
*--------------------------------------
|
||
* File Header (16 Bytes)
|
||
*--------------------------------------
|
||
CS.START cld
|
||
jmp (.1,x)
|
||
.DA #$61 6502,Level 1 (65c02)
|
||
.DA #1 BIN Layout Version 1
|
||
.DA #S.PS.F.EVENT S.PS.F
|
||
.DA #0
|
||
.DA CS.END-CS.START CS
|
||
.DA DS.END-DS.START DS
|
||
.DA #64 SS
|
||
.DA #ZS.END-ZS.START Zero Page Size
|
||
.DA 0
|
||
*--------------------------------------
|
||
* Relocation Table
|
||
*--------------------------------------
|
||
.1 .DA CS.INIT
|
||
.DA CS.RUN
|
||
.DA CS.DOEVENT
|
||
.DA CS.QUIT
|
||
L.MSG.USAGE .DA MSG.USAGE
|
||
L.MSG.Filename .DA MSG.Filename
|
||
L.MSG.Mode .DA MSG.Mode
|
||
L.MSG.UIDGIDSIZE .DA MSG.UIDGIDSIZE
|
||
L.FMT.DateTime .DA FMT.DateTime
|
||
L.MSG.AMCTimes .DA MSG.AMCTimes
|
||
.DA 0
|
||
*--------------------------------------
|
||
CS.INIT clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN
|
||
.1 inc ArgIndex
|
||
lda ArgIndex
|
||
>SYSCALL ArgV
|
||
bcs .3
|
||
>STYA ZPPtr1
|
||
|
||
lda (ZPPtr1)
|
||
cmp #'-'
|
||
bne .2
|
||
|
||
jsr CS.RUN.CheckOpt
|
||
bcc .1
|
||
|
||
.99 >PUSHBI 0
|
||
>LDYA L.MSG.USAGE
|
||
>SYSCALL printf
|
||
lda #E.SYN
|
||
sec
|
||
rts
|
||
|
||
.2 lda ArgFile
|
||
bne .99
|
||
|
||
lda ArgIndex
|
||
sta ArgFile
|
||
bra .1
|
||
|
||
.3 ldx ArgFile
|
||
beq .99
|
||
|
||
>PUSHW pData
|
||
txa
|
||
>SYSCALL ArgV
|
||
>SYSCALL Stat
|
||
bcs .9
|
||
|
||
jsr CS.RUN.DUMP
|
||
bcs .9
|
||
|
||
lda #0
|
||
sec
|
||
.9
|
||
CS.RUN.RTS rts
|
||
*--------------------------------------
|
||
CS.RUN.DUMP lda ArgFile
|
||
>SYSCALL ArgV
|
||
>SYSCALL Realpath
|
||
bcs CS.RUN.RTS
|
||
|
||
phx
|
||
>PUSHYA
|
||
>PUSHBI 2
|
||
>LDYA L.MSG.Filename
|
||
>SYSCALL printf
|
||
pla
|
||
>SYSCALL freemem
|
||
|
||
jsr Mod2CSTR
|
||
>PUSHEA.G MOD
|
||
>PUSHBI 2
|
||
>LDYA L.MSG.Mode
|
||
>SYSCALL printf
|
||
|
||
>PUSHL.G StatBuf+S.STAT.BLOCKS
|
||
>PUSHL.G StatBuf+S.STAT.SIZE
|
||
>PUSHW.G StatBuf+S.STAT.GID
|
||
>PUSHW.G StatBuf+S.STAT.UID
|
||
>PUSHBI 12
|
||
>LDYA L.MSG.UIDGIDSIZE
|
||
>SYSCALL printf
|
||
|
||
jsr CS.RUN.PrintAMCTime
|
||
|
||
rts
|
||
*--------------------------------------
|
||
*--------------------------------------
|
||
Mod2CSTR ldy #S.STAT.MODE+1
|
||
lda (pData),y
|
||
lsr
|
||
lsr
|
||
lsr
|
||
lsr
|
||
tax
|
||
lda TYPES,x
|
||
>STA.G MOD
|
||
|
||
ldx #0
|
||
ldy #S.STAT.MODE
|
||
lda (pData),y
|
||
|
||
ldy #MOD+1
|
||
|
||
.1 lsr
|
||
pha
|
||
lda #'-'
|
||
bcc .2
|
||
|
||
lda ACCESS,x
|
||
|
||
.2 sta (pData),y
|
||
iny
|
||
pla
|
||
inx
|
||
cpx #8
|
||
bne .1
|
||
|
||
.3 ldy #S.STAT.MODE+1
|
||
lda (pData),y
|
||
lsr
|
||
lda #'-'
|
||
bcc .4
|
||
|
||
lda ACCESS,x
|
||
|
||
.4 >STA.G MOD+9
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.PrintAMCTime
|
||
ldy #TIME.Access-1 Set NODATE as default
|
||
jsr CS.RUN.PrintAMCTime.NODATE
|
||
ldy #TIME.Mod-1 Set NODATE as default
|
||
jsr CS.RUN.PrintAMCTime.NODATE
|
||
ldy #TIME.Create-1 Set NODATE as default
|
||
jsr CS.RUN.PrintAMCTime.NODATE
|
||
|
||
>LDA.G StatBuf+S.STAT.ATIME+S.TIME.MONTH
|
||
beq .1 Month=0.....invalid date/time
|
||
|
||
>PUSHEA.G StatBuf+S.STAT.ATIME
|
||
>PUSHW L.FMT.DateTime
|
||
>LEA.G TIME.Access
|
||
>SYSCALL StrFTime
|
||
|
||
.1 >LDA.G StatBuf+S.STAT.MTIME+S.TIME.MONTH
|
||
beq .2 Month=0.....invalid date/time
|
||
|
||
>PUSHEA.G StatBuf+S.STAT.MTIME
|
||
>PUSHW L.FMT.DateTime
|
||
>LEA.G TIME.Mod
|
||
>SYSCALL StrFTime
|
||
|
||
.2 >LDA.G StatBuf+S.STAT.CTIME+S.TIME.MONTH
|
||
beq .8 Month=0.....invalid date/time
|
||
|
||
>PUSHEA.G StatBuf+S.STAT.CTIME
|
||
>PUSHW L.FMT.DateTime
|
||
>LEA.G TIME.Create
|
||
>SYSCALL StrFTime
|
||
|
||
.8 >PUSHEA.G TIME.Create
|
||
>PUSHEA.G TIME.Mod
|
||
>PUSHEA.G TIME.Access
|
||
>PUSHBI 6
|
||
>LDYA L.MSG.AMCTimes
|
||
>SYSCALL printf
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.PrintAMCTime.NODATE
|
||
ldx #$ff
|
||
|
||
.1 inx
|
||
iny
|
||
lda MSG.NODATE,x
|
||
sta (pData),y
|
||
bne .1
|
||
|
||
rts
|
||
*--------------------------------------
|
||
CS.QUIT
|
||
.8 clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.DOEVENT sec
|
||
rts
|
||
*--------------------------------------
|
||
CS.RUN.CheckOpt ldy #1
|
||
lda (ZPPtr1),y
|
||
|
||
ldx #OptionVars-OptionList-1
|
||
|
||
.2 cmp OptionList,x
|
||
beq .3
|
||
dex
|
||
bpl .2
|
||
|
||
sec
|
||
rts
|
||
|
||
.3 ldy OptionVars,x
|
||
lda #$ff
|
||
sta 0,y
|
||
|
||
clc
|
||
rts
|
||
*--------------------------------------
|
||
CS.END
|
||
*--------------------------------------
|
||
OptionList .AS "Cc"
|
||
OptionVars .DA #bFormatStr,#bFormatStr
|
||
TYPES .AS "-dbclssp"
|
||
ACCESS .AS "rwxrwxrwx"
|
||
MSG.NODATE .AZ "<No-Date>"
|
||
FMT.DateTime .AZ "%d-%b-%y %H:%M:%S"
|
||
*--------------------------------------
|
||
MSG.USAGE .AS "Usage : STAT File\r\n"
|
||
.AZ " -C : "Format Sting"\r\n"
|
||
MSG.Filename .AZ "Filename : %s\r\n"
|
||
MSG.Mode .AZ "Access : %s\r\n"
|
||
MSG.UIDGIDSIZE .AS "UID : %10D\r\n"
|
||
.AS "GID : %10D\r\n"
|
||
.AS "Size : %10u\r\n"
|
||
.AZ "Blocks : %10u\r\n"
|
||
MSG.AMCTimes .AS "Accessed : %s\r\n"
|
||
.AS "Modified : %s\r\n"
|
||
.AZ "Created : %s\r\n"
|
||
*--------------------------------------
|
||
.DUMMY
|
||
.OR 0
|
||
DS.START
|
||
StatBuf .BS S.STAT
|
||
MOD .BS 11 drwxrwxrwx + \0
|
||
TIME.Access .BS 20
|
||
TIME.Mod .BS 20
|
||
TIME.Create .BS 20
|
||
DS.END
|
||
.ED
|
||
*--------------------------------------
|
||
MAN
|
||
SAVE USR/SRC/BIN/STAT.S
|
||
ASM
|