A2osX/BIN/CHMOD.S.txt

354 lines
6.1 KiB
Plaintext
Raw Normal View History

2019-04-19 05:42:43 +00:00
NEW
2019-05-02 09:52:32 +00:00
AUTO 3,1
2019-04-19 05:42:43 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2020-05-19 13:00:17 +00:00
.TF bin/chmod
2019-04-19 05:42:43 +00:00
*--------------------------------------
2020-05-20 21:06:05 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
.INB inc/mli.i
.INB inc/mli.e.i
2019-04-19 05:42:43 +00:00
*--------------------------------------
2019-04-30 16:08:47 +00:00
X.ENTER.SUBDIR .EQ 0
2019-04-19 05:42:43 +00:00
X.COPY.TO.DEST .EQ 0
X.DELETE.SOURCE .EQ 0
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPPtr2 .BS 2
ZPFileName .BS 2
ZPFileStat .BS 2
ZPFullPath .BS 2
ZPMode .BS 2
2020-07-22 15:51:03 +00:00
ArgIndex .BS 1
StrMode .BS 1
2019-04-19 05:42:43 +00:00
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 0
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data SegmentSize
.DA #64 Stack Size
.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.DIR .DA MSG.DIR
L.MSG.FILE .DA MSG.FILE
L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
.DA 0
*--------------------------------------
CS.INIT clc
rts
*--------------------------------------
2020-07-22 15:51:03 +00:00
CS.RUN inc ArgIndex
lda ArgIndex
2019-04-19 05:42:43 +00:00
>SYSCALL ArgV
bcs .8
2019-04-19 05:42:43 +00:00
>STYA ZPPtr1
lda (ZPPtr1)
cmp #'-'
bne .4
2019-04-19 05:42:43 +00:00
ldy #1
lda (ZPPtr1),y
ldx #OptionVars-OptionList-1
2019-04-19 05:42:43 +00:00
.2 cmp OptionList,x
beq .3
dex
bpl .2
2020-01-31 20:26:51 +00:00
.9 >PUSHW L.MSG.USAGE
>PUSHBI 0
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-04-19 05:42:43 +00:00
lda #E.SYN
sec
.99 rts
.3 ldy OptionVars,x
2019-04-19 05:42:43 +00:00
lda #$80
sta (pData),y
bra CS.RUN
*--------------------------------------
2020-07-22 15:51:03 +00:00
.4 lda StrMode
2019-04-19 05:42:43 +00:00
bne .5
2020-07-22 15:51:03 +00:00
lda ArgIndex
sta StrMode
2019-04-19 05:42:43 +00:00
bra CS.RUN
2019-04-19 05:42:43 +00:00
.5 >LDA.G hSrcBasePath
bne .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
>LDYA ZPPtr1
jsr InitSrcDirYA
bcc CS.RUN
rts
2020-07-22 15:51:03 +00:00
.8 lda StrMode
2019-04-19 05:42:43 +00:00
beq .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
jsr CS.RUN.Str2Mode
bcs .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
>LDA.G hSrcBasePath
beq .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
>LDYAI 256
2020-02-28 07:21:46 +00:00
>SYSCALL GetMem
2019-04-19 05:42:43 +00:00
bcs .99
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
>STYA ZPFullPath
txa
>STA.G hSrcFullPath
*--------------------------------------
CS.RUN.LOOP ldy #S.PS.hStdIn
lda (pPS),y
2020-08-19 19:39:43 +00:00
>SYSCALL FEOF
2019-04-19 05:42:43 +00:00
bcs .99
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
tay
2019-05-02 09:52:32 +00:00
bne .1
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
>SYSCALL GetChar
bcs .99
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
cmp #$03 Ctrl-C
beq .99 Abort....
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
cmp #$13 Ctrl-S
bne .1
>LDA.G bPause
eor #$ff
sta (pData),y
bne CS.RUN.LOOP
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
.1 >LDA.G bPause
bne CS.RUN.LOOP Pause...
2020-05-20 21:06:05 +00:00
*--------------------------------------
2019-04-19 05:42:43 +00:00
jsr GetEntry
2020-05-20 21:06:05 +00:00
bcs CS.RUN.LEAVE
ldy #S.STAT.MODE+1
2019-04-19 05:42:43 +00:00
lda (ZPFileStat),y
2020-05-20 21:06:05 +00:00
and #$70
bne .5 REG file ?
jsr CS.RUN.FILE
bcc CS.RUN.NEXT
rts
.5 cmp /S.STAT.MODE.DIR DIR ?
2020-07-18 14:04:21 +00:00
beq .6
cmp /S.STAT.MODE.BDEV VOL ?
bne .9
2019-04-19 05:42:43 +00:00
2020-07-18 14:04:21 +00:00
.6 jsr CS.RUN.DIR
2020-05-20 21:06:05 +00:00
bcc CS.RUN.NEXT
rts
2020-07-18 14:04:21 +00:00
.9 lda #MLI.E.UNSUPST
2020-05-20 21:06:05 +00:00
sec
.99 rts
*--------------------------------------
CS.RUN.NEXT jsr GetNextEntry
bcc CS.RUN.LOOP
CS.RUN.LEAVE jsr LeaveSubDir
2019-04-19 05:42:43 +00:00
bcs .90
jsr BasePath..
2020-05-20 21:06:05 +00:00
jmp CS.RUN.NEXT
2019-04-19 05:42:43 +00:00
.90 lda #0
sec
.99 rts
*--------------------------------------
2020-07-22 15:51:03 +00:00
CS.RUN.DIR lda (ZPFileName)
2019-04-19 05:42:43 +00:00
cmp #'.'
2020-05-20 21:06:05 +00:00
bne .1
ldy #1
lda (ZPFileName),y
2019-04-19 05:42:43 +00:00
beq .8
2020-01-31 20:26:51 +00:00
2020-05-20 21:06:05 +00:00
cmp #'.'
bne .1
iny
lda (ZPFileName),y
beq .8
2020-07-22 15:51:03 +00:00
.1 jsr FilterMatch
bcs .8
jsr CS.RUN.GetFilePath
2020-01-31 20:26:51 +00:00
>PUSHW L.MSG.DIR
2019-04-19 05:42:43 +00:00
>PUSHW ZPFullPath
>PUSHBI 2
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-04-19 05:42:43 +00:00
bcs .9
2020-01-31 20:26:51 +00:00
2020-05-20 21:06:05 +00:00
>PUSHW ZPFullPath
2019-04-19 05:42:43 +00:00
>PUSHW ZPMode
2020-08-19 19:39:43 +00:00
>SYSCALL ChMod
2019-04-19 05:42:43 +00:00
jsr CS.RUN.CheckErr
2020-07-22 15:51:03 +00:00
bcs .9
>LDA.G bRecurse
bpl .8
2019-04-19 05:42:43 +00:00
>LDYA ZPFileName
2020-05-21 12:55:49 +00:00
jmp EnterSubDirYA
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
.8 clc
.9 rts
*--------------------------------------
2020-07-29 13:10:11 +00:00
CS.RUN.FILE clc
2019-04-19 05:42:43 +00:00
.9 rts
*--------------------------------------
CS.RUN.Str2Mode >SYSCALL ArgV
>STYA ZPPtr1
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
ldy #$ff
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
.1 iny
lda (ZPPtr1),y
bne .1
2020-07-22 15:51:03 +00:00
2020-07-29 13:10:11 +00:00
cpy #4 must be "765" max
bcs .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
stz ZPMode
stz ZPMode+1
2020-07-22 15:51:03 +00:00
2020-07-29 13:10:11 +00:00
ldy #0
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
.2 lda (ZPPtr1),y
2020-07-29 13:10:11 +00:00
beq .8
2019-04-19 05:42:43 +00:00
cmp #'0'
bcc .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
cmp #'7'+1
bcs .9
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
asl ZPMode
rol ZPMode+1
asl ZPMode
rol ZPMode+1
asl ZPMode
rol ZPMode+1
and #7
clc
adc ZPMode
sta ZPMode
bcc .3
2020-07-22 15:51:03 +00:00
2019-04-19 05:42:43 +00:00
inc ZPMode+1
2020-07-22 15:51:03 +00:00
2020-07-29 13:10:11 +00:00
.3 iny
bra .2
2019-04-19 05:42:43 +00:00
2020-07-29 13:10:11 +00:00
.8 clc
2019-04-19 05:42:43 +00:00
rts
2020-05-21 12:55:49 +00:00
2019-04-19 05:42:43 +00:00
.9 sec
rts
*--------------------------------------
CS.RUN.CheckErr bcs .1
>LDYA L.MSG.OK
2020-02-28 07:21:46 +00:00
>SYSCALL PutS
2019-04-19 05:42:43 +00:00
rts
2020-05-20 21:06:05 +00:00
2019-04-19 05:42:43 +00:00
.1 pha
2020-01-31 20:26:51 +00:00
>PUSHW L.MSG.ERR
pla
pha
2019-04-19 05:42:43 +00:00
>PUSHA
>PUSHBI 1
2020-02-28 07:21:46 +00:00
>SYSCALL PrintF
2019-04-19 05:42:43 +00:00
>LDA.G bContinue
eor #$80
asl
pla
rts
*--------------------------------------
CS.RUN.GetFilePath
>LDA.G hSrcBasePath
>SYSCALL GetMemPtr
>PUSHYA
>LDYA ZPFullPath
>SYSCALL StrCpy
>PUSHW ZPFileName
>LDYA ZPFullPath
>SYSCALL StrCat
rts
*--------------------------------------
CS.DOEVENT sec
rts
*--------------------------------------
CS.QUIT jsr LeaveSubDir
bcc CS.QUIT
>LDA.G hFilter
beq .1
>SYSCALL FreeMem
.1 >LDA.G hSrcFullPath
beq .8
>SYSCALL FreeMem
.8 clc
rts
*--------------------------------------
2020-08-25 14:54:30 +00:00
.INB usr/src/shared/x.fileenum.s
2019-04-19 05:42:43 +00:00
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "CRcr"
2019-04-19 05:42:43 +00:00
OptionVars .DA #bContinue,#bRecurse,#bContinue,#bRecurse
*--------------------------------------
MSG.USAGE .AS "Usage : CHMOD mode [File *,? wildcards allowed]\r\n"
.AS " -C : Continue on error\r\n"
.AZ " -R : Recurse subdirectories\r\n"
MSG.OK .AZ "[OK]"
MSG.ERR .AZ "[%h]\r\n"
2020-05-20 21:06:05 +00:00
MSG.DIR .AZ "Dir :%s..."
MSG.FILE .AZ "File:%s..."
2019-04-19 05:42:43 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START
bContinue .BS 1
bRecurse .BS 1
bPause .BS 1
hSrcFullPath .BS 1
2019-10-08 12:47:47 +00:00
2020-08-25 14:54:30 +00:00
.INB usr/src/shared/x.fileenum.g
2019-04-19 05:42:43 +00:00
2020-08-25 14:54:30 +00:00
DS.END .ED
2019-04-19 05:42:43 +00:00
*--------------------------------------
MAN
2020-05-20 21:06:05 +00:00
SAVE usr/src/bin/chmod.s
2019-04-19 05:42:43 +00:00
ASM