A2osX/BIN/ARP.S.txt

202 lines
4.0 KiB
Plaintext
Raw Normal View History

NEW
2017-12-22 21:24:30 +00:00
PREFIX /A2OSX.BUILD
AUTO 4,1
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BUILD/BIN/ARP
*--------------------------------------
.INB /A2OSX.BUILD/INC/MACROS.I
.INB /A2OSX.BUILD/INC/A2OSX.I
.INB /A2OSX.BUILD/INC/LIBTCPIP.I
*--------------------------------------
2016-03-16 07:19:54 +00:00
TIMEOUT.MAX .EQ 40 40*100ms = 4 sec.
*--------------------------------------
ZPPTR1 .EQ ZPBIN
*--------------------------------------
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
.DA 0
.DA CS.END-CS.START CS
.DA DS.END-DS.START DS
.DA #16 SS
.DA #2 ZP
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.DST.IP .DA DST.IP
L.DST.MAC .DA DST.MAC
L.MSG0 .DA MSG0
L.MSG1 .DA MSG1
L.MSG2 .DA MSG2
.DA 0
*--------------------------------------
CS.INIT >LDYA L.LIBTCPIP
>SYSCALL LoadLib.YA
bcs .9
sta hLIBTCPIP
2017-01-29 21:47:19 +00:00
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
clc
.9 rts
2017-01-29 21:47:19 +00:00
*--------------------------------------
CS.RUN ldy #S.PS.ARGC
lda (pPs),y
2017-01-29 21:47:19 +00:00
bne .1
jmp CS.RUN.DUMP
2017-01-29 21:47:19 +00:00
.1 >PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
lda #1
>SYSCALL GetArg.A
>PUSHYA
2017-01-29 21:47:19 +00:00
>SYSCALL SSCANF
2017-01-29 21:47:19 +00:00
bcc CS.RUN.QUERY
lda #K.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
2017-01-29 21:47:19 +00:00
.1 >PUSHW L.DST.MAC
>PUSHW L.DST.IP
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.QUERY
bcc .2 success, print & exit
2015-09-11 18:48:12 +00:00
2017-01-29 21:47:19 +00:00
jsr Wait.TimeOut
bcs .9
>SLEEP
>SYSCALL GetChar
2017-01-29 21:47:19 +00:00
bcs .1
cmp #3
beq .8
bra .1
.2 ldx #5
.3 >PUSHB DST.MAC,x
dex
bpl .3
ldx #3
.4 >PUSHB DST.IP,x
dex
bpl .4
>LDYA L.MSG2
>SYSCALL PrintF.YA
2017-01-29 21:47:19 +00:00
.8 lda #0
.9 sec
rts
2016-03-16 07:19:54 +00:00
*--------------------------------------
CS.RUN.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
>STYA ZPPTR1
2017-01-29 21:47:19 +00:00
>LDYA L.MSG0
>SYSCALL PrintF.YA
ldx #K.ARPCACHE.SIZE
.1 lda (ZPPTR1)
beq .4
ldy #S.ARPCACHE.IP+4
.2 dey
2016-03-16 07:19:54 +00:00
>PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.IP
bne .2
ldy #S.ARPCACHE.MAC+6
.3 dey
2016-03-16 07:19:54 +00:00
>PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.MAC
bne .3
2016-03-16 07:19:54 +00:00
ldy #S.ARPCACHE.TTL+1
>PUSHB (ZPPTR1),y
dey
>PUSHB (ZPPTR1),y
>PUSHB (ZPPTR1)
>LDYA L.MSG1
phx
>SYSCALL PrintF.YA
plx
2016-03-16 07:19:54 +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
inc ZPPTR1+1
2016-03-29 06:29:48 +00:00
.5 dex
2016-03-16 07:19:54 +00:00
bne .1
.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
>SYSCALL UnloadLib.A
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
LIBTCPIP >CSTR "libtcpip.o"
SSCANF.IP >CSTR "%d.%d.%d.%d"
MSG0 >CSTR "STS TTL MAC Address IP Address\r\n"
MSG1 >CSTR "$%h %5D %h:%h:%h:%h:%h:%h %d.%d.%d.%d\r\n"
MSG2 >CSTR "%d.%d.%d.%d is at %h:%h:%h:%h:%h:%h\r\n"
*--------------------------------------
DS.START
hLIBTCPIP .BS 1
DST.IP .BS 4
DST.MAC .BS 6
TimeOut .BS 1
DS.END
*--------------------------------------
MAN
SAVE /A2OSX.SRC/BIN/ARP.S
ASM