A2osX/LIB/LIBTCPIP.S.IP.txt
2016-03-13 23:09:00 +01:00

99 lines
1.6 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
*--------------------------------------
IP.IN ldy #S.IP.PROTOCOL
lda (ZPFrameBase1),y
cmp #S.IP.PROTOCOL.ICMP
bne .2
jmp ICMP.IN
.2 cmp #S.IP.PROTOCOL.UDP
bne .3
jmp UDP.IN
.3 cmp #S.IP.PROTOCOL.TCP
bne .9
jmp TCP.IN
.9 sec
rts
*--------------------------------------
* In:
* PULLW = Start Offset
* PULLW = End Offset
* Out:
* Y,A = CheckSum
*--------------------------------------
IP.ComputeChecksum
>PULLA
clc
adc ZPFrameBase1
sta ZPTmpPtr1
>PULLA
adc ZPFrameBase1+1
sta ZPTmpPtr1+1
>PULLA
clc
adc ZPFrameBase1
sta TmpOffset
>PULLA
adc ZPFrameBase1+1
sta TmpOffset+1
stz IP.CHECKSUM
stz IP.CHECKSUM+1
stz IP.CHECKSUM+2
stz IP.CHECKSUM+3
ldy #2
.1 clc
iny
lda (ZPTmpPtr1),y
adc IP.CHECKSUM
sta IP.CHECKSUM
dey
lda (ZPTmpPtr1),y
adc IP.CHECKSUM+1
sta IP.CHECKSUM+1
bcc .3
inc IP.CHECKSUM+2
bne .3
inc IP.CHECKSUM+3
.3 lda ZPTmpPtr1
clc
adc #2
sta ZPTmpPtr1
bcc .4
inc ZPTmpPtr1+1
.4 cmp TmpOffset
bne .1
lda ZPTmpPtr1+1
cmp TmpOffset+1
bne .1
lda IP.CHECKSUM
clc
adc IP.CHECKSUM+2
eor #$FF
tay
lda IP.CHECKSUM+1
adc IP.CHECKSUM+3
eor #$FF
rts
*--------------------------------------
MAN
SAVE LIB/LIBTCPIP.S.IP
LOAD LIB/LIBTCPIP.S
ASM