2017-12-22 21:24:30 +00:00
|
|
|
|
NEW
|
2018-11-17 17:17:13 +00:00
|
|
|
|
PREFIX
|
2017-12-22 21:24:30 +00:00
|
|
|
|
AUTO 4,1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* # strtof
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* Convert String to 40 bits Float
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* ## C
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* `float strtof (const char* str, char** endptr);`
|
2018-10-04 15:30:14 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHWI EndPtr`
|
|
|
|
|
* `>LDYA str`
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>SYSCALL strtof`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* On stack (float)
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
K.strtof >STYA TXTPTR Ptr to source string
|
2018-06-15 15:15:48 +00:00
|
|
|
|
>PULLW ZPPtr1
|
|
|
|
|
|
|
|
|
|
jsr K.AToF.I
|
|
|
|
|
|
2017-10-17 15:40:21 +00:00
|
|
|
|
lda TXTPTR
|
2018-06-15 15:15:48 +00:00
|
|
|
|
sta (ZPPtr1)
|
2017-10-17 15:40:21 +00:00
|
|
|
|
ldy #1
|
2017-10-20 15:42:24 +00:00
|
|
|
|
lda TXTPTR+1
|
2018-06-15 15:15:48 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2017-10-20 15:42:24 +00:00
|
|
|
|
rts
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # AToF
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* Convert String to 40 bits Float
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* `float atof (const char* str);`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* `>LDYA str`
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>SYSCALL atof`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* On stack (float)
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-15 15:15:48 +00:00
|
|
|
|
K.AToF >STYA TXTPTR Ptr to source string
|
|
|
|
|
|
|
|
|
|
K.AToF.I jsr CHARGOT
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
2018-06-13 15:18:08 +00:00
|
|
|
|
ldx #ROM.FIN
|
2018-06-15 15:15:48 +00:00
|
|
|
|
**** DUP code in MATH.Go ****
|
2018-06-13 15:18:08 +00:00
|
|
|
|
jsr GP.ROMCALL
|
2018-06-15 15:15:48 +00:00
|
|
|
|
|
|
|
|
|
lda pStack
|
|
|
|
|
sec
|
|
|
|
|
sbc #5
|
|
|
|
|
sta pStack
|
|
|
|
|
sta FORPNT Ptr to dst buffer
|
|
|
|
|
lda pStack+1
|
|
|
|
|
sta FORPNT+1
|
|
|
|
|
|
2018-06-13 15:18:08 +00:00
|
|
|
|
ldx #ROM.GETFAC
|
|
|
|
|
jsr GP.ROMCALL
|
2018-06-15 15:15:48 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
clc
|
|
|
|
|
rts
|
2017-10-10 15:40:23 +00:00
|
|
|
|
*/--------------------------------------
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* # StrToL/StrToUL
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* Convert String to 32 bits (unsigned) int
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* `long strtol (const char* str, char** endptr, int base);`
|
2018-06-15 15:15:48 +00:00
|
|
|
|
* `unsigned long strtoul (const char* str, char** endptr, int base);`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHB Base`
|
|
|
|
|
* `>PUSHWI EndPtr`
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>LDYAI str`
|
|
|
|
|
* `>SYSCALL strtol`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* On stack (long)
|
2017-10-10 15:40:23 +00:00
|
|
|
|
*\--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.StrToL sec Signed
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
K.StrToUL clc Unsigned
|
2018-06-15 15:15:48 +00:00
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
>PULLW ZPPtr1
|
2017-10-12 15:28:59 +00:00
|
|
|
|
>PULLA Base
|
2017-10-23 15:39:19 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
jsr K.AToL.I
|
|
|
|
|
bcs K.StrToUL.rts
|
|
|
|
|
* clc
|
|
|
|
|
|
|
|
|
|
K.StrToUL.Exit adc ZPPtr2
|
2018-06-15 15:15:48 +00:00
|
|
|
|
sta (ZPPtr1)
|
2017-10-12 15:28:59 +00:00
|
|
|
|
lda #0
|
|
|
|
|
adc ZPPtr2+1
|
2017-10-20 15:42:24 +00:00
|
|
|
|
ldy #1
|
2018-06-15 15:15:48 +00:00
|
|
|
|
sta (ZPPtr1),y
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
|
|
|
|
K.StrToUL.rts rts
|
|
|
|
|
*/--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* # atol
|
|
|
|
|
* Convert String to 32 bits long
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2018-06-15 15:15:48 +00:00
|
|
|
|
* `long atol ( const char * str );`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-15 15:15:48 +00:00
|
|
|
|
* `>LDYA str`
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>SYSCALL atol`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-15 15:15:48 +00:00
|
|
|
|
* On stack (long)
|
2017-10-12 15:28:59 +00:00
|
|
|
|
*\--------------------------------------
|
2018-05-23 15:27:37 +00:00
|
|
|
|
*STDLIB.32 .BS 4 32 bits max
|
|
|
|
|
STDLIB.32 .EQ FAC 32 bits max
|
|
|
|
|
*--------------------------------------
|
2018-06-15 15:15:48 +00:00
|
|
|
|
K.AToL >STYA ZPPtr2 C-String in Ptr2, Dst buffer in Ptr1
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
|
|
|
|
lda #10 base 10
|
|
|
|
|
sec signed
|
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
K.AToL.I jsr STDLIB.GetDec
|
2017-10-12 15:28:59 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
phy Save Count processed
|
2017-10-23 15:39:19 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
ldy #3
|
|
|
|
|
|
2017-10-17 15:40:21 +00:00
|
|
|
|
.3 lda STDLIB.32,y
|
2018-06-15 15:15:48 +00:00
|
|
|
|
>PUSHA
|
2017-10-12 15:28:59 +00:00
|
|
|
|
dey
|
|
|
|
|
bpl .3
|
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* # atoi
|
|
|
|
|
* Convert String to 16 bits int
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## C
|
2018-06-15 15:15:48 +00:00
|
|
|
|
* `int atoi ( const char * str );`
|
2018-06-18 06:22:50 +00:00
|
|
|
|
* ## ASM
|
2018-06-14 15:31:36 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>LDYAI str`
|
|
|
|
|
* `>SYSCALL atoi`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* Y,A = int
|
2017-10-10 15:40:23 +00:00
|
|
|
|
*\--------------------------------------
|
2018-06-18 15:48:00 +00:00
|
|
|
|
K.atoi >STYA ZPPtr2
|
2017-10-12 15:28:59 +00:00
|
|
|
|
lda #10 base 10
|
|
|
|
|
sec signed
|
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
jsr STDLIB.GetDec
|
2017-10-12 15:28:59 +00:00
|
|
|
|
bcs .9
|
|
|
|
|
|
2017-10-17 15:40:21 +00:00
|
|
|
|
>LDYA STDLIB.32
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.9 rts
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*--------------------------------------
|
2018-05-25 15:09:14 +00:00
|
|
|
|
* Convert Hex int at ZPPtr2 to STDLIB.32
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2018-05-25 15:09:14 +00:00
|
|
|
|
STDLIB.GetHex lda (ZPPtr2)
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
jsr MEM.IsHexDigit
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
jsr STDLIB.32.Clear
|
|
|
|
|
|
|
|
|
|
sta STDLIB.32
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
beq .8
|
|
|
|
|
jsr MEM.IsHexDigit
|
|
|
|
|
bcs .8
|
|
|
|
|
|
|
|
|
|
pha
|
|
|
|
|
|
|
|
|
|
ldx #4
|
|
|
|
|
|
|
|
|
|
.2 jsr STDLIB.32.T2
|
|
|
|
|
bcs .99 overflow!!!
|
|
|
|
|
dex
|
|
|
|
|
bne .2
|
|
|
|
|
|
|
|
|
|
pla
|
|
|
|
|
ora STDLIB.32
|
|
|
|
|
sta STDLIB.32
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.99 pla
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* Convert Decimal int at ZPPtr2 to STDLIB.32
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
STDLIB.GetDec jsr STDLIB.32.Clear
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-10-10 15:40:23 +00:00
|
|
|
|
ldy #$ff
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-10-10 15:40:23 +00:00
|
|
|
|
.1 iny
|
2017-10-12 15:28:59 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-08-24 06:47:31 +00:00
|
|
|
|
beq .8
|
2017-10-10 15:40:23 +00:00
|
|
|
|
|
2018-04-17 15:25:45 +00:00
|
|
|
|
jsr MEM.IsDigit
|
2017-10-10 15:40:23 +00:00
|
|
|
|
bcs .8
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-28 06:00:45 +00:00
|
|
|
|
phy Save Y, pointing to next char
|
2017-10-17 15:40:21 +00:00
|
|
|
|
jsr STDLIB.32.T10
|
2018-05-28 06:00:45 +00:00
|
|
|
|
ply
|
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
bcs .9
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-08-24 06:47:31 +00:00
|
|
|
|
and #$0F
|
2018-05-23 15:27:37 +00:00
|
|
|
|
|
|
|
|
|
* clc
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2017-10-17 15:40:21 +00:00
|
|
|
|
adc STDLIB.32
|
|
|
|
|
sta STDLIB.32
|
2017-10-09 15:30:48 +00:00
|
|
|
|
bcc .1
|
2017-10-17 15:40:21 +00:00
|
|
|
|
inc STDLIB.32+1
|
2017-10-09 15:30:48 +00:00
|
|
|
|
bne .1
|
2017-10-17 15:40:21 +00:00
|
|
|
|
inc STDLIB.32+2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bne .1
|
2017-10-17 15:40:21 +00:00
|
|
|
|
inc STDLIB.32+3
|
2017-10-10 15:40:23 +00:00
|
|
|
|
bne .1 overflow!!!
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* sec
|
|
|
|
|
rts
|
2017-08-24 06:47:31 +00:00
|
|
|
|
|
2018-11-12 14:48:28 +00:00
|
|
|
|
.8 tya
|
|
|
|
|
sec
|
|
|
|
|
beq .9
|
|
|
|
|
|
|
|
|
|
clc
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.9 rts
|
2017-10-09 15:30:48 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-17 15:40:21 +00:00
|
|
|
|
STDLIB.32.T10 ldx #3
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-10-17 15:40:21 +00:00
|
|
|
|
.1 lda STDLIB.32,x save STDLIB.32 for 4+1
|
2017-10-12 15:28:59 +00:00
|
|
|
|
pha
|
2017-10-09 15:30:48 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
jsr STDLIB.32.T2 STDLIB.32 * 2 -> STDLIB.32
|
|
|
|
|
bcs STDLIB.32.9 overflow!!!
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
jsr STDLIB.32.T2 STDLIB.32 * 4 -> STDLIB.32
|
|
|
|
|
bcs STDLIB.32.9 overflow!!!
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
|
|
|
|
ldx #0
|
2017-10-09 15:30:48 +00:00
|
|
|
|
ldy #4
|
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* clc
|
|
|
|
|
|
2017-10-17 15:40:21 +00:00
|
|
|
|
.2 pla STDLIB.32 * 4 + STDLIB.32 -> STDLIB.32
|
|
|
|
|
adc STDLIB.32,x
|
|
|
|
|
sta STDLIB.32,x
|
2017-10-12 15:28:59 +00:00
|
|
|
|
inx
|
2017-10-09 15:30:48 +00:00
|
|
|
|
dey
|
|
|
|
|
bne .2
|
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
bcs STDLIB.32.RTS overflow!!!
|
2017-10-12 15:28:59 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
* STDLIB.32 * 2 -> STDLIB.32
|
2018-05-23 15:27:37 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
STDLIB.32.T2 asl STDLIB.32
|
2018-05-23 15:27:37 +00:00
|
|
|
|
rol STDLIB.32+1
|
|
|
|
|
rol STDLIB.32+2
|
|
|
|
|
rol STDLIB.32+3
|
2017-10-23 15:39:19 +00:00
|
|
|
|
rts if CS, overflow!!!
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
STDLIB.32.9 pla discard saved STDLIB.32
|
2017-10-09 15:30:48 +00:00
|
|
|
|
pla
|
2017-10-12 15:28:59 +00:00
|
|
|
|
pla
|
|
|
|
|
pla
|
2017-10-26 06:41:57 +00:00
|
|
|
|
|
2018-05-25 15:09:14 +00:00
|
|
|
|
STDLIB.32.RTS rts
|
2017-10-12 15:28:59 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-17 15:40:21 +00:00
|
|
|
|
STDLIB.32.Clear ldx #3
|
|
|
|
|
|
|
|
|
|
.1 stz STDLIB.32,x
|
2017-10-09 15:30:48 +00:00
|
|
|
|
dex
|
2017-10-12 15:28:59 +00:00
|
|
|
|
bpl .1
|
2017-10-09 15:30:48 +00:00
|
|
|
|
rts
|
2017-09-28 15:39:12 +00:00
|
|
|
|
*/--------------------------------------
|
2018-08-11 10:57:57 +00:00
|
|
|
|
* # RealPath
|
2017-09-28 15:39:12 +00:00
|
|
|
|
* Return the canonicalized absolute pathname
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* ## C
|
|
|
|
|
* `unsigned short int realpath (const char* str);`
|
|
|
|
|
* ## ASM
|
2018-06-18 08:44:02 +00:00
|
|
|
|
* **In:**
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* `>LDYA str`
|
|
|
|
|
* `>SYSCALL realpath`
|
2018-10-11 15:23:06 +00:00
|
|
|
|
* ## RETURN VALUE
|
2018-06-18 15:48:00 +00:00
|
|
|
|
* CC : success
|
|
|
|
|
* Y,A = Ptr to Full Path (C-String)
|
|
|
|
|
* X = hMem of Full Path
|
|
|
|
|
* CS : A = Error Code
|
2017-09-28 15:39:12 +00:00
|
|
|
|
*\--------------------------------------
|
2018-11-07 16:11:02 +00:00
|
|
|
|
K.realpath sec
|
|
|
|
|
.HS 90 BCC
|
|
|
|
|
K.realpath.I clc
|
|
|
|
|
ror .89+1
|
|
|
|
|
|
|
|
|
|
>STYA ZPPtr1
|
2018-10-29 08:41:10 +00:00
|
|
|
|
|
2017-09-28 15:39:12 +00:00
|
|
|
|
ldx #$ff
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr1)
|
2017-10-03 15:33:30 +00:00
|
|
|
|
beq .1
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
|
|
|
|
cmp #'/' full path starting with '/'?
|
2017-10-03 15:33:30 +00:00
|
|
|
|
beq .3 yes, do not append to current prefix
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.1 ldy #S.PS.hPREFIX
|
2017-09-28 15:39:12 +00:00
|
|
|
|
lda (pPs),y
|
2018-06-21 15:12:10 +00:00
|
|
|
|
jsr K.GetMemPtr
|
2017-09-28 15:39:12 +00:00
|
|
|
|
>STYA ZPPtr2
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.2 iny
|
2017-09-28 15:39:12 +00:00
|
|
|
|
inx
|
2017-09-29 06:36:27 +00:00
|
|
|
|
lda (ZPPtr2),y
|
2017-09-28 15:39:12 +00:00
|
|
|
|
sta K.Buf256,x
|
2017-10-03 15:33:30 +00:00
|
|
|
|
bne .2
|
2017-09-29 06:36:27 +00:00
|
|
|
|
|
|
|
|
|
dex
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.3 ldy #$ff
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.4 iny
|
2017-09-28 15:39:12 +00:00
|
|
|
|
inx
|
|
|
|
|
lda (ZPPtr1),y
|
|
|
|
|
sta K.Buf256,x
|
2017-10-03 15:33:30 +00:00
|
|
|
|
bne .4
|
2018-11-27 16:22:15 +00:00
|
|
|
|
|
2017-09-29 14:57:20 +00:00
|
|
|
|
dex
|
2017-09-28 15:39:12 +00:00
|
|
|
|
beq .89 we have '/'....nothing to do...
|
2018-11-27 16:22:15 +00:00
|
|
|
|
|
|
|
|
|
lda K.Buf256,x
|
2017-09-28 15:39:12 +00:00
|
|
|
|
cmp #'/'
|
2018-11-27 16:22:15 +00:00
|
|
|
|
bne .50
|
|
|
|
|
stz K.Buf256,x remove ending / if any
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
* X=LEN, K.Buf256 = /dir1/./../file\0
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
.50 ldx #1
|
|
|
|
|
|
|
|
|
|
lda K.Buf256,x
|
|
|
|
|
beq .89
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
|
|
|
|
.5 ldy #0 dot counter=0
|
2018-11-27 16:22:15 +00:00
|
|
|
|
|
|
|
|
|
.6 cmp #'/'
|
2017-09-28 15:39:12 +00:00
|
|
|
|
beq .8
|
2017-09-29 06:36:27 +00:00
|
|
|
|
|
2017-09-28 15:39:12 +00:00
|
|
|
|
cmp #'.'
|
|
|
|
|
bne .7
|
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
iny
|
|
|
|
|
.HS 2C BIT ABS, skip "LDY #0"
|
|
|
|
|
.7 ldy #0 not a dot....reset dot counter
|
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
inx
|
|
|
|
|
lda K.Buf256,x
|
|
|
|
|
bne .6 always, should end with a '/'
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
.8 tya
|
|
|
|
|
beq .80 Y was 0....nothing to do...
|
2018-11-27 16:22:15 +00:00
|
|
|
|
dey "./" ?
|
2017-09-29 06:36:27 +00:00
|
|
|
|
bne .9 no..
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
lda K.Buf256-2,x
|
2018-11-27 14:03:26 +00:00
|
|
|
|
cmp #'/' "/./" ?
|
|
|
|
|
bne .80
|
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
dex
|
|
|
|
|
dex
|
|
|
|
|
jsr K.RealPath.RemoveAtX we found "/./", remove,useless....
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
|
|
|
|
bra .80
|
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
.9 dey "../" ?
|
|
|
|
|
bne .90 ".../" ??!!...mmm...syntax error
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
lda K.Buf256-3,x
|
2018-11-27 14:03:26 +00:00
|
|
|
|
cmp #'/' "/../" ?
|
|
|
|
|
bne .80
|
2018-11-27 16:22:15 +00:00
|
|
|
|
|
|
|
|
|
dex
|
|
|
|
|
dex
|
|
|
|
|
dex
|
2018-11-27 14:03:26 +00:00
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
txa we found "/../"
|
2017-09-29 06:36:27 +00:00
|
|
|
|
beq .90 at the beginning of string...cannot remove /dir/..
|
|
|
|
|
|
|
|
|
|
jsr K.RealPath.RemoveAtX remove "/.."
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.10 dex
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-09-29 14:57:20 +00:00
|
|
|
|
lda K.Buf256,x go to "/dir"
|
2017-09-29 06:36:27 +00:00
|
|
|
|
cmp #'/'
|
2017-10-03 15:33:30 +00:00
|
|
|
|
bne .10
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
jsr K.RealPath.RemoveAtX ...remove "/dir"
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2018-11-27 16:22:15 +00:00
|
|
|
|
.80 inx
|
|
|
|
|
lda K.Buf256,x
|
|
|
|
|
bne .5
|
2018-11-27 14:03:26 +00:00
|
|
|
|
*--------------------------------------
|
2018-11-07 16:11:02 +00:00
|
|
|
|
.89 lda #$ff SELF MODIFIED
|
|
|
|
|
bpl .98
|
|
|
|
|
>LDYAI K.Buf256
|
2018-06-22 14:59:24 +00:00
|
|
|
|
jmp K.NewStr
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2018-11-20 15:54:49 +00:00
|
|
|
|
.90 lda #E.BADPATH
|
2017-09-28 15:39:12 +00:00
|
|
|
|
sec
|
|
|
|
|
rts
|
2018-11-07 16:11:02 +00:00
|
|
|
|
|
|
|
|
|
.98 clc
|
|
|
|
|
rts
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-29 06:36:27 +00:00
|
|
|
|
K.RealPath.RemoveAtX
|
|
|
|
|
txa X = "/something"
|
|
|
|
|
tay
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda K.Buf256,y
|
|
|
|
|
beq .2
|
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .1
|
|
|
|
|
|
|
|
|
|
.2 phx
|
|
|
|
|
|
|
|
|
|
.3 lda K.Buf256,y
|
|
|
|
|
sta K.Buf256,x
|
2017-10-03 15:33:30 +00:00
|
|
|
|
beq .4
|
2017-09-29 06:36:27 +00:00
|
|
|
|
iny
|
|
|
|
|
inx
|
|
|
|
|
bne .3
|
|
|
|
|
|
2017-10-03 15:33:30 +00:00
|
|
|
|
.4 txa
|
|
|
|
|
bne .8
|
|
|
|
|
|
|
|
|
|
lda #'/' Make sure we have a least '/' in the buffer
|
|
|
|
|
sta K.Buf256
|
|
|
|
|
stz K.Buf256+1
|
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
.8 plx
|
|
|
|
|
rts
|
2018-11-17 17:17:13 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # StrMatch
|
|
|
|
|
* Compare a String against pattern (e.g. '*test?.txt')
|
|
|
|
|
* ## C
|
|
|
|
|
* `int * strmatch ( char * s, const char * pattern );`
|
|
|
|
|
* ## ASM
|
|
|
|
|
* **In:**
|
|
|
|
|
* `>PUSHWI pattern`
|
|
|
|
|
* `>LDYAI s`
|
|
|
|
|
* `>SYSCALL strmatch`
|
|
|
|
|
* ## RETURN VALUE
|
|
|
|
|
* CC : match
|
|
|
|
|
* CS : no match
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.StrMatch jsr MEM.SPtr1PPtr2
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) Get pattern 1st byte
|
|
|
|
|
beq .8 Match always if empty
|
|
|
|
|
|
|
|
|
|
ldy #0
|
|
|
|
|
|
|
|
|
|
bra .21
|
|
|
|
|
|
|
|
|
|
.1 inc ZPPtr2 Make PTR2 (pattern) advance to next char
|
|
|
|
|
bne .2
|
|
|
|
|
inc ZPPtr2+1
|
|
|
|
|
|
|
|
|
|
.2 lda (ZPPtr2) get pattern char
|
|
|
|
|
beq .41 end of pattern...
|
|
|
|
|
|
|
|
|
|
.21 cmp #'*'
|
|
|
|
|
beq .5
|
|
|
|
|
|
|
|
|
|
.3 lda (ZPPtr1) we must match ? or regular char, check if at end of string
|
|
|
|
|
beq .9 no char left, exit with error
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) get back pattern char
|
|
|
|
|
cmp #'?'
|
|
|
|
|
beq .4 no need to compare, any char will match
|
|
|
|
|
cmp (ZPPtr1),y Regular Char, compare with string at Y
|
|
|
|
|
bne .9 no match, exit
|
|
|
|
|
|
|
|
|
|
.4 iny advance to next char to compare
|
|
|
|
|
bra .1 continue if remaining char in pattern
|
|
|
|
|
|
|
|
|
|
.41 lda (ZPPtr1),y end of pattern, but end of string ?
|
|
|
|
|
|
|
|
|
|
beq .8 yes, string matched entirely
|
|
|
|
|
* no, remaining char in string, no match
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.5 inc ZPPtr2 Make PTR2 advance to next char
|
|
|
|
|
bne .6
|
|
|
|
|
inc ZPPtr2+1
|
|
|
|
|
|
|
|
|
|
.6 lda (ZPPtr2) we have '*', last char of pattern ?
|
|
|
|
|
beq .8 yes, match everything, including empty string
|
|
|
|
|
|
|
|
|
|
lda (ZPPtr2) get next char of pattern
|
|
|
|
|
cmp #'*' another '*' ?
|
|
|
|
|
beq .5 yes, '**' = '*', go next char
|
|
|
|
|
cmp #'?' '*?' ? we must match a least one char
|
|
|
|
|
beq .3
|
|
|
|
|
|
|
|
|
|
.7 lda (ZPPtr1),y we need at least one remaining char in string, check if at end of string
|
|
|
|
|
beq .9 no chance to match ? or regular char
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
lda (ZPPtr2) get again char in pattern
|
|
|
|
|
cmp (ZPPtr1),y compare with char in string
|
|
|
|
|
bne .7 not equal to next non wildcard in pattern
|
|
|
|
|
|
|
|
|
|
iny
|
|
|
|
|
bra .1 go check remaining char in pattern...
|
|
|
|
|
|
|
|
|
|
.8 clc
|
|
|
|
|
rts
|
2017-09-29 06:36:27 +00:00
|
|
|
|
*--------------------------------------
|
2017-08-23 15:05:29 +00:00
|
|
|
|
MAN
|
2018-11-17 17:17:13 +00:00
|
|
|
|
SAVE USR/SRC/SYS/KERNEL.S.STDLIB
|
|
|
|
|
LOAD USR/SRC/SYS/KERNEL.S
|
2017-08-23 15:05:29 +00:00
|
|
|
|
ASM
|