mirror of
https://github.com/A2osX/A2osX.git
synced 2024-11-25 20:33:13 +00:00
Kernel 0.9.1 : Code reorganization & move to CSTR, new RealPath.YA API
This commit is contained in:
parent
98632f7a49
commit
399bdc0cae
@ -1,14 +1,5 @@
|
||||
*** Auto generated by docgen.cmd ***
|
||||
|
||||
# GetArgC
|
||||
Returns argument count in the process command line.
|
||||
|
||||
## In:
|
||||
+ none.
|
||||
|
||||
## Out:
|
||||
+ A = Command line Arg Count (Including /path/cmd)
|
||||
|
||||
# GetArg.A
|
||||
|
||||
## In:
|
||||
@ -613,6 +604,18 @@ Convert String to 32 bits int
|
||||
|
||||
## Out:
|
||||
|
||||
# RealPath.YA
|
||||
Return the canonicalized absolute pathname
|
||||
|
||||
## In :
|
||||
+ Y,A = Ptr to Relative Filename (C-String)
|
||||
|
||||
## Out :
|
||||
+ CC : success
|
||||
+ Y,A = Ptr to Full Path (C-String)
|
||||
+ X = hMem of Full Path
|
||||
+ CS : A = Error Code
|
||||
|
||||
# StrLen.YA
|
||||
Returns Length of C-String
|
||||
|
||||
|
Binary file not shown.
Binary file not shown.
24
BIN/LS.S.txt
24
BIN/LS.S.txt
@ -51,19 +51,12 @@ L.PRODOS.FT.TXT .DA PRODOS.FT.TXT
|
||||
L.FMT.DateTime .DA FMT.DateTime
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
CS.INIT ldy #S.PS.ARGC
|
||||
lda (pPs),y
|
||||
beq .7
|
||||
|
||||
>STA.G ArgCount
|
||||
|
||||
.1 >SYSCALL GetArg.A
|
||||
CS.INIT
|
||||
.1 >INC.G ArgCount
|
||||
>SYSCALL GetArg.A
|
||||
bcs .6
|
||||
>STYA ZPPtr1
|
||||
|
||||
>SYSCALL PrintF.YA
|
||||
lda #'|'
|
||||
>SYSCALL PutChar.A
|
||||
|
||||
|
||||
lda (ZPPtr1)
|
||||
cmp #'-'
|
||||
bne .4
|
||||
@ -84,16 +77,13 @@ CS.INIT ldy #S.PS.ARGC
|
||||
.3 ldy OptionVars-1,x
|
||||
lda #$80
|
||||
sta (pData),y
|
||||
bra .6
|
||||
bra .1
|
||||
|
||||
.4 >LDYA ZPPtr1
|
||||
jsr InitSrcDirYA
|
||||
bcs .9
|
||||
|
||||
>LDA.G ArgCount
|
||||
dec
|
||||
sta (pData),y
|
||||
bne .1 scan for any other args
|
||||
bra .1 scan for any other args
|
||||
|
||||
.6 >LDA.G index do we have a Source dir ?
|
||||
bne .8
|
||||
|
15
BIN/MD.S.txt
15
BIN/MD.S.txt
@ -21,7 +21,7 @@ CS.START cld
|
||||
.DA CS.END-CS.START CS
|
||||
.DA DS.END-DS.START DS
|
||||
.DA #16 SS
|
||||
.DA 0 ZP
|
||||
.DA #0 ZP
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
* Relocation Table
|
||||
@ -35,17 +35,18 @@ CS.START cld
|
||||
CS.INIT clc
|
||||
rts
|
||||
*--------------------------------------
|
||||
CS.RUN >SYSCALL GetArgC
|
||||
cmp #1
|
||||
beq .99
|
||||
|
||||
lda #1
|
||||
CS.RUN lda #1
|
||||
>SYSCALL GetArg.A
|
||||
bcs .99
|
||||
|
||||
>SYSCALL GetFullPath.YA
|
||||
bcs .9
|
||||
|
||||
phy
|
||||
pha
|
||||
txa
|
||||
>STA.G hFullPath
|
||||
pla
|
||||
ply
|
||||
>SYSCALL MKDir.YA
|
||||
bcs .9
|
||||
|
||||
|
@ -23,6 +23,15 @@ InitSrcDirYA >SYSCALL GetFullPath.YA
|
||||
txa
|
||||
>STA.G hFullPath
|
||||
|
||||
>LDYA ZPPtr1
|
||||
>SYSCALL PrintF.YA
|
||||
lda #'|'
|
||||
>SYSCALL PutChar.A
|
||||
lda #13
|
||||
>SYSCALL PutChar.A
|
||||
lda #10
|
||||
>SYSCALL PutChar.A
|
||||
|
||||
ldy #1
|
||||
lda (ZPPtr1),y
|
||||
beq .5 we have '/'
|
||||
|
@ -163,7 +163,7 @@ SYS.AToL .EQ $74
|
||||
* .EQ $76
|
||||
* .EQ $78
|
||||
* .EQ $7A
|
||||
* .EQ $7C
|
||||
SYS.RealPath.YA .EQ $7C
|
||||
* .EQ $7E
|
||||
*--------------------------------------
|
||||
SYS.StrLen.YA .EQ $80
|
||||
|
@ -211,15 +211,6 @@ Cmd.Exec.EXT.TXT
|
||||
>PUSHYA
|
||||
>PUSHW ZPCMDBuf
|
||||
>SYSCALL StrCat
|
||||
|
||||
>LDYA ZPCMDBuf
|
||||
>SYSCALL PrintF.YA
|
||||
lda #'!'
|
||||
>SYSCALL PutChar.A
|
||||
lda #13
|
||||
>SYSCALL PutChar.A
|
||||
lda #10
|
||||
>SYSCALL PutChar.A
|
||||
*--------------------------------------
|
||||
* BIN : Launch "/PATH/CMD ARGS"
|
||||
*--------------------------------------
|
||||
@ -232,16 +223,7 @@ Cmd.Exec.EXT.BIN
|
||||
>PUSHW ZPPTR2
|
||||
>PUSHW ZPCMDBuf
|
||||
>SYSCALL StrCat
|
||||
|
||||
>LDYA ZPCMDBuf
|
||||
>SYSCALL PrintF.YA
|
||||
lda #'!'
|
||||
>SYSCALL PutChar.A
|
||||
lda #13
|
||||
>SYSCALL PutChar.A
|
||||
lda #10
|
||||
>SYSCALL PutChar.A
|
||||
|
||||
|
||||
.1 >LDA.G CMD.bStartProc
|
||||
asl
|
||||
>LDYA ZPCMDBuf
|
||||
@ -276,103 +258,54 @@ Cmd.Exec.EXT.SEP
|
||||
*--------------------------------------
|
||||
* Internal Commands
|
||||
*--------------------------------------
|
||||
Cmd.Exec.CD lda (ZPPTR2)
|
||||
bne Cmd.Exec.CD1
|
||||
|
||||
Cmd.Exec.PWD ldy #S.PS.hPREFIX
|
||||
lda (pPs),y
|
||||
>SYSCALL GetMemPtr.A
|
||||
>SYSCALL PrintF.YA
|
||||
jmp Cmd.Exec.ECHO.CR
|
||||
*--------------------------------------
|
||||
Cmd.Exec.CD lda (ZPPTR2)
|
||||
bne .1
|
||||
|
||||
Cmd.Exec.CD1 lda (ZPPTR2) Get ARG
|
||||
cmp #'/' Full Path?
|
||||
bne .20
|
||||
>LDYA L.ENV.HOME
|
||||
>SYSCALL GetEnv.YA
|
||||
bcs Cmd.Exec.PWD
|
||||
|
||||
sta (ZPCMDBuf)
|
||||
>SYSCALL ExpandStr.YA
|
||||
bcs .9
|
||||
|
||||
bra .4
|
||||
|
||||
.1 ldy #0
|
||||
|
||||
ldy #1 strlen = 1
|
||||
lda #0
|
||||
sta (ZPCMDBuf),y
|
||||
bra .1
|
||||
|
||||
.20 ldy #S.PS.hPREFIX no, init target prefix with actual prefix
|
||||
lda (pPs),y
|
||||
>SYSCALL GetMemPtr.A
|
||||
>PUSHYA
|
||||
>PUSHW ZPCMDBuf
|
||||
>SYSCALL StrCpy
|
||||
|
||||
ldy #0
|
||||
|
||||
.10 iny
|
||||
lda (ZPCMDBuf),y
|
||||
bne .10 get strlen ...
|
||||
|
||||
.1 ldx #0 dot counter for /./ & /../ detection
|
||||
|
||||
.12 lda (ZPPTR2)
|
||||
bne .21 last char...
|
||||
|
||||
dey
|
||||
lda (ZPCMDBuf),y
|
||||
.2 lda (ZPPTR2),y
|
||||
tax
|
||||
iny
|
||||
cmp #'/'
|
||||
beq .8
|
||||
lda (ZPPTR2),y
|
||||
bne .2
|
||||
cpx #'/'
|
||||
beq .3
|
||||
|
||||
lda #'/'
|
||||
sta (ZPCMDBuf),y
|
||||
sta (ZPPTR2),y
|
||||
iny
|
||||
bra .13
|
||||
lda #0
|
||||
sta (ZPPTR2),y
|
||||
|
||||
.21 inc ZPPTR2
|
||||
bne .11
|
||||
inc ZPPTR2+1
|
||||
.3 >LDYA ZPPTR2 Get ARG
|
||||
>SYSCALL RealPath.YA
|
||||
bcs .9
|
||||
|
||||
.11 sta (ZPCMDBuf),y
|
||||
iny
|
||||
cmp #'/'
|
||||
beq .13
|
||||
.4 >STYA ZPPTR2
|
||||
txa
|
||||
>STA.G CMD.hFullpath
|
||||
|
||||
cmp #'.' a dot ?
|
||||
bne .1 no, reset counter...
|
||||
inx
|
||||
bra .12
|
||||
|
||||
.13 txa counting dot ?
|
||||
beq .12
|
||||
cpx #2 /../ ?
|
||||
beq .14
|
||||
|
||||
dex /./ ?
|
||||
bne Cmd.Exec.ERRSYN
|
||||
dey
|
||||
dey remove "./" at the end of path....
|
||||
bra .1
|
||||
|
||||
.14 dey remove "../" at the end of path : "/dir1/../"
|
||||
dey
|
||||
dey
|
||||
beq Cmd.Exec.ERRSYN path was "/../".....error....
|
||||
|
||||
.16 dey path is something like : /dir1/, skip ending '/'
|
||||
lda (ZPCMDBuf),y path is something like : /dir1
|
||||
cmp #'/'
|
||||
bne .16
|
||||
|
||||
bra .1 Start over...
|
||||
|
||||
.8 lda #0
|
||||
sta (ZPCMDBuf),y
|
||||
cpy #1
|
||||
beq .80 we have '/' go change prefix
|
||||
|
||||
>LDYA ZPCMDBuf
|
||||
>SYSCALL PrintF.YA
|
||||
lda #'!'
|
||||
>SYSCALL PutChar.A
|
||||
ldy #1
|
||||
lda (ZPPTR2),y
|
||||
beq .8 we have '/'
|
||||
|
||||
>PUSHEA.G CMD.Stat
|
||||
>PUSHW ZPCMDBuf
|
||||
>PUSHW ZPPTR2
|
||||
>SYSCALL STAT
|
||||
bcs .9
|
||||
|
||||
@ -381,7 +314,7 @@ Cmd.Exec.CD1 lda (ZPPTR2) Get ARG
|
||||
cmp #$0F Directory ?
|
||||
bne Cmd.Exec.ERRSYN
|
||||
|
||||
.80 >LDYA ZPCMDBuf
|
||||
.8 >LDYA ZPPTR2
|
||||
>SYSCALL NewStr.YA
|
||||
bcs .9
|
||||
phx
|
||||
|
@ -134,10 +134,6 @@ CSH.Run jsr CSH.GetBuf
|
||||
|
||||
jsr CSH.RestorePtr Restore ptr to get full cmd line to execute
|
||||
|
||||
>LDA.G hCmdBuf Get the buffer
|
||||
>SYSCALL GetMemPtr.A
|
||||
>STYA ZPCMDBuf
|
||||
|
||||
jsr CSH.GetCharNB
|
||||
|
||||
ldy #0
|
||||
|
@ -64,6 +64,7 @@ L.MSG.CSHERR .DA MSG.CSHERR
|
||||
L.ENV.PATH .DA ENV.PATH
|
||||
L.ENV.PWD .DA ENV.PWD
|
||||
L.ENV.PS1 .DA ENV.PS1
|
||||
L.ENV.HOME .DA ENV.HOME
|
||||
L.FMT.DATE .DA FMT.DATE
|
||||
L.FMT.TIME .DA FMT.TIME
|
||||
J.ESC .DA CmdLine.BS left arrow
|
||||
@ -187,11 +188,7 @@ CS.RUN.EXIT lda #0
|
||||
CS.RUN.EXIT.ERR sec
|
||||
CS.RUN.EXIT.RTS rts
|
||||
*--------------------------------------
|
||||
CS.RUN.READ >LDA.G hCmdBuf Get the buffer
|
||||
>SYSCALL GetMemPtr.A
|
||||
>STYA ZPCMDBuf
|
||||
|
||||
lda #0 reset it
|
||||
CS.RUN.READ lda #0 reset Buffer
|
||||
sta (ZPCMDBuf)
|
||||
|
||||
.1 >SYSCALL Sleep
|
||||
@ -205,13 +202,7 @@ CS.RUN.READ >LDA.G hCmdBuf Get the buffer
|
||||
|
||||
>PUSHW ZPCMDBuf
|
||||
|
||||
lda #CMD.VarName
|
||||
clc
|
||||
adc pData
|
||||
tay
|
||||
lda pData+1
|
||||
adc #0
|
||||
>PUSHYA
|
||||
>PUSHEA.G CMD.VarName
|
||||
>SYSCALL SetEnv
|
||||
rts
|
||||
*--------------------------------------
|
||||
@ -480,6 +471,7 @@ CS.END
|
||||
ENV.PATH >CSTR "PATH"
|
||||
ENV.PWD >CSTR "PWD"
|
||||
ENV.PS1 >CSTR "PS1"
|
||||
ENV.HOME >CSTR "HOME"
|
||||
*--------------------------------------
|
||||
INTCMDS >CSTR "CD"
|
||||
>CSTR "DATE"
|
||||
|
@ -39,7 +39,10 @@ K.GetArg.A pha save requested arg#
|
||||
inc ZPPtr1+1
|
||||
|
||||
.5 dex
|
||||
bne .1
|
||||
bne .1 stop here....
|
||||
|
||||
lda (ZPPtr1) at end of ARGS[] ?
|
||||
beq .9
|
||||
|
||||
.8 >LDYA ZPPtr1
|
||||
.80 clc
|
||||
|
@ -77,7 +77,7 @@ K.SYSCALL.JMP .DA 0 $00
|
||||
.DA 0
|
||||
.DA 0
|
||||
.DA 0
|
||||
.DA 0
|
||||
.DA K.RealPath.YA
|
||||
.DA 0
|
||||
*--------------------------------------
|
||||
* Bank 2
|
||||
|
@ -201,6 +201,107 @@ HEXBUF.ROL asl HEXBUF
|
||||
HEXBUF .BS 4 32 bits max
|
||||
BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
||||
ASCBUF .BS 12 LEN + sign + 10 digits ($FFFFFFFF=4.294.967.295)
|
||||
*/--------------------------------------
|
||||
* # RealPath.YA
|
||||
* Return the canonicalized absolute pathname
|
||||
* ## In :
|
||||
* Y,A = Ptr to Relative Filename (C-String)
|
||||
* ## Out :
|
||||
* CC : success
|
||||
* Y,A = Ptr to Full Path (C-String)
|
||||
* X = hMem of Full Path
|
||||
* CS : A = Error Code
|
||||
*\--------------------------------------
|
||||
K.RealPath.YA >STYA ZPPtr1
|
||||
|
||||
ldx #$ff
|
||||
|
||||
lda (ZPPtr1)
|
||||
beq .10
|
||||
|
||||
cmp #'/' full path starting with '/'?
|
||||
beq .2 yes, do not append to current prefix
|
||||
|
||||
.10 ldy #S.PS.hPREFIX
|
||||
lda (pPs),y
|
||||
jsr K.GetMemPtr.A
|
||||
>STYA ZPPtr2
|
||||
|
||||
ldy #$ff
|
||||
|
||||
.1 iny
|
||||
lda (ZPPtr2),y
|
||||
beq .2
|
||||
inx
|
||||
sta K.Buf256,x
|
||||
bra .1
|
||||
|
||||
.2 ldy #$ff
|
||||
|
||||
.3 iny
|
||||
inx
|
||||
lda (ZPPtr1),y
|
||||
sta K.Buf256,x
|
||||
bne .3 X=LEN, K.Buf256 = /dir1..../file(/) /x0
|
||||
*\--------------------------------------
|
||||
.4 dex
|
||||
beq .89 we have '/'....nothing to do...
|
||||
lda K.Buf256,x
|
||||
cmp #'/'
|
||||
bne .5
|
||||
|
||||
dex
|
||||
|
||||
.5 ldy #0 dot counter=0
|
||||
|
||||
.6 lda K.Buf256,x
|
||||
cmp #'/'
|
||||
beq .8
|
||||
cmp #'.'
|
||||
bne .7
|
||||
iny
|
||||
.HS 2C BIT ABS
|
||||
ldy #0
|
||||
|
||||
.7 dex
|
||||
bra .6 always, should end with a '/'
|
||||
|
||||
.8 dey we found "/." ?
|
||||
bmi .80
|
||||
bne .9
|
||||
|
||||
|
||||
bra .80
|
||||
|
||||
.9 dey we found "/.." ?
|
||||
bne .90 "/......" ...mmm...syntax error
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.80 txa
|
||||
beq .89
|
||||
dex
|
||||
bra .5
|
||||
|
||||
.89 >LDYAI K.Buf256
|
||||
>SYSCALL PrintF.YA
|
||||
lda #'@'
|
||||
>SYSCALL PutChar.A
|
||||
lda #13
|
||||
>SYSCALL PutChar.A
|
||||
lda #10
|
||||
>SYSCALL PutChar.A
|
||||
|
||||
>DEBUG
|
||||
|
||||
>LDYAI K.Buf256
|
||||
jmp K.NewStr.YA
|
||||
|
||||
.90 lda #SYSMGR.ERRSYN
|
||||
sec
|
||||
rts
|
||||
*--------------------------------------
|
||||
MAN
|
||||
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDLIB
|
||||
|
Loading…
Reference in New Issue
Block a user