A2osX/BIN/MKDIR.S.txt

303 lines
4.8 KiB
Plaintext
Raw Normal View History

2018-11-10 14:30:09 +00:00
NEW
2020-02-23 20:01:48 +00:00
AUTO 3,1
2018-11-10 14:30:09 +00:00
.LIST OFF
.OP 65C02
.OR $2000
2020-02-23 20:01:48 +00:00
.TF bin/mkdir
*/-------------------------------------
* # MKDIR
* Create directories
* ## Arguments
* **-M mode**
* Apply specified mode to created directories
* **-P**
* Create parent directories if required
* **-V**
* Verbose mode
* ## Return Value
*\-------------------------------------
2020-08-17 20:47:31 +00:00
.INB inc/macros.i
.INB inc/a2osx.i
*--------------------------------------
.DUMMY
.OR ZPBIN
ZS.START
ZPPtr1 .BS 2
ZPMode .BS 2
ArgIndex .BS 1
ArgLen .BS 1
bParent .BS 1
bVerbose .BS 1
ZS.END .ED
2018-11-10 14:30:09 +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 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #16 SS
.DA #0 ZP
.DA 0
*--------------------------------------
* Relocation Table
2019-10-03 06:25:27 +00:00
*--------------------------------------
2018-11-10 14:30:09 +00:00
.1 .DA CS.INIT
.DA CS.RUN
.DA CS.DOEVENT
2018-11-10 14:30:09 +00:00
.DA CS.QUIT
L.MSG.USAGE .DA MSG.USAGE
L.MSG.DIR .DA MSG.DIR
L.MSG.OK .DA MSG.OK
L.MSG.ERR .DA MSG.ERR
2018-11-10 14:30:09 +00:00
.DA 0
*--------------------------------------
CS.INIT
CS.QUIT clc
2018-11-10 14:30:09 +00:00
rts
*--------------------------------------
CS.RUN >LDYAI S.STAT.MODE.FO+S.STAT.MODE.FG+S.STAT.MODE.FU
>STYA ZPMode
.1 jsr CS.RUN.GetNextArg
bcs .8
lda (ZPPtr1)
cmp #'-'
bne .6
ldy #1
lda (ZPPtr1),y
beq .9
.2 ldx #OptionVars-OptionList-1
.3 cmp OptionList,x
beq .5
dex
bpl .3
cmp #'M'
beq .4
cmp #'m'
bne .9
.4 jsr CS.RUN.GetNextArg
2018-11-10 14:30:09 +00:00
bcs .9
jsr CS.RUN.Str2Mode
bcc .1
bra .9
.5 lda OptionVars,x
tax
* sec
ror $0,x
iny
lda (ZPPtr1),y
bne .2
bra .1
.6 lda (pData)
bne .9
>PUSHW ZPPtr1
>PUSHW pData
>SYSCALL RealPath
bcc .1
.9 >LDYA L.MSG.USAGE
>SYSCALL PutS
lda #E.SYN
sec
rts
.8 lda (pData)
beq .9
*--------------------------------------
CS.RUN.Create bit bParent
bmi CS.RUN.CreateP
2020-05-19 13:00:17 +00:00
jsr CS.RUN.Create1
bcs .9
2018-11-10 14:30:09 +00:00
lda #0
sec
.9 rts
*--------------------------------------
CS.RUN.CreateP ldy #$ff
.1 iny
lda (pData),y
bne .1
sty ArgLen
ldy #0 skip /
.2 iny
lda (pData),y
beq .8 /VOL
eor #'/'
bne .2
.3 iny /VOL/
lda (pData),y
beq .4 /VOL/DIR
eor #'/'
bne .3
.4 sty ArgIndex /VOL/DIR/
sta (pData),y /VOL/DIR
>PUSHW pData
>PUSHEA.G StatBuf
>SYSCALL Stat
bcc .5
2020-05-19 13:00:17 +00:00
jsr CS.RUN.Create1
bcs .9
.5 ldy ArgIndex
cpy ArgLen
beq .8
lda #'/'
sta (pData),y /VOL/DIR/.....
bra .3
.8 lda #0
2018-11-10 14:30:09 +00:00
sec
.9 rts
*--------------------------------------
CS.RUN.Create1 clc
bit bVerbose
bpl .1
>PUSHW L.MSG.DIR
>PUSHW pData
>PUSHBI 2
>SYSCALL PrintF
.1 >PUSHW pData
>PUSHW ZPMode
>SYSCALL MKDir
bit bVerbose
bpl .8
bcs .2
>LDYA L.MSG.OK
>SYSCALL PutS
clc
2018-11-10 14:30:09 +00:00
rts
.2 pha
>PUSHW L.MSG.ERR
pla
pha
>PUSHA
>PUSHBI 1
>SYSCALL PrintF
pla
sec
.8 rts
2018-11-10 14:30:09 +00:00
*--------------------------------------
CS.RUN.GetNextArg
inc ArgIndex
lda ArgIndex
>SYSCALL ArgV
bcs .9
>STYA ZPPtr1
.9 rts
*--------------------------------------
CS.RUN.Str2Mode ldy #$ff
.1 iny
lda (ZPPtr1),y
bne .1
cpy #4 must be "765" max
bcs .9
stz ZPMode
stz ZPMode+1
ldy #0
.2 lda (ZPPtr1),y
beq .8
cmp #'0'
bcc .9
cmp #'7'+1
bcs .9
asl ZPMode
rol ZPMode+1
asl ZPMode
rol ZPMode+1
asl ZPMode
rol ZPMode+1
and #7
clc
adc ZPMode
sta ZPMode
bcc .3
inc ZPMode+1
.3 iny
bra .2
.8 clc
2018-11-10 14:30:09 +00:00
rts
.9
2018-11-10 14:30:09 +00:00
*--------------------------------------
CS.DOEVENT sec
2018-11-10 14:30:09 +00:00
rts
*--------------------------------------
CS.END
*--------------------------------------
OptionList .AS "PpVv"
OptionVars .DA #bParent,#bParent
.DA #bVerbose,#bVerbose
*--------------------------------------
MSG.USAGE .CS "Usage : MKDIR newdir\r\n"
.CS " -M mode : set mode\r\n"
.CS " -P : Make parent directories as needed\r\n"
.CZ " -V : Verbose"
MSG.DIR .CZ "MKDir:%s..."
MSG.OK .CZ "[OK]"
MSG.ERR .CS "[%h]"
MSG.CRLF .CZ "\r\n"
2018-11-10 14:30:09 +00:00
*--------------------------------------
.DUMMY
.OR 0
DS.START .BS 128 Path buffer
StatBuf .BS S.STAT
2020-08-17 20:47:31 +00:00
DS.END .ED
2018-11-10 14:30:09 +00:00
*--------------------------------------
MAN
2020-08-17 20:47:31 +00:00
SAVE usr/src/bin/mkdir.s
2018-11-10 14:30:09 +00:00
ASM