2017-08-23 15:05:29 +00:00
|
|
|
|
PR#3
|
|
|
|
|
PREFIX /A2OSX.BUILD
|
|
|
|
|
LOMEM $A00
|
|
|
|
|
INC 1
|
|
|
|
|
AUTO 6
|
|
|
|
|
*/--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* # StrToF
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* Convert String to 40 bits Float
|
|
|
|
|
* ## In:
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* PUSHW PTR to EndPtr
|
2017-10-09 15:30:48 +00:00
|
|
|
|
* PUSHW Source String (C-Sring)
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* PUSHW PTR to target buffer (5 bytes)
|
2017-08-25 15:02:16 +00:00
|
|
|
|
* ## Out:
|
|
|
|
|
*\--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.StrToF jsr PullPtr1Ptr2Ptr3
|
|
|
|
|
jsr K.AToF.I
|
|
|
|
|
bcc K.StrToUL.Exit
|
|
|
|
|
|
|
|
|
|
.9 rts
|
2017-08-25 15:02:16 +00:00
|
|
|
|
*/--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* # AToF
|
|
|
|
|
* Convert String to 40 bits Float
|
2017-08-23 15:05:29 +00:00
|
|
|
|
* ## In:
|
2017-09-29 14:57:20 +00:00
|
|
|
|
* PUSHW Source String (C-Sring)
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* PUSHW PTR to target buffer (5 Bytes)
|
2017-08-23 15:05:29 +00:00
|
|
|
|
* ## Out:
|
|
|
|
|
*\--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.AToF jsr PullPtr1Ptr2 C-String in Ptr2, Dst buffer in Ptr1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.AToF.I jsr MANTISSA.Clear
|
|
|
|
|
|
|
|
|
|
ldy #$ff
|
|
|
|
|
|
|
|
|
|
.1 iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
beq .8
|
|
|
|
|
cmp #' '
|
|
|
|
|
beq .1
|
|
|
|
|
|
|
|
|
|
.2 iny
|
|
|
|
|
lda (ZPPtr2),y
|
|
|
|
|
beq .8
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
jsr STDIO.IsDigit
|
|
|
|
|
bcc .7
|
|
|
|
|
|
|
|
|
|
cmp #'+'
|
|
|
|
|
beq .3
|
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .4
|
|
|
|
|
|
|
|
|
|
.3 jsr K.AToF.CheckSign
|
2017-10-10 15:40:23 +00:00
|
|
|
|
bcs .9
|
2017-10-12 15:28:59 +00:00
|
|
|
|
bra .1
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.4 cmp #'.'
|
|
|
|
|
bne .5
|
|
|
|
|
ldx INEXP Decimal point not allowed in EXP
|
|
|
|
|
bne .9
|
|
|
|
|
ldx bDECPOINT ....and only one!
|
|
|
|
|
bne .9
|
|
|
|
|
inc bDECPOINT
|
|
|
|
|
bra .1
|
|
|
|
|
|
|
|
|
|
.5 cmp #'E'
|
|
|
|
|
beq .6
|
|
|
|
|
|
|
|
|
|
cmp #'e'
|
|
|
|
|
bne .8
|
|
|
|
|
.6
|
|
|
|
|
|
|
|
|
|
.7
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.8 clc
|
|
|
|
|
|
|
|
|
|
.9 lda #SYSMGR.ERRSYN
|
|
|
|
|
sec
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
K.AToF.CheckSign
|
|
|
|
|
ldy INEXP Get MANTSIGN or EXPSIGN
|
|
|
|
|
ldx MANTSIGN,y
|
|
|
|
|
bne .9 Already set, error
|
2017-08-23 15:05:29 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
cmp #'-'
|
|
|
|
|
bne .1
|
|
|
|
|
lda #$ff
|
|
|
|
|
.1 sta MANTSIGN,y set '+' of $ff to test with BIT
|
|
|
|
|
|
|
|
|
|
clc
|
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
.9 sec
|
|
|
|
|
rts
|
2017-10-10 15:40:23 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # StrToL
|
|
|
|
|
* Convert String to 32 bits int
|
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHB Base
|
|
|
|
|
* PUSHW PTR to EndPtr
|
|
|
|
|
* PUSHW Source String (C-Sring)
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* PUSHW PTR to target buffer DWORD
|
2017-10-10 15:40:23 +00:00
|
|
|
|
* ## Out:
|
|
|
|
|
*\--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.StrToL sec Signed
|
|
|
|
|
.HS 90 BCC
|
2017-10-10 15:40:23 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # StrToUL
|
|
|
|
|
* Convert String to 32 bits unsigned int
|
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHB Base
|
|
|
|
|
* PUSHW PTR to EndPtr
|
|
|
|
|
* PUSHW Source String (C-Sring)
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* PUSHW PTR to target buffer DWORD
|
|
|
|
|
* ## Out:
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.StrToUL clc Unsigned
|
|
|
|
|
jsr PullPtr1Ptr2Ptr3
|
|
|
|
|
>PULLA Base
|
|
|
|
|
jsr K.AToL.I
|
|
|
|
|
bcs K.StrToUL.rts
|
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
|
|
|
|
|
K.StrToUL.Exit adc ZPPtr2
|
|
|
|
|
sta ZPPtr3
|
|
|
|
|
lda #0
|
|
|
|
|
adc ZPPtr2+1
|
|
|
|
|
sta ZPPtr3+1
|
|
|
|
|
|
|
|
|
|
K.StrToUL.rts rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # AToL
|
|
|
|
|
* Convert String to 32 bits int
|
|
|
|
|
* ## In:
|
|
|
|
|
* PUSHW Source String (C-Sring)
|
|
|
|
|
* PUSHW PTR to target buffer DWORD
|
|
|
|
|
* ## Out:
|
|
|
|
|
*\--------------------------------------
|
|
|
|
|
K.AToL jsr PullPtr1Ptr2 C-String in Ptr2, Dst buffer in Ptr1
|
|
|
|
|
|
|
|
|
|
lda #10 base 10
|
|
|
|
|
sec signed
|
|
|
|
|
|
|
|
|
|
K.AToL.I jsr STDLIB.Dec2Hex
|
|
|
|
|
bcs .9
|
|
|
|
|
phy Save Count processed
|
|
|
|
|
ldy #3
|
|
|
|
|
|
|
|
|
|
.3 lda MANTISSA,y
|
|
|
|
|
sta (ZPPtr1),y
|
|
|
|
|
dey
|
|
|
|
|
bpl .3
|
|
|
|
|
pla
|
|
|
|
|
|
|
|
|
|
* clc
|
|
|
|
|
|
|
|
|
|
.9 rts
|
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # AToI.YA
|
|
|
|
|
* Convert String to 16 bits int
|
|
|
|
|
* ## In:
|
|
|
|
|
* Y,A = Source String (C-String)
|
2017-10-10 15:40:23 +00:00
|
|
|
|
* ## Out:
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* Y,A = Int
|
2017-10-10 15:40:23 +00:00
|
|
|
|
*\--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
K.AToI.YA >STYA ZPPtr2
|
|
|
|
|
lda #10 base 10
|
|
|
|
|
sec signed
|
|
|
|
|
|
|
|
|
|
jsr STDLIB.Dec2Hex
|
|
|
|
|
bcs .9
|
|
|
|
|
|
|
|
|
|
>LDYA MANTISSA
|
|
|
|
|
.9 rts
|
2017-08-23 15:05:29 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* Convert ZPPtr1 to MANTISSA
|
2017-08-24 06:47:31 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
STDLIB.Dec2Hex jsr MANTISSA.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
|
|
|
|
|
|
|
|
|
jsr STDIO.IsDigit
|
|
|
|
|
bcs .8
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
jsr MANTISSA.T10
|
|
|
|
|
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
|
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
adc MANTISSA
|
|
|
|
|
sta MANTISSA
|
2017-10-09 15:30:48 +00:00
|
|
|
|
bcc .1
|
2017-10-12 15:28:59 +00:00
|
|
|
|
inc MANTISSA+1
|
2017-10-09 15:30:48 +00:00
|
|
|
|
bne .1
|
2017-10-12 15:28:59 +00:00
|
|
|
|
inc MANTISSA+2
|
2017-08-24 06:47:31 +00:00
|
|
|
|
bne .1
|
2017-10-12 15:28:59 +00:00
|
|
|
|
inc MANTISSA+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
|
|
|
|
|
2017-10-10 15:40:23 +00:00
|
|
|
|
.8 clc
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.9 rts
|
2017-10-09 15:30:48 +00:00
|
|
|
|
*--------------------------------------
|
2017-10-12 15:28:59 +00:00
|
|
|
|
MANTISSA.T10 ldx #3
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.1 lda MANTISSA,x save MANTISSA for 4+1
|
|
|
|
|
pha
|
2017-10-09 15:30:48 +00:00
|
|
|
|
dex
|
|
|
|
|
bpl .1
|
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
jsr MANTISSA.ROL MANTISSA * 2 -> MANTISSA
|
|
|
|
|
bcs .9 overflow!!!
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
jsr MANTISSA.ROL MANTISSA * 4 -> MANTISSA
|
|
|
|
|
bcs .9 overflow!!!
|
|
|
|
|
|
|
|
|
|
ldx #0
|
2017-10-09 15:30:48 +00:00
|
|
|
|
ldy #4
|
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
* clc
|
|
|
|
|
|
|
|
|
|
.2 pla MANTISSA * 4 + MANTISSA -> MANTISSA
|
|
|
|
|
adc MANTISSA,x
|
|
|
|
|
sta MANTISSA,x
|
|
|
|
|
inx
|
2017-10-09 15:30:48 +00:00
|
|
|
|
dey
|
|
|
|
|
bne .2
|
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
bcs .99 overflow!!!
|
|
|
|
|
|
|
|
|
|
jsr MANTISSA.ROL MANTISSA * 10 -> MANTISSA
|
|
|
|
|
bcs .99 overflow!!!
|
2017-10-09 15:30:48 +00:00
|
|
|
|
|
2017-10-12 15:28:59 +00:00
|
|
|
|
.9 pla discard saved MANTISSA
|
2017-10-09 15:30:48 +00:00
|
|
|
|
pla
|
2017-10-12 15:28:59 +00:00
|
|
|
|
pla
|
|
|
|
|
pla
|
|
|
|
|
.99 rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MANTISSA.ROL asl MANTISSA
|
|
|
|
|
rol MANTISSA+1
|
|
|
|
|
rol MANTISSA+2
|
|
|
|
|
rol MANTISSA+3
|
|
|
|
|
rts
|
|
|
|
|
*--------------------------------------
|
|
|
|
|
MANTISSA.Clear ldx #8
|
|
|
|
|
.1 stz EXPSIGN,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-10-12 15:28:59 +00:00
|
|
|
|
bDECPOINT .BS 1
|
|
|
|
|
INEXP .BS 1
|
|
|
|
|
MANTSIGN .BS 1
|
|
|
|
|
EXPSIGN .BS 1
|
|
|
|
|
EXP .BS 1
|
|
|
|
|
MANTISSA .BS 4 32 bits max
|
2017-09-28 15:39:12 +00:00
|
|
|
|
*/--------------------------------------
|
|
|
|
|
* # 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)
|
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
|
|
|
|
|
jsr K.GetMemPtr.A
|
|
|
|
|
>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
|
2017-09-29 06:36:27 +00:00
|
|
|
|
*--------------------------------------
|
2017-09-29 14:57:20 +00:00
|
|
|
|
* X=LEN, K.Buf256 = /dir1../file(/) /x0
|
|
|
|
|
|
|
|
|
|
dex
|
2017-09-28 15:39:12 +00:00
|
|
|
|
beq .89 we have '/'....nothing to do...
|
2017-09-29 06:36:27 +00:00
|
|
|
|
|
|
|
|
|
lda K.Buf256,x Skip any / at the end of string....
|
2017-09-28 15:39:12 +00:00
|
|
|
|
cmp #'/'
|
|
|
|
|
bne .5
|
|
|
|
|
|
|
|
|
|
dex
|
|
|
|
|
|
|
|
|
|
.5 ldy #0 dot counter=0
|
|
|
|
|
|
|
|
|
|
.6 lda K.Buf256,x
|
|
|
|
|
cmp #'/'
|
|
|
|
|
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
|
|
|
|
|
|
2017-09-29 14:57:20 +00:00
|
|
|
|
txa
|
|
|
|
|
beq .89
|
|
|
|
|
dex
|
|
|
|
|
bra .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...
|
|
|
|
|
dey "/." ?
|
|
|
|
|
bne .9 no..
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
jsr K.RealPath.RemoveAtX we found "/.", remove,useless....
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
|
|
|
|
bra .80
|
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
.9 dey "/.." ?
|
|
|
|
|
bne .90 "/..." ??!!...mmm...syntax error
|
2017-09-28 15:39:12 +00:00
|
|
|
|
|
2017-09-29 06:36:27 +00:00
|
|
|
|
txa we found "/.."
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
.80 txa
|
2017-10-03 15:33:30 +00:00
|
|
|
|
beq .89 Empty path!!! go put back "/" an exit
|
2017-09-28 15:39:12 +00:00
|
|
|
|
dex
|
|
|
|
|
bra .5
|
|
|
|
|
|
|
|
|
|
.89 >LDYAI K.Buf256
|
|
|
|
|
jmp K.NewStr.YA
|
|
|
|
|
|
|
|
|
|
.90 lda #SYSMGR.ERRSYN
|
|
|
|
|
sec
|
|
|
|
|
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
|
|
|
|
|
*--------------------------------------
|
2017-08-23 15:05:29 +00:00
|
|
|
|
MAN
|
|
|
|
|
SAVE /A2OSX.SRC/SYS/KERNEL.S.STDLIB
|
|
|
|
|
LOAD /A2OSX.SRC/SYS/KERNEL.S
|
|
|
|
|
ASM
|