A2osX/BIN/ARP.S.txt
Rémy GIBERT bae3f91aab 0.9
2017-01-12 18:43:45 +01:00

229 lines
4.4 KiB
Plaintext
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

PR#3
PREFIX /A2OSX.SRC
NEW
INC 1
AUTO 6
.LIST OFF
.OP 65C02
.OR $2000
.TF /A2OSX.BOOT/BIN/ARP
*--------------------------------------
.INB /A2OSX.DEV/INC/MACROS.I
.INB /A2OSX.DEV/INC/A2OSX.I
.INB /A2OSX.DEV/INC/LIBTCPIP.I
*--------------------------------------
TIMEOUT.MAX .EQ 40 40*100ms = 4 sec.
*--------------------------------------
ZPPTR1 .EQ ZPBIN
*--------------------------------------
* File Header (16 Bytes)
*--------------------------------------
CS.START cld
jmp (.1,x)
.DA #$61 6502,Level 1 (65c02)
.DA #1 BIN Layout Version 1
.DA 0
.DA CS.END-CS.START
.DA DS.END-DS.START Data Segment to Allocate
.DA 0
.DA 0
*--------------------------------------
* Relocation Table
*--------------------------------------
.1 .DA CS.INIT
.DA CS.RUN
.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 LoadLibYA
sta hLIBTCPIP
>SYSCALL GetArgC
cmp #1
beq CS.INIT.DUMP
>PUSHW L.DST.IP
>PUSHW L.SSCANF.IP
lda #1
>SYSCALL GetArgA
>PUSHYA
>SYSCALL SSCANF
bcs .9
stz bCTRLC
lda (pPs)
ora #S.PS.F.EVENT Now accept events
sta (pPs)
rts CC,Give back control to CS.RUN
.9 lda #SYSMGR.ERRSYN
sec
rts
*--------------------------------------
CS.INIT.DUMP >LIBCALL hLIBTCPIP,LIBTCPIP.ARP.GETCACHE
>STYA ZPPTR1
>LDYA L.MSG0
>SYSCALL CPrintFYA
ldx #K.ARPCACHE.SIZE
.1 lda (ZPPTR1)
beq .4
ldy #S.ARPCACHE.IP+4
.2 dey
>PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.IP
bne .2
ldy #S.ARPCACHE.MAC+6
.3 dey
>PUSHB (ZPPTR1),y
cpy #S.ARPCACHE.MAC
bne .3
ldy #S.ARPCACHE.TTL+1
>PUSHB (ZPPTR1),y
dey
>PUSHB (ZPPTR1),y
>PUSHB (ZPPTR1)
>LDYA L.MSG1
phx
>SYSCALL CPrintFYA
plx
.4 lda ZPPTR1
clc
adc #S.ARPCACHE
sta ZPPTR1
bcc .5
inc ZPPTR1+1
.5 dex
bne .1
.8 lda #0 tell TSKMGR that all done ok, but
sec we do not want to stay in memory
rts
*--------------------------------------
CS.RUN jsr Init.Timeout
.1 lda bCTRLC
bne .9
>PUSHW L.DST.MAC
>PUSHW L.DST.IP
>LIBCALL hLIBTCPIP,LIBTCPIP.ARP.QUERY
bcc .2 success, print & exit
jsr Wait.TimeOut
bcs .9
>SYSCALL Sleep
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 CPrintFYA
lda #0
.9 sec
rts
*--------------------------------------
CS.DOEVENT lda (pEvent)
bpl .1 is it a TIMER event?
ldy #TimeOut
lda (pData),y
beq .9
dec
sta (pData),y
.9 sec do not discard TIMER event
rts
.1 lda (pEvent)
and #S.EVT.F.KEY is it a KEY event?
beq .9
ldy #S.EVT.hDEV is Event from active IN device?
lda (pEvent),y
ldy #S.PS.hStdIn
cmp (pPs),y
bne .9
ldy #S.EVT.DATAHI is it an O or SAPPLE key ?
lda (pEvent),y
bne .9
ldy #S.EVT.DATALO
lda (pEvent),y
cmp #$03 Ctrl-C
bne .9
lda #$FF
sta bCTRLC
clc
rts
*--------------------------------------
CS.QUIT lda hLIBTCPIP
>SYSCALL UnloadLibA
clc
rts
*--------------------------------------
Init.Timeout ldy #TimeOut
lda #TIMEOUT.MAX
sta (pData),y
rts
*--------------------------------------
Wait.TimeOut sec
ldy #TimeOut
lda (pData),y
beq .9
ldy #bCTRLC
lda (pData),y
bmi .9
clc
.9 rts
*--------------------------------------
CS.END
LIBTCPIP >PSTR "libtcpip.o"
SSCANF.IP >PSTR "%d.%d.%d.%d"
MSG0 >CSTR "STS TTL MAC Address IP Address\n"
MSG1 >CSTR "$%h %5D %h:%h:%h:%h:%h:%h %d.%d.%d.%d\n"
MSG2 >CSTR "%d.%d.%d.%d is at %h:%h:%h:%h:%h:%h\n"
*--------------------------------------
DS.START
hLIBTCPIP .BS 1
DST.IP .BS 4
DST.MAC .BS 6
TimeOut .BS 1
bCTRLC .BS 1
DS.END
*--------------------------------------
MAN
SAVE BIN/ARP.S
ASM