A2osX/BIN/ARP.S.txt

248 lines
5.1 KiB
Plaintext
Raw Normal View History

NEW
2019-09-19 15:22:14 +00:00
AUTO 3,1
.LIST OFF
.OP 65C02
.OR $2000
2018-07-23 15:28:42 +00:00
.TF BIN/ARP
*--------------------------------------
2018-07-23 15:28:42 +00:00
.INB INC/MACROS.I
.INB INC/A2OSX.I
.INB INC/ETH.I
.INB INC/LIBTCPIP.I
*--------------------------------------
2016-03-16 07:19:54 +00:00
TIMEOUT.MAX .EQ 40 40*100ms = 4 sec.
*--------------------------------------
2019-10-06 12:50:43 +00:00
.DUMMY
.OR ZPBIN
ZS.START
ZPPTR1 .BS 2
EntryCount .BS 1
ZS.END
.ED
*--------------------------------------
2015-06-03 18:30:57 +00:00
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
2015-06-03 18:30:57 +00:00
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
2018-11-06 19:26:45 +00:00
.DA #S.PS.F.EVENT
.DA #0
2019-10-06 12:50:43 +00:00
.DA CS.END-CS.START Code Size (without Constants)
.DA DS.END-DS.START Data Segment Size
.DA #32 Stack Size
.DA #ZS.END-ZS.START Zero Page Size
2015-06-03 18:30:57 +00:00
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
2015-06-03 18:30:57 +00:00
.DA CS.DOEVENT
.DA CS.QUIT
L.LIBTCPIP .DA LIBTCPIP
L.SSCANF.IP .DA SSCANF.IP
L.SSCANF.MAC .DA SSCANF.MAC
2018-11-09 13:29:23 +00:00
L.MSG.Usage .DA MSG.Usage
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
2018-07-19 15:33:55 +00:00
>SYSCALL LoadLib
bcs .9
sta hLIBTCPIP
.9 rts
2017-01-29 21:47:19 +00:00
*--------------------------------------
2019-01-16 21:51:57 +00:00
CS.RUN >LIBCALL hLIBTCPIP,LIBTCPIP.GETCFG
2018-11-09 13:29:23 +00:00
>STYA ZPPTR1
2019-02-03 21:58:26 +00:00
lda (ZPPTR1)
2018-11-09 13:29:23 +00:00
bmi .1
jmp CS.RUN.ERR
.1 ldy #S.PS.ARGC
lda (pPs),y
2018-11-23 16:20:19 +00:00
cmp #1
2018-11-09 13:29:23 +00:00
bcs .2
2017-01-29 21:47:19 +00:00
jmp CS.RUN.DUMP
2018-11-09 13:29:23 +00:00
.2 >PUSHEA.G DST.IP+3
>PUSHEA.G DST.IP+2
>PUSHEA.G DST.IP+1
>PUSHEA.G DST.IP
2018-11-09 13:29:23 +00:00
>PUSHBI 8 4 Ptrs
>PUSHW L.SSCANF.IP
lda #1
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
2018-07-19 15:33:55 +00:00
>SYSCALL sscanf
2018-11-09 13:29:23 +00:00
bcs CS.RUN.ERR
ldy #S.PS.ARGC
lda (pPs),y
2018-11-23 16:20:19 +00:00
cmp #1
beq CS.RUN.QUERY
2018-11-09 13:29:23 +00:00
cmp #3
bne CS.RUN.ERR
jmp CS.RUN.ADD
CS.RUN.ERR >PUSHBI 0
>LDYA L.MSG.Usage
>SYSCALL printf
lda #E.SYN
2017-01-29 21:47:19 +00:00
sec
rts
*--------------------------------------
CS.RUN.QUERY jsr Init.Timeout
2017-02-13 07:26:18 +00:00
.1 >PUSHEA.G DST.MAC
>PUSHEA.G DST.IP
2017-01-29 21:47:19 +00:00
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.QUERY
bcc .2 success, print & exit
jsr Wait.TimeOut
2018-11-09 13:29:23 +00:00
bcs .8
>SLEEP
>SYSCALL GetChar
2017-01-29 21:47:19 +00:00
bcs .1
cmp #3
2018-11-09 13:29:23 +00:00
beq .9
2017-01-29 21:47:19 +00:00
bra .1
2019-01-16 21:51:57 +00:00
.2 ldx #5
ldy #DST.MAC+5
.3 >PUSHB (pData),y
dey
2019-01-16 21:51:57 +00:00
dex
2017-01-29 21:47:19 +00:00
bpl .3
2019-01-16 21:51:57 +00:00
ldx #3
ldy #DST.IP+3
.4 >PUSHB (pData),y
dey
2019-01-16 21:51:57 +00:00
dex
2017-01-29 21:47:19 +00:00
bpl .4
2018-08-22 15:23:27 +00:00
>PUSHBI 10
2017-01-29 21:47:19 +00:00
>LDYA L.MSG2
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2017-01-29 21:47:19 +00:00
.8 lda #0
.9 sec
rts
*--------------------------------------
CS.RUN.ADD >PUSHEA.G DST.MAC+5
>PUSHEA.G DST.MAC+4
>PUSHEA.G DST.MAC+3
>PUSHEA.G DST.MAC+2
>PUSHEA.G DST.MAC+1
>PUSHEA.G DST.MAC
2018-11-09 13:29:23 +00:00
>PUSHBI 12 6 Ptrs
>PUSHW L.SSCANF.MAC
lda #2
2018-10-16 15:48:03 +00:00
>SYSCALL ArgV
2018-07-19 15:33:55 +00:00
>SYSCALL sscanf
bcs .9
>PUSHEA.G DST.MAC
>PUSHEA.G DST.IP
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.ADD
2018-11-09 13:29:23 +00:00
clc
.8 rts
.9 jmp CS.RUN.ERR
2016-03-16 07:19:54 +00:00
*--------------------------------------
CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
>STYA ZPPTR1
>LDYA L.MSG0
2018-07-24 16:00:24 +00:00
>SYSCALL puts
2019-10-06 12:50:43 +00:00
lda #K.ARPCACHE.SIZE
sta EntryCount
.1 lda (ZPPTR1)
beq .4
2019-10-06 12:50:43 +00:00
ldy #S.ARPCACHE.IP+4
2019-10-06 12:50:43 +00:00
.2 dey
2016-03-16 07:19:54 +00:00
>PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.IP
bne .2
2019-10-06 12:50:43 +00:00
ldy #S.ARPCACHE.MAC+6
2019-10-06 12:50:43 +00:00
.3 dey
2016-03-16 07:19:54 +00:00
>PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.MAC
bne .3
2019-10-06 12:50:43 +00:00
2016-03-16 07:19:54 +00:00
ldy #S.ARPCACHE.TTL+1
>PUSHB (ZPPTR1),y
dey
>PUSHB (ZPPTR1),y
>PUSHB (ZPPTR1)
2018-08-22 15:23:27 +00:00
>PUSHBI 13
>LDYA L.MSG1
2018-06-21 15:12:10 +00:00
>SYSCALL printf
2019-10-06 12:50:43 +00:00
2016-03-29 06:29:48 +00:00
.4 lda ZPPTR1
clc
adc #S.ARPCACHE
sta ZPPTR1
2016-03-29 06:29:48 +00:00
bcc .5
2019-10-06 12:50:43 +00:00
inc ZPPTR1+1
2019-10-06 12:50:43 +00:00
.5 dec EntryCount
2016-03-16 07:19:54 +00:00
bne .1
2019-10-06 12:50:43 +00:00
.8 lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
2015-06-03 18:30:57 +00:00
CS.DOEVENT lda (pEvent)
2017-01-29 21:47:19 +00:00
bpl .9 is it a TIMER event?
2016-03-16 07:19:54 +00:00
ldy #TimeOut
lda (pData),y
beq .9
2016-03-16 07:19:54 +00:00
dec
sta (pData),y
.9 sec do not discard TIMER event
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
2018-11-12 09:22:06 +00:00
beq .8
2019-10-06 12:50:43 +00:00
2018-07-20 14:10:10 +00:00
>SYSCALL UnloadLib
2018-11-12 09:22:06 +00:00
.8 clc
rts
*--------------------------------------
2016-03-16 07:19:54 +00:00
Init.Timeout ldy #TimeOut
lda #TIMEOUT.MAX
sta (pData),y
rts
*--------------------------------------
Wait.TimeOut sec
ldy #TimeOut
lda (pData),y
beq .9
clc
.9 rts
*--------------------------------------
CS.END
2019-11-11 14:21:06 +00:00
LIBTCPIP .AZ "LIBTCPIP"
SSCANF.IP .AZ "%d.%d.%d.%d"
SSCANF.MAC .AZ "%h:%h:%h:%h:%h:%h"
2018-11-09 13:29:23 +00:00
MSG.Usage .AS "Usage : ARP, display ARP cache\r\n"
.AS " ARP ip.ip.ip.ip query cache or network\r\n"
.AZ " ARP ip.ip.ip.ip HH:HH:HH:HH:HH:HH add a static ARP record in Cache\r\n"
2018-07-24 16:00:24 +00:00
MSG0 .AZ "STS TTL MAC Address IP Address"
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"
hLIBTCPIP .BS 1
*--------------------------------------
DS.START
DST.IP .BS 4
DST.MAC .BS 6
TimeOut .BS 1
DS.END
*--------------------------------------
MAN
2019-01-16 21:51:57 +00:00
SAVE USR/SRC/BIN/ARP.S
ASM