mirror of
https://github.com/A2osX/A2osX.git
synced 2024-10-09 14:55:05 +00:00
Kernel 0.9.1 : KERNEL, Extending and generalize the use of SScanF
This commit is contained in:
parent
b9ac24c39e
commit
8ec7b2e443
@ -637,6 +637,8 @@ Scan a C-String (in progress)
|
|||||||
+ %D : word
|
+ %D : word
|
||||||
* %L : long int
|
* %L : long int
|
||||||
* %U : dword
|
* %U : dword
|
||||||
|
+ %h : HEX byte
|
||||||
|
+ %H : HEX word
|
||||||
+ Y,A = PTR to String to scan (ex: "192.168.1.5")
|
+ Y,A = PTR to String to scan (ex: "192.168.1.5")
|
||||||
|
|
||||||
## Out:
|
## Out:
|
||||||
@ -662,14 +664,14 @@ Specifiers :
|
|||||||
+ %B : pull 2 bytes to Print BIN
|
+ %B : pull 2 bytes to Print BIN
|
||||||
+ %d : pull 1 byte unsigned DEC 0..255
|
+ %d : pull 1 byte unsigned DEC 0..255
|
||||||
+ %D : pull 2 bytes unsigned DEC 0..65535
|
+ %D : pull 2 bytes unsigned DEC 0..65535
|
||||||
+ %u : pull 2 bytes PTR to 4 bytes long unsigned DEC 0..4294967295
|
+ %u : pull 4 bytes long unsigned DEC 0..4294967295
|
||||||
+ %e : pull 2 bytes PTR to 5 Bytes float (-)1.23456789e+12
|
+ %e : pull 5 Bytes float (-)1.23456789e+12
|
||||||
+ %f : pull 2 bytes PTR to 5 Bytes float (-)3.1415
|
+ %f : pull 5 Bytes float (-)3.1415
|
||||||
+ %h : pull 1 byte to Print HEX
|
+ %h : pull 1 byte to Print HEX
|
||||||
+ %H : pull 2 bytes to Print HEX
|
+ %H : pull 2 bytes to Print HEX
|
||||||
+ %i : pull 1 byte to Print signed DEC -128..127
|
+ %i : pull 1 byte to Print signed DEC -128..127
|
||||||
+ %I : pull 2 bytes to Print signed DEC -32768..32767
|
+ %I : pull 2 bytes to Print signed DEC -32768..32767
|
||||||
+ %L : pull 2 bytes PTR to 4 bytes signed DEC -2147483648..2147483647
|
+ %L : pull 4 bytes signed DEC -2147483648..2147483647
|
||||||
+ %n : pull 1 byte to Print low Nibble HEX
|
+ %n : pull 1 byte to Print low Nibble HEX
|
||||||
+ %N : pull 1 byte to Print high Nibble HEX
|
+ %N : pull 1 byte to Print high Nibble HEX
|
||||||
+ %s : pull 2 bytes ptr to C-Style String
|
+ %s : pull 2 bytes ptr to C-Style String
|
||||||
|
Binary file not shown.
Binary file not shown.
@ -35,6 +35,7 @@ CS.START cld
|
|||||||
.DA CS.QUIT
|
.DA CS.QUIT
|
||||||
L.LIBTCPIP .DA LIBTCPIP
|
L.LIBTCPIP .DA LIBTCPIP
|
||||||
L.SSCANF.IP .DA SSCANF.IP
|
L.SSCANF.IP .DA SSCANF.IP
|
||||||
|
L.SSCANF.MAC .DA SSCANF.MAC
|
||||||
L.MSG0 .DA MSG0
|
L.MSG0 .DA MSG0
|
||||||
L.MSG1 .DA MSG1
|
L.MSG1 .DA MSG1
|
||||||
L.MSG2 .DA MSG2
|
L.MSG2 .DA MSG2
|
||||||
@ -65,9 +66,17 @@ CS.RUN ldy #S.PS.ARGC
|
|||||||
>SYSCALL GetArg.A
|
>SYSCALL GetArg.A
|
||||||
|
|
||||||
>SYSCALL SScanF.YA
|
>SYSCALL SScanF.YA
|
||||||
bcc CS.RUN.QUERY
|
bcs .9
|
||||||
|
|
||||||
lda #K.E.SYN
|
ldy #S.PS.ARGC
|
||||||
|
lda (pPs),y
|
||||||
|
cmp #1
|
||||||
|
beq CS.RUN.QUERY
|
||||||
|
|
||||||
|
cmp #2
|
||||||
|
beq CS.RUN.ADD
|
||||||
|
|
||||||
|
.9 lda #K.E.SYN
|
||||||
sec
|
sec
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
@ -107,6 +116,9 @@ CS.RUN.QUERY jsr Init.Timeout
|
|||||||
|
|
||||||
.9 sec
|
.9 sec
|
||||||
rts
|
rts
|
||||||
|
*--------------------------------------
|
||||||
|
CS.RUN.ADD
|
||||||
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
|
CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
|
||||||
>STYA ZPPTR1
|
>STYA ZPPTR1
|
||||||
@ -187,6 +199,7 @@ Wait.TimeOut sec
|
|||||||
CS.END
|
CS.END
|
||||||
LIBTCPIP .AZ "libtcpip.o"
|
LIBTCPIP .AZ "libtcpip.o"
|
||||||
SSCANF.IP .AZ "%d.%d.%d.%d"
|
SSCANF.IP .AZ "%d.%d.%d.%d"
|
||||||
|
SSCANF.MAC .AZ "%h:%h:%h:%h:%h:%h"
|
||||||
MSG0 .AZ "STS TTL MAC Address IP Address\r\n"
|
MSG0 .AZ "STS TTL MAC Address IP Address\r\n"
|
||||||
MSG1 .AZ "$%h %5D %h:%h:%h:%h:%h:%h %d.%d.%d.%d\r\n"
|
MSG1 .AZ "$%h %5D %h:%h:%h:%h:%h:%h %d.%d.%d.%d\r\n"
|
||||||
MSG2 .AZ "%d.%d.%d.%d is at %h:%h:%h:%h:%h:%h\r\n"
|
MSG2 .AZ "%d.%d.%d.%d is at %h:%h:%h:%h:%h:%h\r\n"
|
||||||
|
@ -661,6 +661,28 @@ MEM.IsDigit.RTS rts
|
|||||||
MEM.IsDigit.8 clc
|
MEM.IsDigit.8 clc
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
|
MEM.IsHexDigit jsr MEM.IsDigit
|
||||||
|
bcc .8
|
||||||
|
|
||||||
|
cmp #'A'
|
||||||
|
bcc MEM.IsDigit.9
|
||||||
|
cmp #'F'+1
|
||||||
|
bcc .1
|
||||||
|
|
||||||
|
cmp #'a'
|
||||||
|
bcc MEM.IsDigit.9
|
||||||
|
cmp #'f'+1
|
||||||
|
bcs MEM.IsDigit.RTS
|
||||||
|
|
||||||
|
eor #$20
|
||||||
|
.1
|
||||||
|
* clc
|
||||||
|
sbc #'A'-11 cc so A->10 (11-CC)
|
||||||
|
clc
|
||||||
|
|
||||||
|
.8 and #$0F
|
||||||
|
rts
|
||||||
|
*--------------------------------------
|
||||||
MEM.SetKeyCharY sta CLRWRITEAUX
|
MEM.SetKeyCharY sta CLRWRITEAUX
|
||||||
sta (ZPSListKeyPtr),y
|
sta (ZPSListKeyPtr),y
|
||||||
sta SETWRITEAUX
|
sta SETWRITEAUX
|
||||||
|
@ -618,12 +618,14 @@ K.Rename jsr PFT.CheckPathSTK
|
|||||||
>MLICALL MLIRENAME
|
>MLICALL MLIRENAME
|
||||||
rts
|
rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
K.PrintF.PadL .BS 1
|
*K.PrintF.PadL .BS 1
|
||||||
K.PrintF.PadC .BS 1
|
*K.PrintF.PadC .BS 1
|
||||||
*--------------------------------------
|
|
||||||
*HEXBUF .BS 4
|
*HEXBUF .BS 4
|
||||||
*BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
*BCDBUF .BS 5 5, enough to handle 10 digits (32bits)
|
||||||
|
*--------------------------------------
|
||||||
HEXBUF .EQ FAC
|
HEXBUF .EQ FAC
|
||||||
|
K.PrintF.PadL .EQ FAC+4
|
||||||
|
K.PrintF.PadC .EQ FAC+5
|
||||||
BCDBUF .EQ ARG
|
BCDBUF .EQ ARG
|
||||||
*/--------------------------------------
|
*/--------------------------------------
|
||||||
* # SScanF.YA
|
* # SScanF.YA
|
||||||
@ -638,6 +640,8 @@ BCDBUF .EQ ARG
|
|||||||
* %D : word
|
* %D : word
|
||||||
* %L : long int
|
* %L : long int
|
||||||
* %U : dword
|
* %U : dword
|
||||||
|
* %h : HEX byte
|
||||||
|
* %H : HEX word
|
||||||
* Y,A = PTR to String to scan (ex: "192.168.1.5")
|
* Y,A = PTR to String to scan (ex: "192.168.1.5")
|
||||||
* ## Out:
|
* ## Out:
|
||||||
*\--------------------------------------
|
*\--------------------------------------
|
||||||
@ -693,13 +697,15 @@ K.SScanF.YA >STYA ZPPtr2 String to Scan
|
|||||||
lda K.SScanFTBL+1,x Get VAR size
|
lda K.SScanFTBL+1,x Get VAR size
|
||||||
jmp (K.SScanFJMP,x)
|
jmp (K.SScanFJMP,x)
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
K.SScanFTBL .DA #'i,#1,#'d,#1,#'I,#2,#'D,#2,#'l,#4,#'u,#4
|
K.SScanFTBL .DA #'i,#1,#'d,#1,#'I,#2,#'D,#2,#'l,#4,#'u,#4,#'h,#1,#'H,#2
|
||||||
K.SScanFJMP .DA K.SScanF.I
|
K.SScanFJMP .DA K.SScanF.I
|
||||||
.DA K.SScanF.D
|
.DA K.SScanF.D
|
||||||
.DA K.SScanF.II
|
.DA K.SScanF.II
|
||||||
.DA K.SScanF.DD
|
.DA K.SScanF.DD
|
||||||
.DA K.SScanF.L
|
.DA K.SScanF.L
|
||||||
.DA K.SScanF.U
|
.DA K.SScanF.U
|
||||||
|
.DA K.SScanF.H
|
||||||
|
.DA K.SScanF.HH
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
K.SScanF.I
|
K.SScanF.I
|
||||||
K.SScanF.D
|
K.SScanF.D
|
||||||
@ -708,9 +714,15 @@ K.SScanF.DD
|
|||||||
K.SScanF.L
|
K.SScanF.L
|
||||||
K.SScanF.U pha Save VAL size
|
K.SScanF.U pha Save VAL size
|
||||||
|
|
||||||
jsr STDLIB.Dec2Hex
|
jsr STDLIB.GetDec
|
||||||
|
bra K.SScanF.GetVAL
|
||||||
|
*--------------------------------------
|
||||||
|
K.SScanF.HH
|
||||||
|
K.SScanF.H pha
|
||||||
|
|
||||||
tya Y=char count parsed
|
jsr STDLIB.GetHex
|
||||||
|
|
||||||
|
K.SScanF.GetVAL tya Y=char count parsed
|
||||||
clc
|
clc
|
||||||
adc ZPPtr2
|
adc ZPPtr2
|
||||||
sta ZPPtr2
|
sta ZPPtr2
|
||||||
@ -722,7 +734,7 @@ K.SScanF.U pha Save VAL size
|
|||||||
.2 lda STDLIB.32-1,y
|
.2 lda STDLIB.32-1,y
|
||||||
dey
|
dey
|
||||||
sta (ZPPtr3),y
|
sta (ZPPtr3),y
|
||||||
bpl .2
|
bne .2
|
||||||
|
|
||||||
.9 rts
|
.9 rts
|
||||||
*/--------------------------------------
|
*/--------------------------------------
|
||||||
@ -745,14 +757,14 @@ K.SScanF.U pha Save VAL size
|
|||||||
* %B : pull 2 bytes to Print BIN
|
* %B : pull 2 bytes to Print BIN
|
||||||
* %d : pull 1 byte unsigned DEC 0..255
|
* %d : pull 1 byte unsigned DEC 0..255
|
||||||
* %D : pull 2 bytes unsigned DEC 0..65535
|
* %D : pull 2 bytes unsigned DEC 0..65535
|
||||||
* %u : pull 2 bytes PTR to 4 bytes long unsigned DEC 0..4294967295
|
* %u : pull 4 bytes long unsigned DEC 0..4294967295
|
||||||
* %e : pull 2 bytes PTR to 5 Bytes float (-)1.23456789e+12
|
* %e : pull 5 Bytes float (-)1.23456789e+12
|
||||||
* %f : pull 2 bytes PTR to 5 Bytes float (-)3.1415
|
* %f : pull 5 Bytes float (-)3.1415
|
||||||
* %h : pull 1 byte to Print HEX
|
* %h : pull 1 byte to Print HEX
|
||||||
* %H : pull 2 bytes to Print HEX
|
* %H : pull 2 bytes to Print HEX
|
||||||
* %i : pull 1 byte to Print signed DEC -128..127
|
* %i : pull 1 byte to Print signed DEC -128..127
|
||||||
* %I : pull 2 bytes to Print signed DEC -32768..32767
|
* %I : pull 2 bytes to Print signed DEC -32768..32767
|
||||||
* %L : pull 2 bytes PTR to 4 bytes signed DEC -2147483648..2147483647
|
* %L : pull 4 bytes signed DEC -2147483648..2147483647
|
||||||
* %n : pull 1 byte to Print low Nibble HEX
|
* %n : pull 1 byte to Print low Nibble HEX
|
||||||
* %N : pull 1 byte to Print high Nibble HEX
|
* %N : pull 1 byte to Print high Nibble HEX
|
||||||
* %s : pull 2 bytes ptr to C-Style String
|
* %s : pull 2 bytes ptr to C-Style String
|
||||||
@ -921,14 +933,8 @@ PrintF.L sec signed long
|
|||||||
PrintF.U clc unsigned long (DWORD)
|
PrintF.U clc unsigned long (DWORD)
|
||||||
ldx #3 4 bytes
|
ldx #3 4 bytes
|
||||||
|
|
||||||
>PULLW ZPPtr2
|
>PULLW HEXBUF
|
||||||
|
>PULLW HEXBUF+2
|
||||||
ldy #3
|
|
||||||
|
|
||||||
.1 lda (ZPPtr2),y
|
|
||||||
sta HEXBUF,y
|
|
||||||
dey
|
|
||||||
bpl .1
|
|
||||||
|
|
||||||
PrintF.U.1 bcc PrintF.Hex2Dec unsigned, nothing to check
|
PrintF.U.1 bcc PrintF.Hex2Dec unsigned, nothing to check
|
||||||
|
|
||||||
@ -986,7 +992,7 @@ PrintF.Hex2Dec ror .31+1
|
|||||||
lda #'-'
|
lda #'-'
|
||||||
jsr STDIO.COut
|
jsr STDIO.COut
|
||||||
|
|
||||||
.9 lda K.PrintF.PadL any Len format ?
|
.9 lda K.PrintF.PadL any Len format ?
|
||||||
beq .4 no
|
beq .4 no
|
||||||
|
|
||||||
lda #10
|
lda #10
|
||||||
@ -1043,21 +1049,28 @@ PrintF.Hex2Dec ror .31+1
|
|||||||
PrintF.E sec Force "E+12"
|
PrintF.E sec Force "E+12"
|
||||||
.HS 90 BCC
|
.HS 90 BCC
|
||||||
PrintF.F clc
|
PrintF.F clc
|
||||||
>PULLW INDEX
|
lda pStack+1
|
||||||
|
sta INDEX+1
|
||||||
|
|
||||||
|
lda pStack
|
||||||
|
sta INDEX
|
||||||
|
|
||||||
|
clc
|
||||||
|
adc #5
|
||||||
|
sta pStack
|
||||||
>ROMCALL SETFAC
|
>ROMCALL SETFAC
|
||||||
|
|
||||||
ldy #3 In order not to trash A2osX.SaveSM,A2osX.SaveSX
|
ldy #3 In order not to trash A2osX.SaveSM,A2osX.SaveSX
|
||||||
>ROMCALL FOUT
|
>ROMCALL FOUT
|
||||||
|
|
||||||
ldx #0
|
ldy #0
|
||||||
|
|
||||||
.2 lda $102,x
|
.2 lda $102,y
|
||||||
beq .8
|
beq .8
|
||||||
|
|
||||||
phx
|
|
||||||
jsr STDIO.COut
|
jsr STDIO.COut
|
||||||
plx
|
|
||||||
inx
|
iny
|
||||||
bne .2
|
bne .2
|
||||||
|
|
||||||
.8 clc
|
.8 clc
|
||||||
|
@ -89,7 +89,7 @@ K.AToL jsr MEM.PullP1P2 C-String in Ptr2, Dst buffer in Ptr1
|
|||||||
lda #10 base 10
|
lda #10 base 10
|
||||||
sec signed
|
sec signed
|
||||||
|
|
||||||
K.AToL.I jsr STDLIB.Dec2Hex
|
K.AToL.I jsr STDLIB.GetDec
|
||||||
bcs .9
|
bcs .9
|
||||||
phy Save Count processed
|
phy Save Count processed
|
||||||
|
|
||||||
@ -116,15 +116,56 @@ K.AToI.YA >STYA ZPPtr2
|
|||||||
lda #10 base 10
|
lda #10 base 10
|
||||||
sec signed
|
sec signed
|
||||||
|
|
||||||
jsr STDLIB.Dec2Hex
|
jsr STDLIB.GetDec
|
||||||
bcs .9
|
bcs .9
|
||||||
|
|
||||||
>LDYA STDLIB.32
|
>LDYA STDLIB.32
|
||||||
.9 rts
|
.9 rts
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
* Convert ZPPtr2 to STDLIB.32
|
* Convert Hex int at ZPPtr2 to STDLIB.32
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
STDLIB.Dec2Hex jsr STDLIB.32.Clear
|
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
|
||||||
|
|
||||||
ldy #$ff
|
ldy #$ff
|
||||||
|
|
||||||
@ -165,11 +206,11 @@ STDLIB.32.T10 ldx #3
|
|||||||
dex
|
dex
|
||||||
bpl .1
|
bpl .1
|
||||||
|
|
||||||
jsr .7 STDLIB.32 * 2 -> STDLIB.32
|
jsr STDLIB.32.T2 STDLIB.32 * 2 -> STDLIB.32
|
||||||
bcs .9 overflow!!!
|
bcs STDLIB.32.9 overflow!!!
|
||||||
|
|
||||||
jsr .7 STDLIB.32 * 4 -> STDLIB.32
|
jsr STDLIB.32.T2 STDLIB.32 * 4 -> STDLIB.32
|
||||||
bcs .9 overflow!!!
|
bcs STDLIB.32.9 overflow!!!
|
||||||
|
|
||||||
phy Save Y, pointing to next char
|
phy Save Y, pointing to next char
|
||||||
|
|
||||||
@ -187,24 +228,22 @@ STDLIB.32.T10 ldx #3
|
|||||||
|
|
||||||
ply
|
ply
|
||||||
|
|
||||||
bcs .99 overflow!!!
|
bcs STDLIB.32.RTS overflow!!!
|
||||||
|
|
||||||
* STDLIB.32 * 10 -> STDLIB.32
|
* STDLIB.32 * 2 -> STDLIB.32
|
||||||
|
|
||||||
.7 asl STDLIB.32
|
STDLIB.32.T2 asl STDLIB.32
|
||||||
rol STDLIB.32+1
|
rol STDLIB.32+1
|
||||||
rol STDLIB.32+2
|
rol STDLIB.32+2
|
||||||
rol STDLIB.32+3
|
rol STDLIB.32+3
|
||||||
rts if CS, overflow!!!
|
rts if CS, overflow!!!
|
||||||
|
|
||||||
.9 pla discard saved STDLIB.32
|
STDLIB.32.9 pla discard saved STDLIB.32
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
pla
|
pla
|
||||||
|
|
||||||
.99 rts
|
STDLIB.32.RTS rts
|
||||||
*--------------------------------------
|
|
||||||
|
|
||||||
*--------------------------------------
|
*--------------------------------------
|
||||||
STDLIB.32.Clear ldx #3
|
STDLIB.32.Clear ldx #3
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user