⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tcp.s

📁 AVR单片机系统开发经典实例部分源程序
💻 S
📖 第 1 页 / 共 5 页
字号:
	.module tcp.c
	.area lit(rom, con, rel)
_tcp_str1::
	.byte 32,32,32,32,'T,'C,'P,'H,'d,'r,58,32,'S,'r,'c,'P
	.byte 'r,'t,58,0
	.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\tcp.c
	.dbsym e tcp_str1 _tcp_str1 A[20:20]kc
_tcp_str2::
	.byte 32,'D,'e,'s,'t,'P,'r,'t,58,0
	.dbsym e tcp_str2 _tcp_str2 A[10:10]kc
_tcp_str3::
	.byte 32,'S,'e,'q,'N,'u,'m,58,0
	.dbsym e tcp_str3 _tcp_str3 A[9:9]kc
_tcp_str4::
	.byte 32,'A,'c,'k,'N,'u,'m,58,0
	.dbsym e tcp_str4 _tcp_str4 A[9:9]kc
_tcp_str5::
	.byte 32,'D,'a,'t,'a,'O,'f,'s,58,0
	.dbsym e tcp_str5 _tcp_str5 A[10:10]kc
_tcp_str6::
	.byte 32,'C,'B,'i,'t,'s,58,0
	.dbsym e tcp_str6 _tcp_str6 A[8:8]kc
_tcp_str7::
	.byte 45,'U,'R,'G,0
	.dbsym e tcp_str7 _tcp_str7 A[5:5]kc
_tcp_str8::
	.byte 45,'A,'C,'K,0
	.dbsym e tcp_str8 _tcp_str8 A[5:5]kc
_tcp_str9::
	.byte 45,'P,'S,'H,0
	.dbsym e tcp_str9 _tcp_str9 A[5:5]kc
_tcp_str10::
	.byte 45,'R,'S,'T,0
	.dbsym e tcp_str10 _tcp_str10 A[5:5]kc
_tcp_str11::
	.byte 45,'S,'Y,'N,0
	.dbsym e tcp_str11 _tcp_str11 A[5:5]kc
_tcp_str12::
	.byte 45,'F,'I,'N,0
	.dbsym e tcp_str12 _tcp_str12 A[5:5]kc
_tcp_str13::
	.byte 32,'W,'i,'n,'S,'i,'z,'e,58,0
	.dbsym e tcp_str13 _tcp_str13 A[10:10]kc
_tcp_str14::
	.byte 32,'C,'h,'k,'s,'u,'m,58,0
	.dbsym e tcp_str14 _tcp_str14 A[9:9]kc
_tcp_str15::
	.byte 32,'U,'r,'g,'P,'t,'r,58,0
	.dbsym e tcp_str15 _tcp_str15 A[9:9]kc
_tcp_str16::
	.byte 32,32,32,32,'o,'p,'t,'i,'o,'n,58,0
	.dbsym e tcp_str16 _tcp_str16 A[12:12]kc
_tcp_str17::
	.byte 32,32,32,32,'D,'a,'t,'a,'B,'y,'t,'e,'s,58,0
	.dbsym e tcp_str17 _tcp_str17 A[15:15]kc
_tcp_str18::
	.byte 32,'C,'o,'n,'n,32,'R,'E,'S,'E,'T,10,0
	.dbsym e tcp_str18 _tcp_str18 A[13:13]kc
_tcp_str19::
	.byte 32,'C,'o,'n,'n,32,'A,'C,'C,'E,'P,'T,'E,'D,10,0
	.dbsym e tcp_str19 _tcp_str19 A[16:16]kc
_tcp_str20::
	.byte 32,'C,'o,'n,'n,32,'E,'S,'T,'A,'B,'L,'I,'S,'H,'E
	.byte 'D,10,0
	.dbsym e tcp_str20 _tcp_str20 A[19:19]kc
_tcp_str21::
	.byte 32,45,32,'B,'L,'O,'C,'K,'E,'D,10,0
	.dbsym e tcp_str21 _tcp_str21 A[12:12]kc
_tcp_str22::
	.byte 'T,'C,'P,32,'S,'k,'t,32,'S,'t,'a,'t,'e,58,32,0
	.dbsym e tcp_str22 _tcp_str22 A[16:16]kc
_tcp_str23::
	.byte 'C,'L,'O,'S,'E,'D,10,0
	.dbsym e tcp_str23 _tcp_str23 A[8:8]kc
_tcp_str24::
	.byte 'L,'I,'S,'T,'E,'N,10,0
	.dbsym e tcp_str24 _tcp_str24 A[8:8]kc
_tcp_str25::
	.byte 'S,'Y,'N,95,'S,'E,'N,'T,10,0
	.dbsym e tcp_str25 _tcp_str25 A[10:10]kc
_tcp_str26::
	.byte 'S,'Y,'N,95,'R,'E,'C,'E,'I,'V,'E,'D,10,0
	.dbsym e tcp_str26 _tcp_str26 A[14:14]kc
_tcp_str27::
	.byte 'E,'S,'T,'A,'B,'L,'I,'S,'H,'E,'D,10,0
	.dbsym e tcp_str27 _tcp_str27 A[13:13]kc
_tcp_str28::
	.byte 'F,'I,'N,95,'W,'A,'I,'T,95,49,10,0
	.dbsym e tcp_str28 _tcp_str28 A[12:12]kc
_tcp_str29::
	.byte 'F,'I,'N,95,'W,'A,'I,'T,95,50,10,0
	.dbsym e tcp_str29 _tcp_str29 A[12:12]kc
_tcp_str30::
	.byte 'C,'L,'O,'S,'E,95,'W,'A,'I,'T,10,0
	.dbsym e tcp_str30 _tcp_str30 A[12:12]kc
_tcp_str31::
	.byte 'C,'L,'O,'S,'I,'N,'G,10,0
	.dbsym e tcp_str31 _tcp_str31 A[9:9]kc
_tcp_str32::
	.byte 'L,'A,'S,'T,95,'A,'C,'K,10,0
	.dbsym e tcp_str32 _tcp_str32 A[10:10]kc
_tcp_str33::
	.byte 'T,'I,'M,'E,95,'W,'A,'I,'T,10,0
	.dbsym e tcp_str33 _tcp_str33 A[11:11]kc
_tcp_str34::
	.byte 'U,'N,'K,'N,'O,'W,'N,10,0
	.dbsym e tcp_str34 _tcp_str34 A[9:9]kc
_tcp_Str35::
	.byte 42,42,42,32,'f,'a,'i,'l,'e,'d,32,'t,'o,32,'g,'e
	.byte 't,32,'m,'e,'m,32,'f,'o,'r,32,'s,'o,'c,'k,'e,'t
	.byte 10,0
	.dbsym e tcp_Str35 _tcp_Str35 A[34:34]kc
_tcp_str40::
	.byte 42,42,42,32,'T,'C,'P,32,'c,'h,'k,'s,'u,'m,32,'e
	.byte 'r,'r,10,0
	.dbsym e tcp_str40 _tcp_str40 A[20:20]kc
_TCP_Str50::
	.byte 32,32,32,32,32,32,'C,'o,'n,'n,'e,'c,'t,32,'T,'i
	.byte 'm,'e,58,32,0
	.dbsym e TCP_Str50 _TCP_Str50 A[21:21]kc
_TCP_Str51::
	.byte 32,32,32,32,32,32,'L,'a,'s,'t,32,'R,'x,32,'D,'a
	.byte 't,'a,58,32,0
	.dbsym e TCP_Str51 _TCP_Str51 A[21:21]kc
_TCP_Str52::
	.byte 'T,'h,'e,'i,'r,32,'M,'a,'x,32,'S,'e,'g,32,'S,'i
	.byte 'z,'e,58,32,0
	.dbsym e TCP_Str52 _TCP_Str52 A[21:21]kc
_TCP_Str53::
	.byte 32,32,32,32,32,'T,'h,'e,'i,'r,32,'S,'e,'q,32,'N
	.byte 'u,'m,58,32,0
	.dbsym e TCP_Str53 _TCP_Str53 A[21:21]kc
_TCP_Str54::
	.byte 32,32,32,32,32,32,32,'O,'u,'r,32,'S,'e,'q,32,'N
	.byte 'u,'m,58,32,0
	.dbsym e TCP_Str54 _TCP_Str54 A[21:21]kc
_TCP_Str55::
	.byte 32,32,32,32,'T,'h,'e,'i,'r,32,'W,'i,'n,32,'S,'i
	.byte 'z,'e,58,32,0
	.dbsym e TCP_Str55 _TCP_Str55 A[21:21]kc
_TCP_Str56::
	.byte 32,32,32,'L,'a,'s,'t,32,'B,'y,'t,'e,'s,32,'S,'e
	.byte 'n,'t,58,32,0
	.dbsym e TCP_Str56 _TCP_Str56 A[21:21]kc
_TCP_Str57::
	.byte 32,32,32,32,32,32,32,32,32,32,'T,'h,'e,'i,'r,32
	.byte 'I,'P,58,32,0
	.dbsym e TCP_Str57 _TCP_Str57 A[21:21]kc
_TCP_Str58::
	.byte 32,32,32,32,32,32,32,'R,'e,'m,'o,'t,'e,32,'P,'o
	.byte 'r,'t,58,32,0
	.dbsym e TCP_Str58 _TCP_Str58 A[21:21]kc
_TCP_Str59::
	.byte 32,32,32,32,32,32,32,32,'L,'o,'c,'a,'l,32,'P,'o
	.byte 'r,'t,58,32,0
	.dbsym e TCP_Str59 _TCP_Str59 A[21:21]kc
_TCP_Str60::
	.byte 32,32,32,'R,'o,'u,'n,'d,32,'T,'r,'i,'p,32,'T,'i
	.byte 'm,'e,58,32,0
	.dbsym e TCP_Str60 _TCP_Str60 A[21:21]kc
_TCP_Str61::
	.byte 32,32,32,32,32,32,32,32,32,32,32,'R,'e,'t,'r,'i
	.byte 'e,'s,58,32,0
	.dbsym e TCP_Str61 _TCP_Str61 A[21:21]kc
_TCP_Str62::
	.byte 32,32,32,32,32,32,32,'R,'e,'t,'r,'y,32,'T,'i,'m
	.byte 'e,'r,58,32,0
	.dbsym e TCP_Str62 _TCP_Str62 A[21:21]kc
_TCP_Str63::
	.byte 32,32,32,32,32,32,32,32,'T,'x,'B,'u,'f,'f,'e,'r
	.byte 'R,'d,58,32,0
	.dbsym e TCP_Str63 _TCP_Str63 A[21:21]kc
_TCP_Str64::
	.byte 32,32,32,32,32,32,32,32,'T,'x,'B,'u,'f,'f,'e,'r
	.byte 'W,'r,58,32,0
	.dbsym e TCP_Str64 _TCP_Str64 A[21:21]kc
_TCP_Str65::
	.byte 32,32,32,32,32,32,32,32,'R,'x,'B,'u,'f,'f,'e,'r
	.byte 'R,'d,58,32,0
	.dbsym e TCP_Str65 _TCP_Str65 A[21:21]kc
_TCP_Str66::
	.byte 32,32,32,32,32,32,32,32,'R,'x,'B,'u,'f,'f,'e,'r
	.byte 'W,'r,58,32,0
	.dbsym e TCP_Str66 _TCP_Str66 A[21:21]kc
	.area data(ram, con, rel)
	.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\tcp.c
_TCP_TmpPort::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\tcp.c
	.dbsym e TCP_TmpPort _TCP_TmpPort s
_TCP_Socket::
	.blkw 1
	.area idata
	.word _TCP_Static_Socket
	.area data(ram, con, rel)
	.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\tcp.c
	.dbunion 0 4 TIPAddr
	.dbfield 0 ip8 A[4:4]c
	.dbfield 0 ip32 l
	.dbend
	.dbstruct 0 1075 TTCPSocket
	.dbfield 0 Stage c
	.dbfield 1 ConnectTime l
	.dbfield 5 LastRxData l
	.dbfield 9 AckDelay s
	.dbfield 11 SendAck c
	.dbfield 12 OutGoing c
	.dbfield 13 Flags c
	.dbfield 14 TheirMaxSegSize s
	.dbfield 16 TheirSequenceNum l
	.dbfield 20 TheirWindowSize s
	.dbfield 22 OurSequenceNum l
	.dbfield 26 OurLastBytesSent S
	.dbfield 28 RemoteIP S[TIPAddr]
	.dbfield 32 RemotePort s
	.dbfield 34 LocalPort s
	.dbfield 36 RoundTripTime s
	.dbfield 38 Retries c
	.dbfield 39 Retry_Timer s
	.dbfield 41 TxBuffer A[512:512]c
	.dbfield 553 TxBufferRd S
	.dbfield 555 TxBufferWr S
	.dbfield 557 RxBuffer A[512:512]c
	.dbfield 1069 RxBufferRd S
	.dbfield 1071 RxBufferWr S
	.dbfield 1073 len s
	.dbend
	.dbsym e TCP_Socket _TCP_Socket pS[TTCPSocket]
_TCP_Header::
	.blkb 2
	.area idata
	.word 0
	.area data(ram, con, rel)
	.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\tcp.c
	.dbstruct 0 20 TTCPHeader
	.dbfield 0 SourcePort s
	.dbfield 2 DestPort s
	.dbfield 4 SequenceNum l
	.dbfield 8 AckNum l
	.dbfield 12 DataOffset c
	.dbfield 13 ControlBits c
	.dbfield 14 WindowSize s
	.dbfield 16 Checksum s
	.dbfield 18 UrgentPointer s
	.dbend
	.dbsym e TCP_Header _TCP_Header pS[TTCPHeader]
	.area text(rom, con, rel)
	.dbfile C:\AVR\AT-Modem__PPP__UDP__IC\tcp.c
	.dbfunc e TCP_DisplayHeader _TCP_DisplayHeader fV
;              w -> R14,R15
;             dw -> y+6
;              b -> R22
;              j -> R10,R11
;              i -> y+10
;            len -> R22
;           type -> R20
;     TotalBytes -> y+22
;      HeaderIdx -> R20,R21
	.even
_TCP_DisplayHeader::
	st -y,r19
	st -y,r18
	xcall push_gset5
	movw R20,R16
	sbiw R28,12
	.dbline -1
	.dbline 147
; 
; //      TCP A                                                 TCP B
; //  1.  CLOSED                                                LISTEN
; //
; //  2.  SYN-SENT    --> <SEQ=100><CTL=SYN>                --> SYN-RECEIVED
; //  3.  ESTABLISHED <-- <SEQ=300><ACK=101><CTL=SYN,ACK>   <-- SYN-RECEIVED
; //  4.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK>       --> ESTABLISHED
; //
; //  5.  ESTABLISHED --> <SEQ=101><ACK=301><CTL=ACK><DATA> --> ESTABLISHED
; //  6.    etc
; //
; //
; //
; //  7.  FIN-WAIT-1  --> <SEQ=100><ACK=300><CTL=FIN,ACK>   --> CLOSE-WAIT
; //  8.  FIN-WAIT-2  <-- <SEQ=300><ACK=101><CTL=ACK>       <-- CLOSE-WAIT
; //  9.  TIME-WAIT   <-- <SEQ=300><ACK=101><CTL=FIN,ACK>   <-- LAST-ACK
; // 10.  TIME-WAIT   --> <SEQ=101><ACK=301><CTL=ACK>       --> CLOSED
; // 11.  (2 MSL)
; //      CLOSED
; 
; /*
;  * Copyright (C) 2003-2004 by Clive Moss All rights reserved.
;  *
;  * Help & Contributions from D.J.Armstrong
; 
;  * Redistribution and use in source and binary forms, with or without
;  * modification, are permitted provided that the following conditions
;  * are met:
;  *
;  * 1. Redistributions of source code must retain the above copyright
;  *    notice, this list of conditions and the following disclaimer.
;  * 2. Redistributions in binary form must reproduce the above copyright
;  *    notice, this list of conditions and the following disclaimer in the
;  *    documentation and/or other materials provided with the distribution.
;  * 3. Neither the name of the copyright holders nor the names of
;  *    contributors may be used to endorse or promote products derived
;  *    from this software without specific prior written permission.
;  *
;  * THIS SOFTWARE IS PROVIDED BY CLIVE MOSS 'AS IS' AND ANY EXPRESS OR
;  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
;  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
;  * ARE DISCLAIMED.
;  * IN NO EVENT SHALL CLIVE MOSS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
;  * INDIRECT, INCIDENTAL,SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
;  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
;  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
;  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
;  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
;  * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
;  * SUCH DAMAGE.
;  */
; 
; //#ifdef CPU_eZ8
; //	#pragma stkck									// enable stack checking
; //#endif
; 
; #include <string.h>
; #include <stdlib.h>
; #include <stdio.h>
; 
; #include "common.h"
; #include "ppp.h"
; #include "ip.h"
; #include "tcp.h"
; 
; #ifdef Debug
; flash char	tcp_str1[]	=	"    TCPHdr: SrcPrt:";
; flash char	tcp_str2[]	=	" DestPrt:";
; flash char	tcp_str3[]	=	" SeqNum:";
; flash char	tcp_str4[]	=	" AckNum:";
; flash char	tcp_str5[]	=	" DataOfs:";
; flash char	tcp_str6[]	=	" CBits:";
; flash char	tcp_str7[]	=	"-URG";
; flash char	tcp_str8[]	=	"-ACK";
; flash char	tcp_str9[]	=	"-PSH";
; flash char	tcp_str10[]	=	"-RST";
; flash char	tcp_str11[]	=	"-SYN";
; flash char	tcp_str12[]	=	"-FIN";
; flash char	tcp_str13[]	=	" WinSize:";
; flash char	tcp_str14[]	=	" Chksum:";
; flash char	tcp_str15[]	=	" UrgPtr:";
; flash char	tcp_str16[]	=	"    option:";
; flash char	tcp_str17[]	=	"    DataBytes:";
; flash char	tcp_str18[]	=	" Conn RESET\n";
; flash char	tcp_str19[]	=	" Conn ACCEPTED\n";
; flash char	tcp_str20[]	=	" Conn ESTABLISHED\n";
; flash char	tcp_str21[]	=	" - BLOCKED\n";
; 
; flash char	tcp_str22[]	=	"TCP Skt State: ";
; flash char	tcp_str23[]	=	"CLOSED\n";
; flash char	tcp_str24[]	=	"LISTEN\n";
; flash char	tcp_str25[]	=	"SYN_SENT\n";
; flash char	tcp_str26[]	=	"SYN_RECEIVED\n";
; flash char	tcp_str27[]	=	"ESTABLISHED\n";
; flash char	tcp_str28[]	=	"FIN_WAIT_1\n";
; flash char	tcp_str29[]	=	"FIN_WAIT_2\n";
; flash char	tcp_str30[]	=	"CLOSE_WAIT\n";
; flash char	tcp_str31[]	=	"CLOSING\n";
; flash char	tcp_str32[]	=	"LAST_ACK\n";
; flash char	tcp_str33[]	=	"TIME_WAIT\n";
; flash char	tcp_str34[]	=	"UNKNOWN\n";
; 
; flash char	tcp_Str35[]	=	"*** failed to get mem for socket\n";
; 
; flash char	tcp_str40[]	=	"*** TCP chksum err\n";
; 
; flash char	TCP_Str50[]	=	"      Connect Time: ";
; flash char	TCP_Str51[]	=	"      Last Rx Data: ";
; flash char	TCP_Str52[]	=	"Their Max Seg Size: ";
; flash char	TCP_Str53[]	=	"     Their Seq Num: ";
; flash char	TCP_Str54[]	=	"       Our Seq Num: ";
; flash char	TCP_Str55[]	=	"    Their Win Size: ";
; flash char	TCP_Str56[]	=	"   Last Bytes Sent: ";
; flash char	TCP_Str57[]	=	"          Their IP: ";
; flash char	TCP_Str58[]	=	"       Remote Port: ";
; flash char	TCP_Str59[]	=	"        Local Port: ";
; flash char	TCP_Str60[]	=	"   Round Trip Time: ";
; flash char	TCP_Str61[]	=	"           Retries: ";
; flash char	TCP_Str62[]	=	"       Retry Timer: ";
; flash char	TCP_Str63[]	=	"        TxBufferRd: ";
; flash char	TCP_Str64[]	=	"        TxBufferWr: ";
; flash char	TCP_Str65[]	=	"        RxBufferRd: ";
; flash char	TCP_Str66[]	=	"        RxBufferWr: ";
; #endif
; 
; #ifdef CPU_eZ8
; near u16		TCP_TmpPort = 0;									// this is usedfor deciding what source port to use when making out going tcp connections
; #endif
; #ifdef CPU_ATmega128
; u16			TCP_TmpPort = 0;										//  "
; #endif
; 
; #ifdef StaticTCPSocket
; T_TCP_Socket	TCP_Static_Socket;									// static socket
; T_TCP_Socket	*TCP_Socket = (T_TCP_Socket*)&TCP_Static_Socket;	// set the pointer to point to it
; #else
; T_TCP_Socket	*TCP_Socket = NULL;									// it'll be dynamically allocated
; #endif
; 
; T_TCP_Header	*TCP_Header = NULL;									// points to the tcp header in a tx or rx packet
; 
; //*****************************************************************************************************
; 
; #ifdef Debug
; 
; void TCP_DisplayHeader(int HeaderIdx, int TotalBytes)
; {	// display the tcp header details
	.dbline 175
; 	u8	b, type, len;
; 	int	i, j;
; 	u16	w;
; 	u32	dw;
; 
; /*
; 	 0                   1                   2                   3
; 	 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; 	|          Source Port          |       Destination Port        |
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; 	|                        Sequence Number                        |
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; 	|                    Acknowledgment Number                      |
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; 	|  Data |           |U|A|P|R|S|F|                               |
; 	| Offset| Reserved  |R|C|S|S|Y|I|            Window             |
; 	|       |           |G|K|H|T|N|N|                               |
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; 	|           Checksum            |         Urgent Pointer        |
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; 	|                    Options                    |    Padding    | < optional
; 	+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
; */
; 
; 	// display the header
; 
; 	if (!SendDebugRStr(tcp_str1)) return;
	ldi R16,<_tcp_str1
	ldi R17,>_tcp_str1
	xcall _SendDebugRStr
	tst R16
	brne L2
	.dbline 175
	xjmp L1
L2:
	.dbline 176
; 	sprintf((char*)ScratchPad, "%u", ntohs(TCP_Header->SourcePort));
	lds R30,_TCP_Header
	lds R31,_TCP_Header+1
	ldd R16,z+0
	ldd R17,z+1
	xcall _ntohs
	std y+1,R17
	std y+0,R16
	ldi R18,<L4
	ldi R19,>L4
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _sprintf
	.dbline 177
; 	if (!SendDebugStr((char*)ScratchPad)) return;
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	tst R16
	brne L5
	.dbline 177
	xjmp L1
L5:
	.dbline 179
; 
; 	if (!SendDebugRStr(tcp_str2)) return;
	ldi R16,<_tcp_str2
	ldi R17,>_tcp_str2
	xcall _SendDebugRStr
	tst R16
	brne L7
	.dbline 179
	xjmp L1
L7:
	.dbline 180
; 	sprintf((char*)ScratchPad, "%u", ntohs(TCP_Header->DestPort));
	lds R30,_TCP_Header
	lds R31,_TCP_Header+1
	ldd R16,z+2
	ldd R17,z+3
	xcall _ntohs
	std y+1,R17
	std y+0,R16
	ldi R18,<L4
	ldi R19,>L4
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _sprintf
	.dbline 181
; 	if (!SendDebugStr((char*)ScratchPad)) return;
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	tst R16
	brne L9
	.dbline 181
	xjmp L1
L9:
	.dbline 183
; 
; 	if (!SendDebugRStr(tcp_str3)) return;
	ldi R16,<_tcp_str3
	ldi R17,>_tcp_str3
	xcall _SendDebugRStr
	tst R16
	brne L11
	.dbline 183
	xjmp L1
L11:
	.dbline 184
; 	dw = ntohl(TCP_Header->SequenceNum);
	lds R30,_TCP_Header
	lds R31,_TCP_Header+1
	ldd R16,z+4
	ldd R17,z+5
	ldd R18,z+6
	ldd R19,z+7
	xcall _ntohl
	movw R30,R28
	std z+6,R16
	std z+7,R17
	std z+8,R18
	std z+9,R19
	.dbline 185
; 	sprintf((char*)ScratchPad, "%lu", dw);
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	ldi R18,<L13
	ldi R19,>L13
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _sprintf
	.dbline 186
; 	if (!SendDebugStr((char*)ScratchPad)) return;
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _SendDebugStr
	tst R16
	brne L14
	.dbline 186
	xjmp L1
L14:
	.dbline 188
; 
; 	if (!SendDebugRStr(tcp_str4)) return;
	ldi R16,<_tcp_str4
	ldi R17,>_tcp_str4
	xcall _SendDebugRStr
	tst R16
	brne L16
	.dbline 188
	xjmp L1
L16:
	.dbline 189
; 	dw = ntohl(TCP_Header->AckNum);
	lds R30,_TCP_Header
	lds R31,_TCP_Header+1
	ldd R16,z+8
	ldd R17,z+9
	ldd R18,z+10
	ldd R19,z+11
	xcall _ntohl
	movw R30,R28
	std z+6,R16
	std z+7,R17
	std z+8,R18
	std z+9,R19
	.dbline 190
; 	sprintf((char*)ScratchPad, "%lu", dw);
	movw R30,R28
	ldd R2,z+6
	ldd R3,z+7
	ldd R4,z+8
	ldd R5,z+9
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	ldi R18,<L13
	ldi R19,>L13
	ldi R16,<_ScratchPad
	ldi R17,>_ScratchPad
	xcall _sprintf
	.dbline 191

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -