A2osX/BIN/STAT.S.txt

445 lines
8.0 KiB
Plaintext
Raw Normal View History

2019-11-25 16:45:21 +00:00
NEW
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
2020-03-10 16:42:07 +00:00
.TF bin/stat
2019-11-25 16:45:21 +00:00
*--------------------------------------
2020-07-30 13:59:04 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
2019-11-25 16:45:21 +00:00
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ArgIndex .BS 1
ArgFile .BS 1
2020-02-16 20:45:16 +00:00
ZPPtr1 .BS 2
2019-11-25 16:45:21 +00:00
2021-04-08 20:30:18 +00:00
bAll .BS 1
bAccess .BS 1
bMod .BS 1
bUID .BS 1
bGID .BS 1
bSize .BS 1
bBlocks .BS 1
bCTime .BS 1
bMTime .BS 1
bATime .BS 1
2022-11-02 06:54:30 +00:00
ZS.END .ED
2019-11-25 16:45:21 +00:00
*--------------------------------------
* 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
2022-11-02 06:54:30 +00:00
.DA CS.DOEVENT
2019-11-25 16:45:21 +00:00
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.Filename .DA MSG.Filename
2020-07-30 11:14:37 +00:00
L.MSG.Access .DA MSG.Access
L.MSG.Mod .DA MSG.Mod
2019-11-25 16:45:21 +00:00
L.MSG.UIDGIDSIZE .DA MSG.UIDGIDSIZE
L.FMT.DateTime .DA FMT.DateTime
2020-07-30 13:59:04 +00:00
L.MSG.CMATimes .DA MSG.CMATimes
2021-04-08 20:30:18 +00:00
L.MSG.D .DA MSG.D
L.MSG.U .DA MSG.U
2019-11-25 16:45:21 +00:00
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
2022-11-02 06:54:30 +00:00
CS.RUN dec bAll
2021-04-08 20:30:18 +00:00
2019-11-25 16:45:21 +00:00
.1 inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .3
2021-06-30 19:09:07 +00:00
2019-11-25 16:45:21 +00:00
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .2
jsr CS.RUN.CheckOpt
bcc .1
2022-11-02 06:54:30 +00:00
.99 >LDYA L.MSG.USAGE
>SYSCALL PutS
2019-11-25 16:45:21 +00:00
lda #E.SYN
sec
rts
.2 lda ArgFile
bne .99
lda ArgIndex
sta ArgFile
bra .1
2022-11-02 06:54:30 +00:00
2020-02-16 20:45:16 +00:00
.3 lda ArgFile
2019-11-25 16:45:21 +00:00
beq .99
2022-11-02 06:54:30 +00:00
2019-11-25 16:45:21 +00:00
>SYSCALL ArgV
2020-02-16 20:45:16 +00:00
>PUSHYA
>PUSHW pData
2019-11-25 16:45:21 +00:00
>SYSCALL Stat
bcs .9
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
jsr CS.RUN.CONVERT
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
bit bAll
bmi .7
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
jsr CS.RUN.PRINT
bcs .9
bra .8
.7 jsr CS.RUN.DUMP
2019-11-25 16:45:21 +00:00
bcs .9
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.8 lda #0
2019-11-25 16:45:21 +00:00
sec
2022-11-02 06:54:30 +00:00
.9
2019-11-25 16:45:21 +00:00
CS.RUN.RTS rts
*--------------------------------------
2021-04-08 20:30:18 +00:00
CS.RUN.PRINT bit bAccess
bpl .1
2022-11-02 06:54:30 +00:00
2021-06-30 19:09:07 +00:00
>LEA.G AttrBuf
2021-04-08 20:30:18 +00:00
>SYSCALL PutS
bcs CS.RUN.RTS
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.1 bit bMod
bpl .2
2022-11-02 06:54:30 +00:00
2021-06-30 19:09:07 +00:00
>LEA.G MOD
2021-04-08 20:30:18 +00:00
>SYSCALL PutS
bcs CS.RUN.RTS
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.2 bit bUID
bpl .3
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
>PUSHW L.MSG.D
>PUSHW.G StatBuf+S.STAT.UID
>PUSHBI 2
>SYSCALL PrintF
.9 bcs CS.RUN.RTS
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.3 bit bGID
bpl .4
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
>PUSHW L.MSG.D
>PUSHW.G StatBuf+S.STAT.GID
>PUSHBI 2
>SYSCALL PrintF
bcs .9
.4 bit bSize
bpl .5
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
>PUSHW L.MSG.U
>PUSHL.G StatBuf+S.STAT.SIZE
>PUSHBI 4
>SYSCALL PrintF
bcs CS.RUN.PRINT.RTS
.5 bit bBlocks
bpl CS.RUN.PRINT2
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
>PUSHW L.MSG.U
>PUSHL.G StatBuf+S.STAT.BLOCKS
>PUSHBI 4
>SYSCALL PrintF
bcs CS.RUN.PRINT.RTS
CS.RUN.PRINT2 bit bCTime
bpl .7
2022-11-02 06:54:30 +00:00
2021-06-30 18:29:40 +00:00
>LEA.G TIME.Create
2021-04-08 20:30:18 +00:00
>SYSCALL PutS
bcs .9
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.7 bit bMTime
bpl .8
2022-11-02 06:54:30 +00:00
2021-06-30 18:29:40 +00:00
>LEA.G TIME.Mod
2021-04-08 20:30:18 +00:00
>SYSCALL PutS
bcs .9
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.8 bit bATime
bpl .9
2022-11-02 06:54:30 +00:00
2021-06-30 18:29:40 +00:00
>LEA.G TIME.Access
2021-04-08 20:30:18 +00:00
>SYSCALL PutS
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
.9
CS.RUN.PRINT.RTS
rts
*--------------------------------------
2019-11-25 16:45:21 +00:00
CS.RUN.DUMP lda ArgFile
>SYSCALL ArgV
2020-02-14 07:21:56 +00:00
>PUSHYA
2021-07-24 20:42:23 +00:00
>PUSHWZ Allocate
2020-03-09 16:24:08 +00:00
>SYSCALL RealPath
2021-04-08 20:30:18 +00:00
bcs CS.RUN.PRINT.RTS
2019-11-25 16:45:21 +00:00
2020-02-16 20:45:16 +00:00
>STYA ZPPtr1
2019-11-25 16:45:21 +00:00
phx
2020-02-16 20:45:16 +00:00
>PUSHW L.MSG.Filename
>PUSHW ZPPtr1
2019-11-25 16:45:21 +00:00
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-11-25 16:45:21 +00:00
pla
2020-02-28 07:21:46 +00:00
>SYSCALL FreeMem
2022-11-02 06:54:30 +00:00
2020-07-30 11:14:37 +00:00
>PUSHW L.MSG.Access
2021-06-30 19:09:07 +00:00
>PUSHEA.G AttrBuf
2020-07-30 11:14:37 +00:00
>PUSHBI 2
>SYSCALL PrintF
2020-08-25 10:56:00 +00:00
>PUSHW L.MSG.Mod
2019-11-25 16:45:21 +00:00
>PUSHEA.G MOD
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2022-11-02 06:54:30 +00:00
2020-02-16 20:45:16 +00:00
>PUSHW L.MSG.UIDGIDSIZE
2019-11-25 16:45:21 +00:00
>PUSHW.G StatBuf+S.STAT.UID
2020-02-16 20:45:16 +00:00
>PUSHW.G StatBuf+S.STAT.GID
>PUSHL.G StatBuf+S.STAT.SIZE
>PUSHL.G StatBuf+S.STAT.BLOCKS
>PUSHW.G StatBuf+S.STAT.BLKSIZE
>PUSHBI 14
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2022-11-02 06:54:30 +00:00
2021-04-08 20:30:18 +00:00
>PUSHW L.MSG.CMATimes
>PUSHEA.G TIME.Create
>PUSHEA.G TIME.Mod
>PUSHEA.G TIME.Access
>PUSHBI 6
>SYSCALL PrintF
2022-11-02 06:54:30 +00:00
rts
2019-11-25 16:45:21 +00:00
*--------------------------------------
2021-04-08 20:30:18 +00:00
CS.RUN.CONVERT jsr Access2CSTR
jsr Mod2CSTR
jmp Times2CSTR
*--------------------------------------
2020-07-30 11:14:37 +00:00
Access2CSTR ldy #S.STAT.P.ACCESS
lda (pData),y
2021-06-30 19:09:07 +00:00
ldy #AttrBuf+15
2020-07-30 11:14:37 +00:00
ldx #15
.1 lsr
pha
bcc .2
2022-11-02 06:54:30 +00:00
2020-07-30 11:14:37 +00:00
lda ATTRS,x
sta (pData),y
dex
dey
lda ATTRS,x
sta (pData),y
bra .3
2022-11-02 06:54:30 +00:00
2020-07-30 11:14:37 +00:00
.2 lda #'-'
sta (pData),y
dex
dey
sta (pData),y
2022-11-02 06:54:30 +00:00
2020-07-30 11:14:37 +00:00
.3 pla
2022-11-02 06:54:30 +00:00
2020-07-30 11:14:37 +00:00
dey
dex
bpl .1
rts
2019-11-25 16:45:21 +00:00
*--------------------------------------
Mod2CSTR ldy #S.STAT.MODE+1
lda (pData),y
lsr
2020-07-13 19:29:31 +00:00
php
2022-11-02 06:54:30 +00:00
2019-11-25 16:45:21 +00:00
lsr
lsr
lsr
tax
lda TYPES,x
>STA.G MOD
2022-11-02 06:54:30 +00:00
2020-07-13 19:29:31 +00:00
plp
2022-11-02 06:54:30 +00:00
2020-07-13 19:29:31 +00:00
ldx #8
2019-11-25 16:45:21 +00:00
ldy #S.STAT.MODE
lda (pData),y
ldy #MOD+1
2020-07-13 19:29:31 +00:00
.1 pha
2019-11-25 16:45:21 +00:00
lda #'-'
bcc .2
lda ACCESS,x
.2 sta (pData),y
2022-11-02 06:54:30 +00:00
2019-11-25 16:45:21 +00:00
iny
pla
2020-07-13 19:29:31 +00:00
asl
2022-11-02 06:54:30 +00:00
2020-07-13 19:29:31 +00:00
dex
bpl .1
2019-11-25 16:45:21 +00:00
rts
*--------------------------------------
2021-04-08 20:30:18 +00:00
Times2CSTR ldy #TIME.Access-1 Set NODATE as default
2019-11-25 16:45:21 +00:00
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
2020-01-18 19:37:32 +00:00
>PUSHEA.G TIME.Access
2019-11-25 16:45:21 +00:00
>PUSHW L.FMT.DateTime
2020-01-18 19:37:32 +00:00
>PUSHEA.G StatBuf+S.STAT.ATIME
2019-11-25 16:45:21 +00:00
>SYSCALL StrFTime
.1 >LDA.G StatBuf+S.STAT.MTIME+S.TIME.MONTH
beq .2 Month=0.....invalid date/time
2020-01-18 19:37:32 +00:00
>PUSHEA.G TIME.Mod
2019-11-25 16:45:21 +00:00
>PUSHW L.FMT.DateTime
2020-01-18 19:37:32 +00:00
>PUSHEA.G StatBuf+S.STAT.MTIME
2019-11-25 16:45:21 +00:00
>SYSCALL StrFTime
.2 >LDA.G StatBuf+S.STAT.CTIME+S.TIME.MONTH
beq .8 Month=0.....invalid date/time
2020-01-18 19:37:32 +00:00
>PUSHEA.G TIME.Create
2019-11-25 16:45:21 +00:00
>PUSHW L.FMT.DateTime
2020-01-18 19:37:32 +00:00
>PUSHEA.G StatBuf+S.STAT.CTIME
2019-11-25 16:45:21 +00:00
>SYSCALL StrFTime
2021-04-08 20:30:18 +00:00
.8 rts
2019-11-25 16:45:21 +00:00
*--------------------------------------
CS.RUN.PrintAMCTime.NODATE
ldx #$ff
.1 inx
iny
lda MSG.NODATE,x
sta (pData),y
bne .1
rts
*--------------------------------------
2022-11-02 06:54:30 +00:00
CS.QUIT
2019-11-25 16:45:21 +00:00
.8 clc
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
2022-11-02 06:54:30 +00:00
CS.RUN.CheckOpt ldy #1
2019-11-25 16:45:21 +00:00
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
.2 cmp OptionList,x
beq .3
2021-04-08 20:30:18 +00:00
2019-11-25 16:45:21 +00:00
dex
bpl .2
sec
rts
.3 ldy OptionVars,x
lda #$ff
sta 0,y
2021-04-08 20:30:18 +00:00
stz bAll
2019-11-25 16:45:21 +00:00
clc
rts
*--------------------------------------
CS.END
*--------------------------------------
2021-06-30 18:29:40 +00:00
OptionList .AS "AaDdUuGgSsBbCcMmLl"
2021-04-08 20:30:18 +00:00
OptionVars .DA #bAccess,#bAccess
.DA #bMod,#bMod
.DA #bUID,#bUID
.DA #bGID,#bGID
.DA #bSize,#bSize
.DA #bBlocks,#bBlocks
.DA #bCTime,#bCTime
.DA #bMTime,#bMTime
.DA #bATime,#bATime
2020-07-30 11:14:37 +00:00
ATTRS .AS "DeReBn----InWrRd"
2019-11-25 16:45:21 +00:00
TYPES .AS "-dbclssp"
2020-07-13 19:29:31 +00:00
ACCESS .AS "xwrxwrxwr"
2019-12-02 07:09:58 +00:00
MSG.NODATE .AZ "<No-Date>"
FMT.DateTime .AZ "%d-%b-%y %H:%M:%S"
2019-11-25 16:45:21 +00:00
*--------------------------------------
2022-11-02 06:54:30 +00:00
MSG.USAGE .CS "Usage : STAT File\r\n"
.CS " -A : Access Flags\r\n"
.CS " -D : Mod Flags\r\n"
.CS " -U : UID\r\n"
.CS " -G : GID\r\n"
.CS " -S : Size in bytes\r\n"
.CS " -B : Size in blocks\r\n"
.CS " -C : Creation date/time\r\n"
.CS " -M : Modification date/time\r\n"
.CZ " -L : Last access date/time\r\n"
2021-04-08 20:30:18 +00:00
*--------------------------------------
2022-11-02 06:54:30 +00:00
MSG.Filename .CZ "Filename : %s\r\n"
MSG.Access .CZ "Access : %s\r\n"
MSG.Mod .CZ "Mod : %s\r\n"
MSG.UIDGIDSIZE .CS "UID : %10D\r\n"
.CS "GID : %10D\r\n"
.CS "Size : %10u\r\n"
.CZ "Blocks : %10u (%D)\r\n"
MSG.CMATimes .CS "Created : %s\r\n"
.CS "Modified : %s\r\n"
.CZ "Accessed : %s\r\n"
MSG.D .CZ "%D\r\n"
MSG.U .CZ "%u\r\n"
2019-11-25 16:45:21 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
StatBuf .BS S.STAT
2021-06-30 19:09:07 +00:00
AttrBuf .BS 17
2019-12-02 07:09:58 +00:00
MOD .BS 11 drwxrwxrwx + \0
2019-11-25 16:45:21 +00:00
TIME.Access .BS 20
TIME.Mod .BS 20
TIME.Create .BS 20
2021-06-30 19:09:07 +00:00
DS.END .ED
2019-11-25 16:45:21 +00:00
*--------------------------------------
MAN
2020-07-30 13:59:04 +00:00
SAVE usr/src/bin/stat.s
2019-11-25 16:45:21 +00:00
ASM