Kernel 0.9.1 : KERNEL, SScanF rewritten to fix bugs in DNSINFO and ARP

This commit is contained in:
Rémy GIBERT 2018-05-23 17:27:37 +02:00
parent ea26b4cfdc
commit 17746d588c
14 changed files with 155 additions and 125 deletions

View File

@ -624,14 +624,20 @@ Rename a file
## Out : ## Out :
# SScanF # SScanF.YA
Scan a C-String (in progress) Scan a C-String (in progress)
## In: ## In:
+ PUSHW PTR to target buffer + PUSHW PTR to target var
+ PUSHW PSTR pattern (ex: "%d.%d.%d.%d") + ...
+ PUSHW PTR pattern (ex: "%d.%d.%d.%d")
+ %i : short int
+ %d : byte + %d : byte
+ PUSHW PSTR to scan (ex: "192.168.1.5") + %I : int
+ %D : word
* %L : long int
* %U : dword
+ Y,A = PTR to String to scan (ex: "192.168.1.5")
## Out: ## Out:

View File

@ -56,7 +56,7 @@
## In: ## In:
+ PUSHW = PTR to IP + PUSHW = PTR to IP
+ PUSHW = hostname PSTR to Add + PUSHW = hostname CSTR to Add
# DNS.GetCAche # DNS.GetCAche
+ Return a Ptr to DNS Cache Table + Return a Ptr to DNS Cache Table

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@ -35,8 +35,6 @@ 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.DST.IP .DA DST.IP
L.DST.MAC .DA DST.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
@ -58,13 +56,15 @@ CS.RUN ldy #S.PS.ARGC
bne .1 bne .1
jmp CS.RUN.DUMP jmp CS.RUN.DUMP
.1 >PUSHW L.DST.IP .1 >PUSHEA.G DST.IP+3
>PUSHEA.G DST.IP+2
>PUSHEA.G DST.IP+1
>PUSHEA.G DST.IP
>PUSHW L.SSCANF.IP >PUSHW L.SSCANF.IP
lda #1 lda #1
>SYSCALL GetArg.A >SYSCALL GetArg.A
>PUSHYA
>SYSCALL SSCANF >SYSCALL SScanF.YA
bcc CS.RUN.QUERY bcc CS.RUN.QUERY
lda #K.E.SYN lda #K.E.SYN
@ -73,8 +73,8 @@ CS.RUN ldy #S.PS.ARGC
*-------------------------------------- *--------------------------------------
CS.RUN.QUERY jsr Init.Timeout CS.RUN.QUERY jsr Init.Timeout
.1 >PUSHW L.DST.MAC .1 >PUSHEA.G DST.MAC
>PUSHW L.DST.IP >PUSHEA.G DST.IP
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.QUERY >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.QUERY
bcc .2 success, print & exit bcc .2 success, print & exit
@ -88,14 +88,16 @@ CS.RUN.QUERY jsr Init.Timeout
beq .8 beq .8
bra .1 bra .1
.2 ldx #5 .2 ldy #5
.3 >PUSHB DST.MAC,x
dex .3 >PUSHB.G DST.MAC,y
dey
bpl .3 bpl .3
ldx #3 ldy #3
.4 >PUSHB DST.IP,x
dex .4 >PUSHB.G DST.IP,y
dey
bpl .4 bpl .4
>LDYA L.MSG2 >LDYA L.MSG2
@ -188,9 +190,9 @@ SSCANF.IP .AZ "%d.%d.%d.%d"
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"
hLIBTCPIP .BS 1
*-------------------------------------- *--------------------------------------
DS.START DS.START
hLIBTCPIP .BS 1
DST.IP .BS 4 DST.IP .BS 4
DST.MAC .BS 6 DST.MAC .BS 6
TimeOut .BS 1 TimeOut .BS 1

View File

@ -34,7 +34,6 @@ 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.IP .DA IP
L.MSG0 .DA MSG0 L.MSG0 .DA MSG0
L.MSG1 .DA MSG1 L.MSG1 .DA MSG1
.DA 0 .DA 0
@ -51,20 +50,25 @@ CS.INIT >LDYA L.LIBTCPIP
*-------------------------------------- *--------------------------------------
CS.RUN ldy #S.PS.ARGC CS.RUN ldy #S.PS.ARGC
lda (pPs),y lda (pPs),y
beq CS.RUN.DUMP bne CS.RUN.ADD
jmp CS.RUN.DUMP
CS.RUN.ADD cmp #3 CS.RUN.ADD cmp #2
bne .9 beq .1
jmp .9
>PUSHW L.IP .1 >PUSHEA.G DST.IP+3
>PUSHEA.G DST.IP+2
>PUSHEA.G DST.IP+1
>PUSHEA.G DST.IP
>PUSHW L.SSCANF.IP >PUSHW L.SSCANF.IP
lda #3 lda #1
>SYSCALL GetArg.A >SYSCALL GetArg.A
>PUSHYA
>SYSCALL SSCANF >SYSCALL SScanF.YA
bcs .9 bcs .9
>PUSHW L.IP >PUSHEA.G DST.IP
lda #2 lda #2
>SYSCALL GetArg.A >SYSCALL GetArg.A
>PUSHYA >PUSHYA
@ -85,7 +89,7 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GetCache
>SYSCALL PrintF.YA >SYSCALL PrintF.YA
lda #K.DNSCACHE.SIZE lda #K.DNSCACHE.SIZE
sta EntryCount >STA.G EntryCount
.1 lda (ZPPTR1) .1 lda (ZPPTR1)
beq .2 beq .2
@ -126,7 +130,7 @@ CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.DNS.GetCache
bcc .3 bcc .3
inc ZPPTR1+1 inc ZPPTR1+1
.3 dec EntryCount .3 >DEC.G EntryCount
bne .1 bne .1
.8 lda #0 tell TSKMGR that all done ok, but .8 lda #0 tell TSKMGR that all done ok, but
@ -147,9 +151,12 @@ SSCANF.IP .AZ "%d.%d.%d.%d"
MSG0 .AZ "STS TR.ID Hostname IP Address TTL\r\n" MSG0 .AZ "STS TR.ID Hostname IP Address TTL\r\n"
MSG1 .AZ "$%h $%H %32s %03d.%03d.%03d.%03d %u\r\n" MSG1 .AZ "$%h $%H %32s %03d.%03d.%03d.%03d %u\r\n"
hLIBTCPIP .BS 1 hLIBTCPIP .BS 1
*--------------------------------------
IP .BS 4 DS.START
DST.IP .BS 4
EntryCount .BS 1 EntryCount .BS 1
DS.END
*--------------------------------------
MAN MAN
SAVE /A2OSX.SRC/BIN/DNSINFO.S SAVE /A2OSX.SRC/BIN/DNSINFO.S
ASM ASM

View File

@ -120,7 +120,7 @@ SYS.GetDevStatus.A .EQ $4C
SYS.IOCTL .EQ $4E SYS.IOCTL .EQ $4E
* .EQ $50 * .EQ $50
SYS.SScanF .EQ $52 SYS.SScanF.YA .EQ $52
* .EQ $54 * .EQ $54
* .EQ $56 * .EQ $56
SYS.PrintF.YA .EQ $58 SYS.PrintF.YA .EQ $58

View File

@ -127,7 +127,7 @@ DNS.REQUEST lda hDNSSocket1
* Add a static DNS record * Add a static DNS record
* ## In: * ## In:
* PUSHW = PTR to IP * PUSHW = PTR to IP
* PUSHW = hostname PSTR to Add * PUSHW = hostname CSTR to Add
*\-------------------------------------- *\--------------------------------------
DNS.Add >PULLW ZPPtrDNS Get host string DNS.Add >PULLW ZPPtrDNS Get host string
>PULLW ZPPtrIP Get host IP address >PULLW ZPPtrIP Get host IP address

View File

@ -125,10 +125,14 @@ Kernel Configuration Utility...
![](./.screen-shots/ScreenShot.KCONFIG.png) ![](./.screen-shots/ScreenShot.KCONFIG.png)
Color ANSI/VT100 Support !!! Color ANSI/VT100 Support...
![](./.screen-shots/PuTTY.png) ![](./.screen-shots/PuTTY.png)
DHGR Mixed-Mode Graphic primitives....
![](./.screen-shots/ScreenShot.GFX.png)
## General Information: ## General Information:
Kernel API is confined in Aux LC Bank 1 & 2 to leave enough room at $EOOO for Drivers. Kernel API is confined in Aux LC Bank 1 & 2 to leave enough room at $EOOO for Drivers.

View File

@ -52,7 +52,7 @@ K.SYSCALL.JMP .DA 0 $00
.DA K.IOCTL .DA K.IOCTL
.DA 0 $50 .DA 0 $50
.DA K.SScanF .DA K.SScanF.YA
.DA 0 .DA 0
.DA 0 .DA 0
.DA K.PrintF.YA .DA K.PrintF.YA

View File

@ -626,101 +626,109 @@ K.PrintF.PadC .BS 1
HEXBUF .EQ FAC HEXBUF .EQ FAC
BCDBUF .EQ ARG BCDBUF .EQ ARG
*/-------------------------------------- */--------------------------------------
* # SScanF * # SScanF.YA
* Scan a C-String (in progress) * Scan a C-String (in progress)
* ## In: * ## In:
* PUSHW PTR to target buffer * PUSHW PTR to target var
* ...
* PUSHW PTR pattern (ex: "%d.%d.%d.%d") * PUSHW PTR pattern (ex: "%d.%d.%d.%d")
* %i : short int
* %d : byte * %d : byte
* PUSHW PTR to String to scan (ex: "192.168.1.5") * %I : int
* %D : word
* %L : long int
* %U : dword
* Y,A = PTR to String to scan (ex: "192.168.1.5")
* ## Out: * ## Out:
*\-------------------------------------- *\--------------------------------------
K.SScanF jsr MEM.PullP1P2P3 K.SScanF.YA >STYA ZPPtr2 String to Scan
>PULLW ZPPtr1 Pattern
ldy #0 Y = PTR in pattern .1 lda (ZPPtr1) End Of Pattern?
beq .8
lda (ZPPtr1)
beq .9
tax X = COUNT to scan
inc ZPPtr1 inc ZPPtr1
bne .1 bne .11
inc ZPPtr1+1 inc ZPPtr1+1
.1 txa End Of String? .11 cmp #'%' Escape?
beq .8
tya
cmp (ZPPtr2) End of pattern?
beq .8
iny
lda (ZPPtr2),y
cmp #'%' Escape?
beq .2 beq .2
cmp (ZPPtr1) Same char?
cmp (ZPPtr2) Same char in string?
bne .9 bne .9
jsr K.SScanF.IncPtr1
inc ZPPtr2
bne .1 bne .1
clc inc ZPPtr2+1
bra .1
.2 lda (ZPPtr1) Get specifier after %
beq .9 unexpected End of pattern after "%" ?
inc ZPPtr1
bne .21
inc ZPPtr1+1
.21 ldx #K.SScanFJMP-K.SScanFTBL-2
.3 cmp K.SScanFTBL,x
beq .4
dex
dex
bpl .3
.9 lda #MLI.E.EOF
sec
rts rts
.2 tya .4 jsr .5
cmp (ZPPtr2) unexpected End of pattern after "%" ?
beq .9
iny
lda (ZPPtr2),y
cmp #'d' BYTE ?
bne .3
* stz ASCBUF tya
.20 lda (ZPPtr1) clc
jsr MEM.IsDigit adc ZPPtr2
bcs .21 sta ZPPtr2
phx bcc .1
* inc ASCBUF inc ZPPtr2+1
* ldx ASCBUF
* sta ASCBUF,x
plx
jsr K.SScanF.IncPtr1
bne .20 end of string ?
.21
* jsr DEC2HEX AToF MIGRATION
bra *
lda HEXBUF
sta (ZPPtr3)
inc ZPPtr3
bne .1
inc ZPPtr3+1
bra .1
.3 cmp #'D' WORD ?
bne .4
bra .1
.4 cmp #'s' STRING ?
bne .9
bra .1 bra .1
.8 clc .8 clc
rts rts
.9 sec
rts
*-------------------------------------- *--------------------------------------
K.SScanF.IncPtr1 .5 >PULLW ZPPtr3 get VAR Ptr
dex
beq .1 lda K.SScanFTBL+1,x Get VAR Byte count
inc ZPPtr1 jmp (K.SScanFJMP,x)
bne .1 *--------------------------------------
inc ZPPtr1+1 never Zero K.SScanFTBL .DA #'i,#1,#'d,#1,#'I,#2,#'D,#2,#'l,#4,#'u,#4
.1 rts K.SScanFJMP .DA K.SScanF.I
.DA K.SScanF.D
.DA K.SScanF.II
.DA K.SScanF.DD
.DA K.SScanF.L
.DA K.SScanF.U
*--------------------------------------
K.SScanF.I
K.SScanF.D
K.SScanF.II
K.SScanF.DD
K.SScanF.L
K.SScanF.U pha Save Byte count
jsr STDLIB.Dec2Hex
pla
phy
tay
.1 lda STDLIB.32-1,y
dey
sta (ZPPtr3),y
bpl .1
ply
.9 rts
*/-------------------------------------- */--------------------------------------
* # PrintF.YA/SPrintF.YA/FPrintF.YA * # PrintF.YA/SPrintF.YA/FPrintF.YA
* Prints C-Style String * Prints C-Style String

View File

@ -81,6 +81,9 @@ K.StrToUL.rts rts
* PUSHW PTR to target buffer DWORD * PUSHW PTR to target buffer DWORD
* ## Out: * ## Out:
*\-------------------------------------- *\--------------------------------------
*STDLIB.32 .BS 4 32 bits max
STDLIB.32 .EQ FAC 32 bits max
*--------------------------------------
K.AToL jsr MEM.PullP1P2 C-String in Ptr2, Dst buffer in Ptr1 K.AToL jsr MEM.PullP1P2 C-String in Ptr2, Dst buffer in Ptr1
lda #10 base 10 lda #10 base 10
@ -119,7 +122,7 @@ K.AToI.YA >STYA ZPPtr2
>LDYA STDLIB.32 >LDYA STDLIB.32
.9 rts .9 rts
*-------------------------------------- *--------------------------------------
* Convert ZPPtr1 to STDLIB.32 * Convert ZPPtr2 to STDLIB.32
*-------------------------------------- *--------------------------------------
STDLIB.Dec2Hex jsr STDLIB.32.Clear STDLIB.Dec2Hex jsr STDLIB.32.Clear
@ -132,16 +135,13 @@ STDLIB.Dec2Hex jsr STDLIB.32.Clear
jsr MEM.IsDigit jsr MEM.IsDigit
bcs .8 bcs .8
phy Save Y, pointing to next char
jsr STDLIB.32.T10 jsr STDLIB.32.T10
ply
bcs .9 bcs .9
lda (ZPPtr2),y lda (ZPPtr2),y
and #$0F and #$0F
* clc
adc STDLIB.32 adc STDLIB.32
sta STDLIB.32 sta STDLIB.32
@ -165,12 +165,14 @@ STDLIB.32.T10 ldx #3
dex dex
bpl .1 bpl .1
jsr STDLIB.32.ROL STDLIB.32 * 2 -> STDLIB.32 jsr .7 STDLIB.32 * 2 -> STDLIB.32
bcs .9 overflow!!! bcs .9 overflow!!!
jsr STDLIB.32.ROL STDLIB.32 * 4 -> STDLIB.32 jsr .7 STDLIB.32 * 4 -> STDLIB.32
bcs .9 overflow!!! bcs .9 overflow!!!
phy Save Y, pointing to next char
ldx #0 ldx #0
ldy #4 ldy #4
@ -183,9 +185,16 @@ STDLIB.32.T10 ldx #3
dey dey
bne .2 bne .2
ply
bcs .99 overflow!!! bcs .99 overflow!!!
jsr STDLIB.32.ROL STDLIB.32 * 10 -> STDLIB.32 * STDLIB.32 * 10 -> STDLIB.32
.7 asl STDLIB.32
rol STDLIB.32+1
rol STDLIB.32+2
rol STDLIB.32+3
rts if CS, overflow!!! rts if CS, overflow!!!
.9 pla discard saved STDLIB.32 .9 pla discard saved STDLIB.32
@ -195,11 +204,7 @@ STDLIB.32.T10 ldx #3
.99 rts .99 rts
*-------------------------------------- *--------------------------------------
STDLIB.32.ROL asl STDLIB.32
rol STDLIB.32+1
rol STDLIB.32+2
rol STDLIB.32+3
rts
*-------------------------------------- *--------------------------------------
STDLIB.32.Clear ldx #3 STDLIB.32.Clear ldx #3
@ -207,8 +212,6 @@ STDLIB.32.Clear ldx #3
dex dex
bpl .1 bpl .1
rts rts
*--------------------------------------
STDLIB.32 .BS 4 32 bits max
*/-------------------------------------- */--------------------------------------
* # RealPath.YA * # RealPath.YA
* Return the canonicalized absolute pathname * Return the canonicalized absolute pathname