Kernel 0.9.1 : STDLIB : AToL, StrToL....etc...(wip)

This commit is contained in:
Rémy GIBERT 2017-10-10 17:40:23 +02:00
parent a6ac9584d8
commit 33a96ed69a
11 changed files with 207 additions and 159 deletions

View File

@ -469,7 +469,7 @@ Read bytes from file
+ A = hFILE
# FSeek
+ Set the file-position indicator for hFILE
Set the file-position indicator for hFILE
## In:
+ PUSHW = Ptr to Offset (DWORD)
@ -477,7 +477,7 @@ Read bytes from file
+ PUSHB = hFILE
# FEOF.A
+ Test the end-of-file indicator for hFILE
Test the end-of-file indicator for hFILE
## In:
+ A = hFILE
@ -489,7 +489,7 @@ Read bytes from file
+ CS :
# FTell
+ Return the current value of the file-position indicator
Return the current value of the file-position indicator
## In:
+ PUSHW = Ptr to Offset (DWORD)
@ -537,7 +537,6 @@ FPrintF.YA :
+ CC : success
+ CS : error code from Output
+ Specifiers :
+ %a : pull 2 bytes to Print Access right String 'drwxrwxrwx'
+ %b : pull 1 byte to Print BIN
+ %B : pull 2 bytes to Print BIN
+ %d : pull 1 byte unsigned DEC 0..255
@ -574,7 +573,7 @@ Convert String to 40 bits Float
## In:
+ PUSHW PTR to target buffer (5 Bytes)
+ PUSHW Source String (PSTR)
+ PUSHW Source String (C-Sring)
## Out:
@ -596,6 +595,38 @@ Convert String to 32 bits int
## Out:
# StrToF
Convert String to 40 bits Float
## In:
+ PUSHW PTR to target buffer FLOAT (5 bytes)
+ PUSHW PTR to EndPtr
+ PUSHW Source String (C-Sring)
## Out:
# StrToL
Convert String to 32 bits int
## In:
+ PUSHB Base
+ PUSHW PTR to target buffer DWORD
+ PUSHW PTR to EndPtr
+ PUSHW Source String (C-Sring)
## Out:
# StrToUL
Convert String to 32 bits unsigned int
## In:
+ PUSHB Base
+ PUSHW PTR to target buffer DWORD
+ PUSHW PTR to EndPtr
+ PUSHW Source String (C-Sring)
## Out:
# RealPath.YA
Return the canonicalized absolute pathname

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -238,12 +238,8 @@ CS.RUN.DIR >LDA.G bAllmostAll
.4 jsr CS.RUN.PUSHDATES
ldy #S.STAT.MODE+1
lda (ZPFileStat),y
>PUSHA
dey
lda (ZPFileStat),y
>PUSHA File Mode
jsr Mod2CSTR
>PUSHEA.G MOD File Mod
>PUSHW ZPFileName
>LDYA L.MSG.DIREXT
@ -295,12 +291,8 @@ CS.RUN.FILE ldy #bLong
adc #0
>PUSHYA File Size
ldy #S.STAT.MODE+1
lda (ZPFileStat),y
>PUSHA
dey
lda (ZPFileStat),y
>PUSHA File Mode
jsr Mod2CSTR
>PUSHEA.G MOD File Mod
ldy #S.STAT.P.AUXTYPE+1
lda (ZPFileStat),y
@ -457,6 +449,52 @@ FileType2PSTR ldy #0
adc #0
rts
*--------------------------------------
Mod2CSTR ldy #S.STAT.MODE+1
lda (ZPFileStat),y
lsr
lsr
lsr
lsr
tax
lda TYPES,x
>STA.G MOD
ldx #0
ldy #S.STAT.MODE
lda (ZPFileStat),y
ldy #MOD+1
.1 lsr
pha
lda #'-'
bcc .2
lda ACCESS,x
.2 sta (pData),y
iny
pla
inx
cpx #8
bne .1
.3 ldy #S.STAT.MODE+1
lda (ZPFileStat),y
lsr
lda #'-'
bcc .4
lda ACCESS,x
.4 >STA.G MOD+9
rts
*--------------------------------------
.INB /A2OSX.SRC/BIN/X.FILEENUM.S
*--------------------------------------
CS.END
@ -467,9 +505,9 @@ OptionVars .DA #bAllmostAll,#bLong,#bRecurse,#bAllmostAll,#bLong,#bRecurse
MSG.DEVEXT >CSTR "%15s S%d,D%d Blocks Used:%5D Total:%5D\r\n"
MSG.DIR >CSTR "\e[32m%s/\e[0m"
MSG.ENTER >CSTR "Directory:%s\r\n"
MSG.DIREXT >CSTR "\e[32m%16s\e[0m <dir> %a %s %s\r\n"
MSG.DIREXT >CSTR "\e[32m%16s\e[0m <dir> %s %s %s\r\n"
MSG.FILE >CSTR "%19s"
MSG.FILEEXT >CSTR "%15s %S $%H %a %10u %s %s\r\n"
MSG.FILEEXT >CSTR "%15s %S $%H %s %10u %s %s\r\n"
*--------------------------------------
PRODOS.FT.HEX .HS 0406FAFCFDE2FF
PRODOS.FT.TXT >PSTR "TXT"
@ -483,12 +521,15 @@ PRODOS.FT.DFLT >PSTR "$ "
MSG.NODATE >CSTR " <No-Date> "
FMT.DateTime >CSTR "%d-%b-%y %H:%M"
HEXDIGIT .AS '0123456789ABCDEF'
TYPES .AS "-dbclssp"
ACCESS .AS "rwxrwxrwx"
*--------------------------------------
.DUMMY
.OR 0
DS.START
ArgCount .BS 1
MOD .BS 11 drwxrwxrwx0
TIME.Create .BS 20
TIME.Mod .BS 20

View File

@ -48,8 +48,11 @@ K.GetDevByName.YA
.2 iny
lda (ZPPtr1),y
ora (ZPPtr2),y
bne .3 Both char are 0, match!
cmp (ZPPtr2),y
bne .3
ora (ZPPtr2),y Both char are 0 ?
bne .2 no....loop
lda ZPPtr2
sec
@ -60,11 +63,7 @@ K.GetDevByName.YA
clc
rts
.3 lda (ZPPtr1),y
cmp (ZPPtr2),y
beq .2
lda ZPPtr2
.3 lda ZPPtr2
clc
adc #S.DEV
sta ZPPtr2

View File

@ -125,6 +125,9 @@ K.ExpandStr.YA stz K.ExpandStr.hPStr Reset Intermediate string...
.9 rts
*--------------------------------------
K.ExpandStrValidChar
cmp #'_'
beq .8
cmp #'0'
bcc .9
cmp #'9'+1
@ -133,13 +136,13 @@ K.ExpandStrValidChar
cmp #'A'
bcc .9
cmp #'Z'+1
bcc .8
cmp #'_'
bne .9
* bcc .8
rts
.8 clc
rts
.9 sec
rts
*--------------------------------------

View File

@ -32,7 +32,6 @@ PFT.CheckPathSTK
lda (pStack),y read PTR.HI on top of stack
ply
PFT.CheckPathYA
stx S.PFT.SYSCALL save #SYSCALL
>STYA ZPPtr1
>LDYAI FltMgr.Table
@ -62,16 +61,11 @@ PFT.CheckPathYA
jsr K.GetMemPtr.A
>STYA .7+1
lda S.PFT.SYSCALL getback #SYSCALL
sec
sbc #SYS.FOpen-4 0=Lib.load, 2=Lib.Unload
tax
pla discard JSR return @
pla
>LDYA ZPPtr1 restore passed params
.7 jmp $ffff
.7 jmp $ffff X unmodified
.8 lda ZPPtr2
@ -82,7 +76,6 @@ PFT.CheckPathYA
bcc .1
.9 >LDYA ZPPtr1 restore passed params
ldx S.PFT.SYSCALL
rts
*--------------------------------------
* PFT.Check___
@ -92,9 +85,9 @@ PFT.CheckPathYA
*--------------------------------------
PFT.CheckNodeSTK
lda (pStack) read hFILE on top of stack
PFT.CheckNodeA stx S.PFT.SYSCALL save #SYSCALL
sta S.PFT.hFILE
jsr K.GetMemPtr.A X = unmidified
PFT.CheckNodeA sta .9+1 save hFILE
jsr K.GetMemPtr.A X = unmodified
>STYA ZPPtr1
lda (ZPPtr1)
beq .9 Handler is 0, back to kernel....
@ -102,24 +95,16 @@ PFT.CheckNodeA stx S.PFT.SYSCALL save #SYSCALL
jsr K.GetMemPtr.A
>STYA .1+1
lda S.PFT.SYSCALL getback #SYSCALL
sec
sbc #SYS.FOpen-4 0=Lib.load, 2=Lib.Unload
tax
pla discard JSR return @
pla
lda S.PFT.hFILE restore passed params
lda .9+1 restore passed hFILE
.1 jmp $ffff
.9 lda S.PFT.hFILE
.9 lda #$ff Self Modified
rts
*--------------------------------------
S.PFT.hFILE .BS 1
S.PFT.SYSCALL .BS 1
*--------------------------------------
MAN
SAVE /A2OSX.SRC/SYS/KERNEL.S.PFT
LOAD /A2OSX.SRC/SYS/KERNEL.S

View File

@ -659,7 +659,7 @@ K.SScanF jsr PullPtr1Ptr2Ptr3
stz ASCBUF
.20 lda (ZPPtr1)
jsr K.SScanF.IsDigit
jsr STDIO.IsDigit
bcs .21
phx
inc ASCBUF
@ -669,7 +669,14 @@ K.SScanF jsr PullPtr1Ptr2Ptr3
jsr K.SScanF.IncPtr1
bne .20 end of string ?
.21 jsr DEC2HEX
.21
* jsr DEC2HEX AToF MIGRATION
bra *
lda HEXBUF
sta (ZPPtr3)
inc ZPPtr3
@ -700,15 +707,6 @@ K.SScanF.IncPtr1
bne .1
inc ZPPtr1+1 never Zero
.1 rts
*--------------------------------------
K.SScanF.IsDigit
cmp #'0'
bcc .1
cmp #'9'+1
bcs .1
rts
.1 sec
rts
*/--------------------------------------
* # PrintF.YA/SPrintF.YA/FPrintF.YA
* Prints C-Style String
@ -725,7 +723,6 @@ K.SScanF.IsDigit
* CC : success
* CS : error code from Output
* Specifiers :
* %a : pull 2 bytes to Print Access right String 'drwxrwxrwx'
* %b : pull 1 byte to Print BIN
* %B : pull 2 bytes to Print BIN
* %d : pull 1 byte unsigned DEC 0..255
@ -792,13 +789,12 @@ K.PrintF.YA >STYA ZPPtr1
ldx PADLEN PADLEN is not nul, so this 0 is second digit
bne .5
lda #'0'
* lda #'0'
sta PADCHAR no, this is the first 0, so make it PADCHAR
bra .2
.4 bcc .99 less than '0'....error
cmp #'9'+1
bcs .99 more than '9' ....error
.4 jsr STDIO.IsDigit
bcs .99
.5 and #$0F we have a digit
pha save it...
@ -845,13 +841,12 @@ K.PrintF.YA >STYA ZPPtr1
*--------------------------------------
PrintFESC jmp (PrintFJMP,x)
*--------------------------------------
PrintFTBL1 .AS "abBdDuefhHiILnNsS"
PrintFTBL1 .AS "bBdDuefhHiILnNsS"
PrintFTBL2 .AS "befnr\%"
PrintFTBL2.OUT .HS 08.1B.0C.0A.0D \b\e\f\n\r
.DA #'\' \\
.DA #'%' \%
PrintFJMP .DA PrintF.A
.DA PrintF.B,PrintF.BB
PrintFJMP .DA PrintF.B,PrintF.BB
.DA PrintF.D,PrintF.DD,PrintF.U
.DA PrintF.E,PrintF.F
.DA PrintF.H,PrintF.HH
@ -859,41 +854,6 @@ PrintFJMP .DA PrintF.A
.DA PrintF.N,PrintF.NN
.DA PrintF.S,PrintF.SS
*--------------------------------------
PrintF.A >PULLW HEXBUF
lda HEXBUF+1
lsr
lsr
lsr
lsr
tax
lda TYPES,x
jsr Printf.Cout
bcs .9
ldx #0
.1 lda #'-'
lsr HEXBUF
bcc .2
lda ACCESS,x
.2 jsr Printf.Cout
bcs .9
inx
cpx #8
bne .1
.3 lda #'-'
lsr HEXBUF+1
bcc .4
lda ACCESS,x
.4 jmp Printf.Cout
.9 rts
*--------------------------------------
PrintF.BB >PULLA
pha
jsr PrintF.B
@ -1152,8 +1112,13 @@ STDIO.IOERR lda #MLI.ERR.IO
sec
rts
*--------------------------------------
TYPES .AS "-dbclssp"
ACCESS .AS "rwxrwxrwx"
STDIO.IsDigit cmp #'0'
bcc .1
cmp #'9'+1
rts
.1 sec
rts
*--------------------------------------
SIGN .BS 1
PADLEN .BS 1
PADCHAR .BS 1

View File

@ -20,7 +20,15 @@ K.AToF
* ## Out:
* Y,A = Int
*\--------------------------------------
K.AToI.YA
K.AToI.YA >STYA ZPPtr1
lda #10 base 10
sec signed
jsr STDLIB.Dec2Hex
bcs .9
>LDYA HEXBUF
.9 rts
*/--------------------------------------
* # AToL
* Convert String to 32 bits int
@ -29,33 +37,13 @@ K.AToI.YA
* PUSHW Source String (C-Sring)
* ## Out:
*\--------------------------------------
K.AToL jsr PullPtr1Ptr2 PSTR in Ptr1,buffer in Ptr2
K.AToL jsr PullPtr1Ptr2 C-String in Ptr1, Dst buffer in Ptr2
stz ASCBUF
lda #10 base 10
sec signed
ldx #0
lda (ZPPtr1)
beq .2
ldy #$ff
.1 iny
lda (ZPPtr1),y
beq .2
cmp #'0'
bcc .2
cmp #'9'+1
bcs .2
sta ASCBUF,x
inx
cpx #10
bne .1
.2 stz ASCBUF,x
jsr DEC2HEX
jsr STDLIB.Dec2Hex
bcs .9
ldy #3
@ -64,22 +52,56 @@ K.AToL jsr PullPtr1Ptr2 PSTR in Ptr1,buffer in Ptr2
dey
bpl .3
clc
rts
.9 rts
*/--------------------------------------
* # StrToF
* Convert String to 40 bits Float
* ## In:
* PUSHW PTR to target buffer FLOAT (5 bytes)
* PUSHW PTR to EndPtr
* PUSHW Source String (C-Sring)
* ## Out:
*\--------------------------------------
K.StrToF
*/--------------------------------------
* # StrToL
* Convert String to 32 bits int
* ## In:
* PUSHB Base
* PUSHW PTR to target buffer DWORD
* PUSHW PTR to EndPtr
* PUSHW Source String (C-Sring)
* ## Out:
*\--------------------------------------
K.StrToL
*/--------------------------------------
* # StrToUL
* Convert String to 32 bits unsigned int
* ## In:
* PUSHB Base
* PUSHW PTR to target buffer DWORD
* PUSHW PTR to EndPtr
* PUSHW Source String (C-Sring)
* ## Out:
*\--------------------------------------
K.StrToUL
*--------------------------------------
* Convert ASCBUF decimal to HEXBUF
* Convert ZPPtr1 to HEXBUF
*--------------------------------------
DEC2HEX stz HEXBUF
STDLIB.Dec2Hex stz HEXBUF
stz HEXBUF+1
stz HEXBUF+2
stz HEXBUF+3
ldx #$ff
ldy #$ff
.1 inx
lda ASCBUF,x
.1 iny
lda (ZPPtr1),y
beq .8
jsr STDIO.IsDigit
bcs .8
lda HEXBUF+3 save HEXBUF for 4+1
pha
lda HEXBUF+2
@ -90,11 +112,12 @@ DEC2HEX stz HEXBUF
pha
jsr HEXBUF.ROL HEXBUF * 2 -> HEXBUF
* bcs .9 overflow!!!
bcs .9 overflow!!!
jsr HEXBUF.ROL HEXBUF * 4 -> HEXBUF
* bcs .9 overflow!!!
bcs .9 overflow!!!
* clc
pla HEXBUF * 4 + HEXBUF -> HEXBUF
adc HEXBUF
sta HEXBUF
@ -107,12 +130,12 @@ DEC2HEX stz HEXBUF
pla
adc HEXBUF+3
sta HEXBUF+3
* bcs .99 overflow!!!
bcs .99 overflow!!!
jsr HEXBUF.ROL HEXBUF * 10 -> HEXBUF
* bcs .99 overflow!!!
bcs .99 overflow!!!
lda ASCBUF,x
lda (ZPPtr1),y
and #$0F
adc HEXBUF
@ -123,15 +146,16 @@ DEC2HEX stz HEXBUF
inc HEXBUF+2
bne .1
inc HEXBUF+3
bra .1
bne .1 overflow!!!
.8 rts
.9 pla discard saved HEXBUF
pla
pla
pla
.99 rts
*.9 pla discard saved HEXBUF
* pla
* pla
* pla
*.99 rts
.8 clc
rts
*--------------------------------------
HEXBUF.ROL asl HEXBUF
rol HEXBUF+1