; TASKING TriCore C compiler v1.5r1 Build 322 SN 00090364
; options: -e -A1 -g -O1 -Id:\ctri\include -s -N8 -zTC112_COR1 -zTC112_COR4
;          -zTC112_COR10 -zTC112_COR13 -zTC112_COR14 -zTC112_COR16 -zTC112_COR17
	.name	"tcpip"
	.symb	TOOL, "TASKING TriCore C compiler v1.5", 1
	.symb	TYPE, 256, "bit", 'g', 0, 1
	.symb	FILE, "tcpip.c"
; file "tcpip.c":
;    1 |/******************************************************************
;    2 | *****                                                        *****
;    3 | *****  Name: tcpip.c                                         *****
;    4 | *****  Ver.: 1.0                                             *****
;    5 | *****  Date: 07/05/2001                                      *****
;    6 | *****  Auth: Andreas Dannenberg                              *****
;    7 | *****        HTWK Leipzig                                    *****
;    8 | *****        university of applied sciences                  *****
;    9 | *****        Germany                                         *****
;   10 | *****  Func: implements the TCP/IP-stack and provides a      *****
;   11 | *****        simple API to the user                          *****
;   12 | *****                                                        *****
;   13 | ******************************************************************/
;   14 |
;   15 |#include "tcpip.h"
	.symb	FILE, "tcpip.h"
	.symb	TYPE, 257, 'N', 0, 1,\
		 "CLOSED", 0,\
		 "LISTENING", 1,\
		 "SYN_SENT", 2,\
		 "SYN_RECD", 3,\
		 "ESTABLISHED", 4,\
		 "FIN_WAIT_1", 5,\
		 "FIN_WAIT_2", 6,\
		 "CLOSE_WAIT", 7,\
		 "CLOSING", 8,\
		 "LAST_ACK", 9,\
		 "TIME_WAIT", 10
	.symb	TYPE, 258, "TTCPStateMachine", 'T', #257
	.symb	TYPE, 259, 'N', 0, 1,\
		 "ARP_REQUEST", 0,\
		 "TCP_SYN_FRAME", 1,\
		 "TCP_SYN_ACK_FRAME", 2,\
		 "TCP_FIN_FRAME", 3,\
		 "TCP_DATA_FRAME", 4
	.symb	TYPE, 260, "TLastFrameSent", 'T', #259
	.symb	ENDF
;   16 |#include "cs8900.h"    // Keil: Line added
	.symb	FILE, "cs8900.h"
	.symb	TYPE, 261, 'S', 4,\
		 "Addr", #5, 0,\
		 "Data", #5, 2
	.symb	TYPE, 262, "TInitSeq", 'T', #261
	.symb	ENDF
;   17 |#include "string.h"    // Keil: Line added
	.symb	FILE, "d:\\ctri\\include\\string.h"
	.symb	TYPE, 263, "size_t", 'T', #18
	.symb	ENDF
;   18 |// PHYTEC: #include <reg167.h>    // Keil: Line added for Timer 3
;   19 |
;   20 |// easyWEB-API function
;   21 |// initalizes the LAN-controller, reset flags, starts timer-ISR
;   22 |
;   23 |void TCPLowLevelInit(void)
;   24 |{
	.sdecl	"code.tcpip",CODE
	.sect	"code.tcpip"
	.align	4
	.symb	LINE, 24
	.symb	TYPE, 264, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPLowLevelInit", TCPLowLevelInit, #264, 0, 0, 0
	.symb	ALAB, TCPLowLevelInit, #264
TCPLowLevelInit:
	.symb	SOFF, 0
;   25 |// Keil: Timer 3 is used for TCP retransmission control
;   26 |// PHYTEC:  T3CON = 0x43;                                  // Enable T3 with prescaler = 64
;   27 |// PHYTEC:  T3IC  = 0x52;
;   28 |// PHYTEC:  IEN   = 1;
;   29 |  
;   30 |  Init8900();
	.symb	LINE, 30
	callg	Init8900
;   31 |  TransmitControl = 0;
	.symb	LINE, 31
	mov16	d15,#0				; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;   32 |  TCPFlags = 0;
	.symb	LINE, 32
	st.b	TCPFlags,d15			; TCPFlags
;   33 |  TCPStateMachine = CLOSED;
	.symb	LINE, 33
	st.b	TCPStateMachine,d15		; TCPStateMachine
;   34 |  SocketStatus = 0;
	.symb	LINE, 34
	st.b	SocketStatus,d15		; SocketStatus
;   35 |}
	.symb	LINE, 35
	ret16
	.symb	EFUN
;   36 |
;   37 |// easyWEB-API function
;   38 |// does a passive open (listen on 'MyIP:TCPLocalPort' for an incoming
;   39 |// connection)
;   40 |
;   41 |void TCPPassiveOpen(void)
;   42 |{
	.symb	LINE, 42
	.symb	TYPE, 265, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPPassiveOpen", TCPPassiveOpen, #265, 0, 0, 0
	.symb	ALAB, TCPPassiveOpen, #265
TCPPassiveOpen:
	.symb	SOFF, 0
;   43 |  if (TCPStateMachine == CLOSED)
	.symb	LINE, 43
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jne	d15,#0,_3			; TCPStateMachine
	mov16	d7,#-2				; -2
;   44 |  {
;   45 |    TCPFlags &= ~TCP_ACTIVE_OPEN;                // let's do a passive open!
	.symb	LINE, 45
	ld.bu	d15,TCPFlags			; TCPFlags
	and16	d15,d7				; TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;   46 |    TCPStateMachine = LISTENING;
	.symb	LINE, 46
	mov16	d15,#1				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;   47 |    SocketStatus = SOCK_ACTIVE;                  // reset, socket now active
	.symb	LINE, 47
	st.b	SocketStatus,d15		; SocketStatus
;   48 |  }
	.symb	LINE, 48
_3:
;   49 |}
	.symb	LINE, 49
	ret16
	.symb	EFUN
;   50 |
;   51 |// easyWEB-API function
;   52 |// does an active open (tries to establish a connection between
;   53 |// 'MyIP:TCPLocalPort' and 'RemoteIP:TCPRemotePort')
;   54 |
;   55 |void TCPActiveOpen(void)
;   56 |{
	.symb	LINE, 56
	.symb	TYPE, 266, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPActiveOpen", TCPActiveOpen, #266, 0, 0, 0
	.symb	ALAB, TCPActiveOpen, #266
TCPActiveOpen:
	.symb	SOFF, 0
;   57 |  if ((TCPStateMachine == CLOSED) || (TCPStateMachine == LISTENING))
	.symb	LINE, 57
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#0,_4			; TCPStateMachine
	jne	d15,#1,_5
_4:
	mov16	d7,#-3				; -3
	ld.bu	d15,TCPFlags			; TCPFlags
;   58 |  {
;   59 |    TCPFlags |= TCP_ACTIVE_OPEN;                 // let's do an active open!
	.symb	LINE, 59
	or	d15,d15,#1			; $TCPFlags
;   60 |    TCPFlags &= ~IP_ADDR_RESOLVED;               // we haven't opponents MAC yet
	.symb	LINE, 60
	and16	d15,d7				; $TCPFlags
	extr.u	d15,d15,#0,#8			; $TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;   61 |  
;   62 |    PrepareARP_REQUEST();                        // ask for MAC by sending a broadcast
	.symb	LINE, 62
	callg	PrepareARP_REQUEST
;   63 |    LastFrameSent = ARP_REQUEST;
	.symb	LINE, 63
	mov16	d15,#0				; LastFrameSent
	st.b	LastFrameSent,d15		; LastFrameSent
;   64 |    TCPStartRetryTimer();
	.symb	LINE, 64
	callg	TCPStartRetryTimer
;   65 |    SocketStatus = SOCK_ACTIVE;                  // reset, socket now active    
	.symb	LINE, 65
	mov16	d15,#1				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;   66 |  }
	.symb	LINE, 66
_5:
;   67 |}
	.symb	LINE, 67
	ret16
	.symb	EFUN
;   68 |
;   69 |// easyWEB-API function
;   70 |// closes an open connection
;   71 |
;   72 |void TCPClose(void)
;   73 |{
	.symb	LINE, 73
	.symb	TYPE, 267, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPClose", TCPClose, #267, 0, 0, 0
	.symb	ALAB, TCPClose, #267
TCPClose:
	.symb	SOFF, 0
	ld.bu	d7,TCPFlags			; TCPFlags
;   74 |  switch (TCPStateMachine)
	.symb	LINE, 74
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#1,_7			; case 1
	jeq	d15,#2,_7			; case 2
	jeq	d15,#3,_9			; case 3
	jeq	d15,#4,_9			; case 4
	j	_11				; default
;   75 |  {
;   76 |    case LISTENING :
;   77 |    case SYN_SENT :
	.symb	LINE, 77
_7:
;   78 |    {
;   79 |      TCPStateMachine = CLOSED;
	.symb	LINE, 79
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;   80 |      TCPFlags = 0;
	.symb	LINE, 80
	mov16	d7,#0				; 0
;   81 |      SocketStatus = 0;
	.symb	LINE, 81
	st.b	SocketStatus,d15		; SocketStatus
;   82 |      break;
	.symb	LINE, 82
	j	_11
;   83 |    }
;   84 |    case SYN_RECD :
;   85 |    case ESTABLISHED :
	.symb	LINE, 85
_9:
;   86 |    {
;   87 |      TCPFlags |= TCP_CLOSE_REQUESTED;
	.symb	LINE, 87
	or	d7,d7,#16			; $TCPFlags
	extr.u	d7,d7,#0,#8			; $TCPFlags
;   88 |      break;
;   89 |    }
;   90 |  }
	.symb	LINE, 90
_11:
	st.b	TCPFlags,d7			; TCPFlags
;   91 |}
	.symb	LINE, 91
	ret16
	.symb	EFUN
;   92 |
;   93 |// easyWEB-API function
;   94 |// releases the receive-buffer and allows easyWEB to store new data
;   95 |// NOTE: rx-buffer MUST be released periodically, else the other TCP
;   96 |//       get no ACKs for the data it sent
;   97 |
;   98 |void TCPReleaseRxBuffer(void)
;   99 |{
	.symb	LINE, 99
	.symb	TYPE, 268, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPReleaseRxBuffer", TCPReleaseRxBuffer, #268, 0, 0, 0
	.symb	ALAB, TCPReleaseRxBuffer, #268
TCPReleaseRxBuffer:
	mov16	d7,#-5				; -5
	.symb	SOFF, 0
;  100 |  SocketStatus &= ~SOCK_DATA_AVAILABLE;
	.symb	LINE, 100
	ld.bu	d15,SocketStatus		; SocketStatus
	and16	d15,d7				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  101 |}
	.symb	LINE, 101
	ret16
	.symb	EFUN
;  102 |
;  103 |// easyWEB-API function
;  104 |// transmitts data stored in 'TCP_TX_BUF'
;  105 |// NOTE: * number of bytes to transmit must have been written to 'TCPTxDataCount'
;  106 |//       * data-count MUST NOT exceed 'MAX_TCP_TX_DATA_SIZE'
;  107 |
;  108 |void TCPTransmitTxBuffer(void)
;  109 |{
	.symb	LINE, 109
	.symb	TYPE, 269, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPTransmitTxBuffer", TCPTransmitTxBuffer, #269, 0, 0, 0
	.symb	ALAB, TCPTransmitTxBuffer, #269
TCPTransmitTxBuffer:
	.symb	SOFF, 0
;  110 |  if ((TCPStateMachine == ESTABLISHED) || (TCPStateMachine == CLOSE_WAIT))
	.symb	LINE, 110
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#4,_12
	jne	d15,#7,_14
_12:
;  111 |    if (SocketStatus & SOCK_TX_BUF_RELEASED)
	.symb	LINE, 111
	ld.bu	d15,SocketStatus		; SocketStatus
	jz.t	d15:3,_14
;  112 |    {
;  113 |      SocketStatus &= ~SOCK_TX_BUF_RELEASED;               // occupy tx-buffer
	.symb	LINE, 113
	mov	d7,#-9				; -9
	and16	d15,d7				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  114 |      TCPUNASeqNr += TCPTxDataCount;                       // advance UNA
	.symb	LINE, 114
	ld.w	d7,TCPUNASeqNr			; TCPUNASeqNr
	ld.hu	d15,TCPTxDataCount		; TCPTxDataCount
	add16	d7,d15				; TCPUNASeqNr
	st.w	TCPUNASeqNr,d7			; TCPUNASeqNr
;  115 |      
;  116 |      TxFrame1Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + TCPTxDataCount;
	.symb	LINE, 116
	addi	d15,d15,#54
	st.h	TxFrame1Size,d15		; TxFrame1Size
;  117 |      TransmitControl |= SEND_FRAME1;
	.symb	LINE, 117
	ld.bu	d15,TransmitControl		; TransmitControl
	or	d15,d15,#1			; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  118 |      
;  119 |      LastFrameSent = TCP_DATA_FRAME;
	.symb	LINE, 119
	mov16	d15,#4				; LastFrameSent
	st.b	LastFrameSent,d15		; LastFrameSent
;  120 |      TCPStartRetryTimer();
	.symb	LINE, 120
	callg	TCPStartRetryTimer
;  121 |    }
;  122 |}
	.symb	LINE, 122
_14:
	ret16
	.symb	EFUN
;  123 |
;  124 |// easyWEB's 'main()'-function
;  125 |// must be called from user program periodically (the often - the better)
;  126 |// handles network, TCP/IP-stack and user events
;  127 |
;  128 |void DoNetworkStuff(void)
;  129 |{
	.symb	LINE, 129
	.symb	TYPE, 270, 'X', 8, #1, 26, 0
	.symb	GFUN, "DoNetworkStuff", DoNetworkStuff, #270, 0, 0, 0
	.symb	ALAB, DoNetworkStuff, #270
DoNetworkStuff:
	.symb	IDEN, "ActRxEvent", -1, #5, 131, 0x5
;  130 |  unsigned short ActRxEvent;                       // copy of cs8900's RxEvent-Register
;  131 |
;  132 |  Write8900(ADD_PORT, PP_RxEvent);               // point to RxEvent
	.symb	LINE, 132
	mov	d4,#10				; 10
	.symb	SOFF, 0
	.symb	LTIM, "ActRxEvent", -1, 0, 0x45
	.symb	LTIM, "ActRxEvent", 2, 0, 0xcd
	.symb	LTIM, "ActRxEvent", 2, 0, 0x4d
	.symb	LTIM, "ActRxEvent", 14, 0, 0xcd
	mov	d5,#292				; 292
	callg	Write8900
;  133 |  ActRxEvent = Read8900(DATA_PORT);              // read, implied skip the last frame
	.symb	LINE, 133
	mov	d4,#12				; 12
	callg	Read8900
;  134 |
;  135 |  if (ActRxEvent & RX_OK)
	.symb	LINE, 135
	mov16	d14,d2
	jz.t	d14:8,_17
;  136 |  {
;  137 |    if (ActRxEvent & RX_IA) ProcessEthIAFrame();
	.symb	LINE, 137
	mov	d15,#1024			; 1024
	and16	d15,d14
	jeq	d15,#0,_15
	callg	ProcessEthIAFrame
_15:
;  138 |    if (ActRxEvent & RX_BROADCAST) ProcessEthBroadcastFrame();
	.symb	LINE, 138
	mov	d15,#2048			; 2048
	and16	d15,d14
	jeq	d15,#0,_17
	callg	ProcessEthBroadcastFrame
;  139 |  }
	.symb	LINE, 139
_17:
;  140 |
;  141 |  if (TCPFlags & TCP_TIMER_RUNNING)
	.symb	LINE, 141
	ld.bu	d15,TCPFlags			; TCPFlags
	jz.t	d15:2,_24
;  142 |    if (TCPFlags & TIMER_TYPE_RETRY)
	.symb	LINE, 142
	jz.t	d15:3,_19
;  143 |    {
;  144 |      if (TCPTimer > RETRY_TIMEOUT)
	.symb	LINE, 144
	ld.bu	d15,TCPTimer			; TCPTimer
	ge	d15,d15,#9
	jeq	d15,#0,_24
;  145 |      {
;  146 |        TCPRestartTimer();                       // set a new timeout
	.symb	LINE, 146
	callg	TCPRestartTimer
;  147 |
;  148 |        if (RetryCounter)
	.symb	LINE, 148
	ld.bu	d15,RetryCounter		; RetryCounter
	jeq	d15,#0,_18			; RetryCounter
;  149 |        {
;  150 |          TCPHandleRetransmission();             // resend last frame
	.symb	LINE, 150
	callg	TCPHandleRetransmission
;  151 |          RetryCounter--;
	.symb	LINE, 151
	ld.bu	d15,RetryCounter		; RetryCounter
	add16	d15,#-1				; RetryCounter
	st.b	RetryCounter,d15		; RetryCounter
;  152 |        }
	.symb	LINE, 152
	j	_24
_18:
;  153 |        else
;  154 |        {
;  155 |          TCPStopTimer();
	.symb	LINE, 155
	callg	TCPStopTimer
;  156 |          TCPHandleTimeout();
	.symb	LINE, 156
	callg	TCPHandleTimeout
;  157 |        }
;  158 |      }
;  159 |    }
	.symb	LINE, 159
	j	_24
_19:
;  160 |    else if (TCPTimer > FIN_TIMEOUT)
	.symb	LINE, 160
	ld.bu	d15,TCPTimer			; TCPTimer
	jlt	d15,#3,_24
;  161 |    {
;  162 |      TCPStateMachine = CLOSED;
	.symb	LINE, 162
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  163 |      TCPFlags = 0;                              // reset all flags, stop retransmission...
	.symb	LINE, 163
	st.b	TCPFlags,d15			; TCPFlags
;  164 |      SocketStatus &= SOCK_DATA_AVAILABLE;       // clear all flags but data available
	.symb	LINE, 164
	ld.bu	d15,SocketStatus		; SocketStatus
	and	d15,d15,#4			; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  165 |    }
;  166 |
;  167 |  switch (TCPStateMachine)
	.symb	LINE, 167
_24:
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#0,_26			; case 0
	jeq	d15,#1,_26			; case 1
	jeq	d15,#3,_28			; case 3
	jeq	d15,#4,_28			; case 4
	jeq	d15,#7,_29			; case 7
	j	_40				; default
;  168 |  {
;  169 |    case CLOSED :
;  170 |    case LISTENING :
	.symb	LINE, 170
_26:
;  171 |    {
;  172 |      if (TCPFlags & TCP_ACTIVE_OPEN)            // stack has to open a connection?
	.symb	LINE, 172
	ld.bu	d15,TCPFlags			; TCPFlags
	jz.t	d15:0,_40
;  173 |        if (TCPFlags & IP_ADDR_RESOLVED)         // IP resolved?
	.symb	LINE, 173
	jz.t	d15:1,_40
;  174 |          if (!(TransmitControl & SEND_FRAME2))  // buffer free?
	.symb	LINE, 174
	ld.bu	d15,TransmitControl		; TransmitControl
	jnz.t	d15:1,_40
	mov16	d7,#0				; TCPAckNr
;  175 |          {
;  176 |// PHYTEC:            TCPSeqNr = ((unsigned long)ISNGenHigh << 16) | T3;  // Keil: changed from TAR to T3; // set local ISN
;  177 |					  TCPSeqNr = ((unsigned long)ISNGenHigh << 16);
	.symb	LINE, 177
	ld.hu	d15,ISNGenHigh			; ISNGenHigh
	sh	d15,d15,#16
	st.w	TCPSeqNr,d15			; TCPSeqNr
	add16	d15,#1
;  178 |            TCPUNASeqNr = TCPSeqNr;
;  179 |            TCPAckNr = 0;                                       // we don't know what to ACK!
	.symb	LINE, 179
	st.w	TCPAckNr,d7			; TCPAckNr
	mov16	d4,#2				; 2
;  180 |            TCPUNASeqNr++;                                      // count SYN as a byte
	.symb	LINE, 180
	st.w	TCPUNASeqNr,d15			; TCPUNASeqNr
;  181 |            PrepareTCP_FRAME(TCP_CODE_SYN);                     // send SYN frame
	.symb	LINE, 181
	callg	PrepareTCP_FRAME
;  182 |            LastFrameSent = TCP_SYN_FRAME;
	.symb	LINE, 182
	mov16	d15,#1				; LastFrameSent
	st.b	LastFrameSent,d15		; LastFrameSent
;  183 |            TCPStartRetryTimer();                               // we NEED a retry-timeout
	.symb	LINE, 183
	callg	TCPStartRetryTimer
;  184 |            TCPStateMachine = SYN_SENT;
	.symb	LINE, 184
	mov16	d15,#2				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  185 |          }
;  186 |      break;
	.symb	LINE, 186
	j	_40
;  187 |    }
;  188 |    case SYN_RECD :
;  189 |    case ESTABLISHED :
	.symb	LINE, 189
_28:
;  190 |    {
;  191 |      if (TCPFlags & TCP_CLOSE_REQUESTED)                  // user has user initated a close?
	.symb	LINE, 191
	ld.bu	d15,TCPFlags			; TCPFlags
	jz.t	d15:4,_40
;  192 |        if (!(TransmitControl & (SEND_FRAME2 | SEND_FRAME1)))   // buffers free?
	.symb	LINE, 192
	ld.bu	d15,TransmitControl		; TransmitControl
	and	d15,d15,#3
	jne	d15,#0,_40
;  193 |          if (TCPSeqNr == TCPUNASeqNr)                          // all data ACKed?
	.symb	LINE, 193
	ld.w	d7,TCPSeqNr			; TCPSeqNr
	ld.w	d15,TCPUNASeqNr			; TCPUNASeqNr
	jne	d7,d15,_40
;  194 |          {
;  195 |            TCPUNASeqNr++;
	.symb	LINE, 195
	add16	d15,#1				; TCPUNASeqNr
	st.w	TCPUNASeqNr,d15			; TCPUNASeqNr
;  196 |            PrepareTCP_FRAME(TCP_CODE_FIN | TCP_CODE_ACK);
	.symb	LINE, 196
	mov	d4,#17				; 17
	callg	PrepareTCP_FRAME
;  197 |            LastFrameSent = TCP_FIN_FRAME;
	.symb	LINE, 197
	mov16	d15,#3				; LastFrameSent
	st.b	LastFrameSent,d15		; LastFrameSent
;  198 |            TCPStartRetryTimer();
	.symb	LINE, 198
	callg	TCPStartRetryTimer
;  199 |            TCPStateMachine = FIN_WAIT_1;
	.symb	LINE, 199
	mov16	d15,#5				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  200 |          }
;  201 |      break;
	.symb	LINE, 201
	j	_40
;  202 |    }
;  203 |    case CLOSE_WAIT :
	.symb	LINE, 203
_29:
;  204 |    {
;  205 |      if (!(TransmitControl & (SEND_FRAME2 | SEND_FRAME1)))     // buffers free?
	.symb	LINE, 205
	ld.bu	d15,TransmitControl		; TransmitControl
	and	d15,d15,#3
	jne	d15,#0,_40
;  206 |        if (TCPSeqNr == TCPUNASeqNr)                            // all data ACKed?
	.symb	LINE, 206
	ld.w	d7,TCPSeqNr			; TCPSeqNr
	ld.w	d15,TCPUNASeqNr			; TCPUNASeqNr
	jne	d7,d15,_40
;  207 |        {
;  208 |          TCPUNASeqNr++;                                        // count FIN as a byte
	.symb	LINE, 208
	add16	d15,#1				; TCPUNASeqNr
	st.w	TCPUNASeqNr,d15			; TCPUNASeqNr
;  209 |          PrepareTCP_FRAME(TCP_CODE_FIN | TCP_CODE_ACK);        // we NEED a retry-timeout
	.symb	LINE, 209
	mov	d4,#17				; 17
	callg	PrepareTCP_FRAME
;  210 |          LastFrameSent = TCP_FIN_FRAME;                        // time to say goodbye...
	.symb	LINE, 210
	mov16	d15,#3				; LastFrameSent
	st.b	LastFrameSent,d15		; LastFrameSent
;  211 |          TCPStartRetryTimer();
	.symb	LINE, 211
	callg	TCPStartRetryTimer
;  212 |          TCPStateMachine = LAST_ACK;
	.symb	LINE, 212
	mov16	d15,#9				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  213 |        }
;  214 |      break;
;  215 |    }
;  216 |  }
	.symb	LINE, 216
_40:
;  217 |
;  218 |  if (TransmitControl & SEND_FRAME2)
	.symb	LINE, 218
	ld.bu	d15,TransmitControl		; TransmitControl
	jz.t	d15:1,_43
;  219 |  {
;  220 |    RequestSend(TxFrame2Size);
	.symb	LINE, 220
	ld.bu	d4,TxFrame2Size			; TxFrame2Size
	callg	RequestSend
;  221 |
;  222 |    if (Rdy4Tx())                                // NOTE: when using a very fast MCU, maybe
	.symb	LINE, 222
	callg	Rdy4Tx
	jeq	d2,#0,_41
;  223 |      SendFrame2();                              // the CS8900 isn't ready yet, include
	.symb	LINE, 223
	callg	SendFrame2
	j	_42
_41:
;  224 |    else {                                       // a kind of timer or counter here
;  225 |      TCPStateMachine = CLOSED;
	.symb	LINE, 225
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  226 |      SocketStatus = SOCK_ERR_ETHERNET;          // indicate an error to user
	.symb	LINE, 226
	mov16	d15,#80				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  227 |      TCPFlags = 0;                              // clear all flags, stop timers etc.
	.symb	LINE, 227
	mov16	d15,#0				; TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;  228 |    }
	.symb	LINE, 228
_42:
	mov16	d7,#-3				; -3
;  229 |
;  230 |    TransmitControl &= ~SEND_FRAME2;             // clear tx-flag
	.symb	LINE, 230
	ld.bu	d15,TransmitControl		; TransmitControl
	and16	d15,d7				; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  231 |  }
	.symb	LINE, 231
_43:
;  232 |
;  233 |  if (TransmitControl & SEND_FRAME1)
	.symb	LINE, 233
	ld.bu	d15,TransmitControl		; TransmitControl
	jz.t	d15:0,_46
;  234 |  {
;  235 |    PrepareTCP_DATA_FRAME();                     // build frame w/ actual SEQ, ACK....
	.symb	LINE, 235
	callg	PrepareTCP_DATA_FRAME
;  236 |    RequestSend(TxFrame1Size);
	.symb	LINE, 236
	ld.hu	d4,TxFrame1Size			; TxFrame1Size
	callg	RequestSend
;  237 |  
;  238 |    if (Rdy4Tx())                                // CS8900 ready to accept our frame?
	.symb	LINE, 238
	callg	Rdy4Tx
	jeq	d2,#0,_44
;  239 |      SendFrame1();                              // (see note above)
	.symb	LINE, 239
	callg	SendFrame1
	j	_45
_44:
;  240 |    else {
;  241 |      TCPStateMachine = CLOSED;
	.symb	LINE, 241
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  242 |      SocketStatus = SOCK_ERR_ETHERNET;          // indicate an error to user
	.symb	LINE, 242
	mov16	d15,#80				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  243 |      TCPFlags = 0;                              // clear all flags, stop timers etc.
	.symb	LINE, 243
	mov16	d15,#0				; TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;  244 |    }
	.symb	LINE, 244
_45:
	mov16	d7,#-2				; -2
;  245 |
;  246 |    TransmitControl &= ~SEND_FRAME1;             // clear tx-flag
	.symb	LINE, 246
	ld.bu	d15,TransmitControl		; TransmitControl
	and16	d15,d7				; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  247 |  }
	.symb	LINE, 247
_46:
;  248 |}
	.symb	LINE, 248
	ret16
	.symb	LTIM, "ActRxEvent", 14, 0, 0x4d
	.symb	EFUN
;  249 |
;  250 |// easyWEB internal function
;  251 |// handles an incoming broadcast frame
;  252 |
;  253 |void ProcessEthBroadcastFrame(void)
;  254 |{
	.symb	LINE, 254
	.symb	TYPE, 271, 'X', 8, #1, 26, 0
	.symb	GFUN, "ProcessEthBroadcastFrame", ProcessEthBroadcastFrame, #271, 0, 16, 0
	.symb	ALAB, ProcessEthBroadcastFrame, #271
ProcessEthBroadcastFrame:
	.symb	TYPE, 272, 'Z', #5, 1
	.symb	IDEN, "TargetIP", -16, #272, 129, 0x5
	mov16	d4,#0				; 0
	.symb	SOFF, 16
	sub16.a	sp,#16
;  255 |  unsigned short TargetIP[2];
;  256 |
;  257 |  // next two words MUST be read with High-Byte 1st (CS8900 AN181 Page 2)
;  258 |  ReadHB1ST8900(RX_FRAME_PORT);                  // ignore RxStatus Word
	.symb	LINE, 258
	callg	ReadHB1ST8900
;  259 |  RecdFrameLength = ReadHB1ST8900(RX_FRAME_PORT);// get real length of frame 
	.symb	LINE, 259
	mov16	d4,#0				; 0
	callg	ReadHB1ST8900
	mov16	d4,#6				; 6
	st.h	RecdFrameLength,d2		; RecdFrameLength
;  260 |    
;  261 |  DummyReadFrame8900(6);                         // ignore DA (FF-FF-FF-FF-FF-FF)
	.symb	LINE, 261
	callg	DummyReadFrame8900
	mov16	d4,#6				; 6
;  262 |  CopyFromFrame8900(&RecdFrameMAC, 6);           // store SA (for our answer)
	.symb	LINE, 262
	movh.a	a4,#@his(RecdFrameMAC)
	lea	a4,[a4]@los(RecdFrameMAC)
	callg	CopyFromFrame8900
;  263 |
;  264 |  if (ReadFrameBE8900() == FRAME_ARP)            // get frame type, check for ARP
	.symb	LINE, 264
	callg	ReadFrameBE8900
	mov	d15,#2054			; 2054
	jne	d2,d15,_52
;  265 |    if (ReadFrameBE8900() == HARDW_ETH10)        // Ethernet frame
	.symb	LINE, 265
	callg	ReadFrameBE8900
	jne	d2,#1,_52
;  266 |      if (ReadFrameBE8900() == FRAME_IP)         // check protocol
	.symb	LINE, 266
	callg	ReadFrameBE8900
	mov	d15,#2048			; 2048
	jne	d2,d15,_52
;  267 |        if (ReadFrameBE8900() == IP_HLEN_PLEN)   // check HLEN, PLEN
	.symb	LINE, 267
	callg	ReadFrameBE8900
	mov	d15,#1540			; 1540
	jne	d2,d15,_52
;  268 |          if (ReadFrameBE8900() == OP_ARP_REQUEST)
	.symb	LINE, 268
	callg	ReadFrameBE8900
	jne	d2,#1,_52
;  269 |          {
;  270 |            DummyReadFrame8900(6);               // ignore sender's hardware address
	.symb	LINE, 270
	mov16	d4,#6				; 6
	callg	DummyReadFrame8900
	mov16	d4,#4				; 4
;  271 |            CopyFromFrame8900(&RecdFrameIP, 4);  // read sender's protocol address
	.symb	LINE, 271
	movh.a	a4,#@his(RecdFrameIP)
	lea	a4,[a4]@los(RecdFrameIP)
	callg	CopyFromFrame8900
;  272 |            DummyReadFrame8900(6);               // ignore target's hardware address
	.symb	LINE, 272
	mov16	d4,#6				; 6
	callg	DummyReadFrame8900
	mov16	d4,#4				; 4
;  273 |            CopyFromFrame8900(&TargetIP, 4);     // read target's protocol address
	.symb	LINE, 273
	lea	a14,[sp]
	mov16.aa a4,a14
	callg	CopyFromFrame8900
	mov16	d4,#4				; 4
;  274 |            if (!memcmp(&MyIP, &TargetIP, 4))    // is it for us?
	.symb	LINE, 274
	movh.a	a4,#@his(MyIP)
	lea	a4,[a4]@los(MyIP)
	mov16.aa a5,a14
	callg	memcmp
	jne	d2,#0,_52
;  275 |              PrepareARP_ANSWER();               // yes->create ARP_ANSWER frame
	.symb	LINE, 275
	callg	PrepareARP_ANSWER
;  276 |          }
;  277 |}
	.symb	LINE, 277
_52:
	ret16
	.symb	EFUN
;  278 |
;  279 |// easyWEB internal function
;  280 |// handles an incoming frame that passed CS8900's address filter
;  281 |// (individual addressed = IA)
;  282 |
;  283 |void ProcessEthIAFrame(void)
;  284 |{
	.symb	LINE, 284
	.symb	TYPE, 274, 'X', 8, #1, 26, 0
	.symb	GFUN, "ProcessEthIAFrame", ProcessEthIAFrame, #274, 0, 16, 0
	.symb	ALAB, ProcessEthIAFrame, #274
ProcessEthIAFrame:
	.symb	IDEN, "TargetIP", -16, #272, 129, 0x5
	.symb	IDEN, "ProtocolType", -1, #3, 131, 0x5
	mov16	d4,#0				; 0
	.symb	SOFF, 16
	.symb	LTIM, "ProtocolType", -1, 0, 0x45
	sub16.a	sp,#16
;  285 |  unsigned short TargetIP[2];
;  286 |  unsigned char ProtocolType;
;  287 |
;  288 |  // next two words MUST be read with High-Byte 1st (CS8900 AN181 Page 2)
;  289 |  ReadHB1ST8900(RX_FRAME_PORT);                  // ignore RxStatus Word
	.symb	LINE, 289
	callg	ReadHB1ST8900
;  290 |  RecdFrameLength = ReadHB1ST8900(RX_FRAME_PORT);// get real length of frame 
	.symb	LINE, 290
	mov16	d4,#0				; 0
	callg	ReadHB1ST8900
	mov16	d4,#6				; 6
	st.h	RecdFrameLength,d2		; RecdFrameLength
;  291 |  
;  292 |  DummyReadFrame8900(6);                         // ignore DA
	.symb	LINE, 292
	callg	DummyReadFrame8900
	mov16	d4,#6				; 6
;  293 |  CopyFromFrame8900(&RecdFrameMAC, 6);           // store SA (for our answer)
	.symb	LINE, 293
	movh.a	a4,#@his(RecdFrameMAC)
	lea	a4,[a4]@los(RecdFrameMAC)
	callg	CopyFromFrame8900
;  294 |
;  295 |  switch (ReadFrameBE8900())                     // get frame type
	.symb	LINE, 295
	callg	ReadFrameBE8900
	mov16	d15,d2
	addi	d15,d15,#-2054
	jeq	d15,#-6,_54			; case 2048
	jne	d15,#0,_68			; case 2054
;  296 |  {
;  297 |    case FRAME_ARP :                             // check for ARP
;  298 |    {
;  299 |      if ((TCPFlags & (TCP_ACTIVE_OPEN | IP_ADDR_RESOLVED)) == TCP_ACTIVE_OPEN)
	.symb	LINE, 299
	ld.bu	d15,TCPFlags			; TCPFlags
	and	d15,d15,#3
	jne	d15,#1,_68
;  300 |        if (ReadFrameBE8900() == HARDW_ETH10)         // check for the right prot. etc.
	.symb	LINE, 300
	callg	ReadFrameBE8900
	jne	d2,#1,_68
;  301 |          if (ReadFrameBE8900() == FRAME_IP)
	.symb	LINE, 301
	callg	ReadFrameBE8900
	mov	d15,#2048			; 2048
	jne	d2,d15,_68
;  302 |            if (ReadFrameBE8900() == IP_HLEN_PLEN)
	.symb	LINE, 302
	callg	ReadFrameBE8900
	mov	d15,#1540			; 1540
	jne	d2,d15,_68
;  303 |              if (ReadFrameBE8900() == OP_ARP_ANSWER)
	.symb	LINE, 303
	callg	ReadFrameBE8900
	jne	d2,#2,_68
;  304 |              {
;  305 |                TCPStopTimer();                       // OK, now we've the MAC we wanted ;-)
	.symb	LINE, 305
	callg	TCPStopTimer
	mov16	d4,#6				; 6
;  306 |                CopyFromFrame8900(&RemoteMAC, 6);     // extract opponents MAC
	.symb	LINE, 306
	movh.a	a4,#@his(RemoteMAC)
	lea	a4,[a4]@los(RemoteMAC)
	callg	CopyFromFrame8900
;  307 |                TCPFlags |= IP_ADDR_RESOLVED;
	.symb	LINE, 307
	ld.bu	d4,TCPFlags			; TCPFlags
	or	d4,d4,#2			; TCPFlags
	st.b	TCPFlags,d4			; TCPFlags
;  308 |              }
;  309 |      break;
	.symb	LINE, 309
	ret16
;  310 |    }
;  311 |    case FRAME_IP :                                        // check for IP-type
	.symb	LINE, 311
_54:
	.symb	LTIM, "ProtocolType", 14, 0, 0xcd
	.symb	LTIM, "ProtocolType", 14, 0, 0x4d
	.symb	LTIM, "ProtocolType", 15, 0, 0xcd
;  312 |    {
;  313 |      if ((ReadFrameBE8900() & 0xFF00 ) == IP_VER_IHL)     // IPv4, IHL=5 (20 Bytes Header)
	.symb	LINE, 313
	callg	ReadFrameBE8900
	mov.u	d15,#65280			; 65280
	and16	d15,d2
	mov	d7,#17664			; 17664
	jne	d15,d7,_68
;  314 |      {                                                    // ignore Type Of Service
;  315 |        RecdIPFrameLength = ReadFrameBE8900();             // get IP frame's length
	.symb	LINE, 315
	callg	ReadFrameBE8900
	st.h	RecdIPFrameLength,d2		; RecdIPFrameLength
;  316 |        ReadFrameBE8900();                                 // ignore identification
	.symb	LINE, 316
	callg	ReadFrameBE8900
;  317 |
;  318 |        if (!(ReadFrameBE8900() & (IP_FLAG_MOREFRAG | IP_FRAGOFS_MASK)))  // only unfragm. frames
	.symb	LINE, 318
	callg	ReadFrameBE8900
	mov	d15,#16383			; 16383
	and16	d15,d2
	jne	d15,#0,_68
;  319 |        {
;  320 |          ProtocolType = ReadFrameBE8900();                // get protocol, ignore TTL
	.symb	LINE, 320
	callg	ReadFrameBE8900
	extr.u	d14,d2,#0,#8			; ProtocolType
;  321 |          ReadFrameBE8900();                               // ignore checksum
	.symb	LINE, 321
	callg	ReadFrameBE8900
	mov16	d4,#4				; 4
;  322 |          CopyFromFrame8900(&RecdFrameIP, 4);              // get source IP
	.symb	LINE, 322
	movh.a	a4,#@his(RecdFrameIP)
	lea	a4,[a4]@los(RecdFrameIP)
	callg	CopyFromFrame8900
	mov16	d4,#4				; 4
;  323 |          CopyFromFrame8900(&TargetIP, 4);                 // get destination IP
	.symb	LINE, 323
	lea	a14,[sp]
	mov16.aa a4,a14
	callg	CopyFromFrame8900
	mov16	d4,#4				; 4
;  324 |
;  325 |          if (!memcmp(&MyIP, &TargetIP, 4))                // is it for us?
	.symb	LINE, 325
	movh.a	a4,#@his(MyIP)
	lea	a4,[a4]@los(MyIP)
	mov16.aa a5,a14
	callg	memcmp
	jne	d2,#0,_68
;  326 |            switch (ProtocolType) {
	.symb	LINE, 326
	mov16	d15,d14				; ProtocolType
	jeq	d15,#1,_56			; case 1
	jne	d15,#6,_68			; case 6
	.symb	LTIM, "ProtocolType", 15, 0, 0x4d
;  327 |              case PROT_ICMP : { ProcessICMPFrame(); break; }
;  328 |              case PROT_TCP  : { ProcessTCPFrame(); break; }
	.symb	LINE, 328
	jg	ProcessTCPFrame
	.symb	LINE, 327
_56:
	callg	ProcessICMPFrame
;  329 |              case PROT_UDP  : break;                      // not implemented!
;  330 |            }
;  331 |        }      
;  332 |      }
;  333 |      break;
;  334 |    }
;  335 |  }
	.symb	LINE, 335
_68:
;  336 |}
	.symb	LINE, 336
	ret16
	.symb	EFUN
;  337 |
;  338 |// easyWEB internal function
;  339 |// we've just rec'd an ICMP-frame (Internet Control Message Protocol)
;  340 |// check what to do and branch to the appropriate sub-function
;  341 |
;  342 |void ProcessICMPFrame(void)
;  343 |{
	.symb	LINE, 343
	.symb	TYPE, 275, 'X', 8, #1, 26, 0
	.symb	GFUN, "ProcessICMPFrame", ProcessICMPFrame, #275, 0, 0, 0
	.symb	ALAB, ProcessICMPFrame, #275
ProcessICMPFrame:
	.symb	IDEN, "ICMPTypeAndCode", -1, #5, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "ICMPTypeAndCode", -1, 0, 0x45
	.symb	LTIM, "ICMPTypeAndCode", 14, 0, 0xcd
;  344 |  unsigned short ICMPTypeAndCode;
;  345 |
;  346 |  ICMPTypeAndCode = ReadFrameBE8900();           // get Message Type and Code
	.symb	LINE, 346
	callg	ReadFrameBE8900
	mov16	d14,d2
;  347 |  ReadFrameBE8900();                             // ignore ICMP checksum
	.symb	LINE, 347
	callg	ReadFrameBE8900
;  348 |
;  349 |  switch (ICMPTypeAndCode >> 8) {                // check type
	.symb	LINE, 349
	sha	d15,d14,#-8
	add16	d15,#-8
	jne	d15,#0,_70			; case 8
;  350 |    case ICMP_ECHO :                             // is echo request?
;  351 |    {
;  352 |      PrepareICMP_ECHO_REPLY();                  // echo as much as we can...
	.symb	LINE, 352
	callg	PrepareICMP_ECHO_REPLY
;  353 |      break;
;  354 |    }
;  355 |  }
	.symb	LINE, 355
_70:
;  356 |}
	.symb	LINE, 356
	ret16
	.symb	LTIM, "ICMPTypeAndCode", 14, 0, 0x4d
	.symb	EFUN
;  357 |
;  358 |// easyWEB internal function
;  359 |// we've just rec'd an TCP-frame (Transmission Control Protocol)
;  360 |// this function mainly implements the TCP state machine according to RFC793
;  361 |
;  362 |void ProcessTCPFrame(void)
;  363 |{
	.symb	LINE, 363
	.symb	TYPE, 276, 'X', 8, #1, 26, 0
	.symb	GFUN, "ProcessTCPFrame", ProcessTCPFrame, #276, 0, 0, 0
	.symb	ALAB, ProcessTCPFrame, #276
ProcessTCPFrame:
	.symb	IDEN, "TCPSegSourcePort", -1, #5, 131, 0x5
	.symb	IDEN, "TCPSegDestPort", -1, #5, 131, 0x5
	.symb	IDEN, "TCPSegSeq", -1, #7, 131, 0x5
	.symb	IDEN, "TCPSegAck", -1, #7, 131, 0x5
	.symb	IDEN, "TCPCode", -1, #5, 131, 0x5
	.symb	IDEN, "TCPHeaderSize", -1, #3, 131, 0x5
	.symb	IDEN, "NrOfDataBytes", -1, #5, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "TCPSegSourcePort", -1, 0, 0x45
	.symb	LTIM, "TCPSegDestPort", -1, 0, 0x45
	.symb	LTIM, "TCPSegSeq", -1, 0, 0x45
	.symb	LTIM, "TCPSegAck", -1, 0, 0x45
	.symb	LTIM, "TCPCode", -1, 0, 0x45
	.symb	LTIM, "TCPHeaderSize", -1, 0, 0x45
	.symb	LTIM, "NrOfDataBytes", -1, 0, 0x45
	.symb	LTIM, "TCPSegSourcePort", 10, 0, 0xcd
	.symb	LTIM, "TCPSegDestPort", 2, 0, 0xcd
	.symb	LTIM, "TCPSegDestPort", 2, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	.symb	LTIM, "TCPCode", 2, 0, 0xcd
	.symb	LTIM, "TCPCode", 2, 0, 0x4d
	.symb	LTIM, "TCPCode", 11, 0, 0xcd
	.symb	LTIM, "TCPHeaderSize", 15, 0, 0xcd
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0xcd
	.symb	LTIM, "TCPHeaderSize", 15, 0, 0x4d
;  364 |  unsigned short TCPSegSourcePort;                 // segment's source port
;  365 |  unsigned short TCPSegDestPort;                   // segment's destination port
;  366 |  unsigned long TCPSegSeq;                       // segment's sequence number
;  367 |  unsigned long TCPSegAck;                       // segment's acknowledge number
;  368 |  unsigned short TCPCode;                          // TCP code and header length
;  369 |  unsigned char TCPHeaderSize;                   // real TCP header length
;  370 |  unsigned short NrOfDataBytes;                    // real number of data
;  371 |    
;  372 |  TCPSegSourcePort = ReadFrameBE8900();                    // get ports
	.symb	LINE, 372
	callg	ReadFrameBE8900
	mov16	d10,d2
;  373 |  TCPSegDestPort = ReadFrameBE8900();
	.symb	LINE, 373
	callg	ReadFrameBE8900
;  374 |
;  375 |  if (TCPSegDestPort != TCPLocalPort) return;              // drop segment if port doesn't match
	.symb	LINE, 375
	ld.hu	d15,TCPLocalPort		; TCPLocalPort
	jne	d2,d15,_263
;  376 |
;  377 |  TCPSegSeq = (unsigned long)ReadFrameBE8900() << 16;      // get segment sequence nr.
	.symb	LINE, 377
	callg	ReadFrameBE8900
	sh	d13,d2,#16
;  378 |  TCPSegSeq |= ReadFrameBE8900();
	.symb	LINE, 378
	callg	ReadFrameBE8900
	or16	d13,d2
;  379 |
;  380 |  TCPSegAck = (unsigned long)ReadFrameBE8900() << 16;      // get segment acknowledge nr.
	.symb	LINE, 380
	callg	ReadFrameBE8900
	sh	d12,d2,#16
;  381 |  TCPSegAck |= ReadFrameBE8900();
	.symb	LINE, 381
	callg	ReadFrameBE8900
	or16	d12,d2
;  382 |
;  383 |  TCPCode = ReadFrameBE8900();                             // get control bits, header length...
	.symb	LINE, 383
	callg	ReadFrameBE8900
;  384 |
;  385 |  TCPHeaderSize = (TCPCode & DATA_OFS_MASK) >> 10;         // header length in bytes
	.symb	LINE, 385
	mov.u	d15,#61440			; 61440
	mov16	d11,d2
	ld.hu	d14,RecdIPFrameLength		; RecdIPFrameLength
	and16	d15,d11
	sha	d15,d15,#-10
	extr.u	d15,d15,#0,#8			; TCPHeaderSize
;  386 |  NrOfDataBytes = RecdIPFrameLength - IP_HEADER_SIZE - TCPHeaderSize;     // seg. text length
	.symb	LINE, 386
	addi	d14,d14,#-20
	sub16	d14,d15
;  387 |
;  388 |  if (NrOfDataBytes > MAX_TCP_RX_DATA_SIZE) return;        // packet too large for us :...-(
	.symb	LINE, 388
	mov	d7,#256				; 256
	.symb	LINE, 386
	extr.u	d14,d14,#0,#16			; NrOfDataBytes
	.symb	LINE, 388
	jlt	d7,d14,_263
;  389 |
;  390 |  if (TCPHeaderSize > TCP_HEADER_SIZE)                     // ignore options if any
	.symb	LINE, 390
	ge	d7,d15,#21
	jeq	d7,#0,_201
;  391 |    DummyReadFrame8900(TCPHeaderSize - TCP_HEADER_SIZE);
	.symb	LINE, 391
	addi	d4,d15,#-20
	extr.u	d4,d4,#0,#16
	callg	DummyReadFrame8900
_201:
;  392 |
;  393 |  switch (TCPStateMachine)                                 // implement the TCP state machine
	.symb	LINE, 393
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#0,_202			; case 0
	jeq	d15,#1,_204			; case 1
	jeq	d15,#2,_205			; case 2
	j	_213				; default
;  394 |  {
;  395 |    case CLOSED :
	.symb	LINE, 395
_202:
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0x4d
	.symb	LTIM, "TCPCode", 11, 0, 0x4d
;  396 |    {
;  397 |      if (!(TCPCode & TCP_CODE_RST))
	.symb	LINE, 397
	jnz.t	d11:2,_263
	mov16	d4,#6				; 6
;  398 |      {
;  399 |        TCPRemotePort = TCPSegSourcePort;
	.symb	LINE, 399
	st.h	TCPRemotePort,d10		; TCPRemotePort
;  400 |        memcpy(&RemoteMAC, &RecdFrameMAC, 6);              // save opponents MAC and IP
	.symb	LINE, 400
	movh.a	a4,#@his(RemoteMAC)
	lea	a4,[a4]@los(RemoteMAC)
	movh.a	a5,#@his(RecdFrameMAC)
	lea	a5,[a5]@los(RecdFrameMAC)
	callg	memcpy
	mov16	d4,#4				; 4
;  401 |        memcpy(&RemoteIP, &RecdFrameIP, 4);                // for later use
	.symb	LINE, 401
	movh.a	a4,#@his(RemoteIP)
	lea	a4,[a4]@los(RemoteIP)
	movh.a	a5,#@his(RecdFrameIP)
	lea	a5,[a5]@los(RecdFrameIP)
	callg	memcpy
;  402 |
;  403 |        if (TCPCode & TCP_CODE_ACK)                        // make the reset sequence
	.symb	LINE, 403
	jnz.t	d11:4,_207
;  404 |        {                                                  // acceptable to the other
;  405 |          TCPSeqNr = TCPSegAck;                            // TCP
;  406 |          PrepareTCP_FRAME(TCP_CODE_RST);
;  407 |        }
;  408 |        else
;  409 |        {
;  410 |          TCPSeqNr = 0;
	.symb	LINE, 410
	mov16	d15,#0				; TCPSeqNr
	st.w	TCPSeqNr,d15			; TCPSeqNr
;  411 |          TCPAckNr = TCPSegSeq + NrOfDataBytes;
	.symb	LINE, 411
	add16	d14,d13
	mov16	d15,d14				; $TCPAckNr
;  412 |          if (TCPCode & (TCP_CODE_SYN | TCP_CODE_FIN)) TCPAckNr++;
	.symb	LINE, 412
	and	d11,d11,#3
	jeq	d11,#0,_203
	add16	d15,d14,#1
_203:
	mov	d4,#20				; 20
	st.w	TCPAckNr,d15			; TCPAckNr
;  413 |          PrepareTCP_FRAME(TCP_CODE_RST | TCP_CODE_ACK);
	.symb	LINE, 413
	jg	PrepareTCP_FRAME
;  414 |        }
;  415 |      }
;  416 |      break;
;  417 |    }  
;  418 |    case LISTENING :
	.symb	LINE, 418
_204:
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	.symb	LTIM, "TCPSegSourcePort", 10, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
;  419 |    {
;  420 |      if (!(TCPCode & TCP_CODE_RST))                       // ignore segment containing RST
	.symb	LINE, 420
	jnz.t	d11:2,_263
	mov16	d4,#6				; 6
;  421 |      {
;  422 |        TCPRemotePort = TCPSegSourcePort;
	.symb	LINE, 422
	st.h	TCPRemotePort,d10		; TCPRemotePort
;  423 |        memcpy(&RemoteMAC, &RecdFrameMAC, 6);              // save opponents MAC and IP
	.symb	LINE, 423
	movh.a	a4,#@his(RemoteMAC)
	lea	a4,[a4]@los(RemoteMAC)
	movh.a	a5,#@his(RecdFrameMAC)
	lea	a5,[a5]@los(RecdFrameMAC)
	callg	memcpy
	mov16	d4,#4				; 4
;  424 |        memcpy(&RemoteIP, &RecdFrameIP, 4);                // for later use
	.symb	LINE, 424
	movh.a	a4,#@his(RemoteIP)
	lea	a4,[a4]@los(RemoteIP)
	movh.a	a5,#@his(RecdFrameIP)
	lea	a5,[a5]@los(RecdFrameIP)
	callg	memcpy
;  425 |
;  426 |        if (TCPCode & TCP_CODE_ACK)                        // reset a bad
	.symb	LINE, 426
	jnz.t	d11:4,_207
;  427 |        {                                                  // acknowledgement
;  428 |          TCPSeqNr = TCPSegAck;
;  429 |          PrepareTCP_FRAME(TCP_CODE_RST);
;  430 |        }
;  431 |        else if (TCPCode & TCP_CODE_SYN)
	.symb	LINE, 431
	jz.t	d11:1,_263
;  432 |        {
;  433 |          TCPAckNr = TCPSegSeq + 1;                           // get remote ISN, next byte we expect
	.symb	LINE, 433
	add16	d13,#1
	st.w	TCPAckNr,d13			; TCPAckNr
;  434 |// PHYTEC:          TCPSeqNr = ((unsigned long)ISNGenHigh << 16) | T3;  // Keil: changed from TAR to T3; // set local ISN
;  435 |					TCPSeqNr = ((unsigned long)ISNGenHigh << 16);
	.symb	LINE, 435
	ld.hu	d15,ISNGenHigh			; ISNGenHigh
	sh	d15,d15,#16
	st.w	TCPSeqNr,d15			; TCPSeqNr
;  436 |          TCPUNASeqNr = TCPSeqNr + 1;                         // one byte out -> increase by one
	.symb	LINE, 436
	add16	d15,#1
	st.w	TCPUNASeqNr,d15			; TCPUNASeqNr
;  437 |          PrepareTCP_FRAME(TCP_CODE_SYN | TCP_CODE_ACK);
	.symb	LINE, 437
	j	_212
;  438 |          LastFrameSent = TCP_SYN_ACK_FRAME;
;  439 |          TCPStartRetryTimer();
;  440 |          TCPStateMachine = SYN_RECD;
;  441 |        }
;  442 |      }
;  443 |      break;
;  444 |    }
;  445 |    case SYN_SENT :
	.symb	LINE, 445
_205:
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	mov16	d4,#4				; 4
;  446 |    {
;  447 |      if (memcmp(&RemoteIP, &RecdFrameIP, 4)) break;  // drop segment if its IP doesn't belong
	.symb	LINE, 447
	movh.a	a4,#@his(RemoteIP)
	lea	a4,[a4]@los(RemoteIP)
	movh.a	a5,#@his(RecdFrameIP)
	lea	a5,[a5]@los(RecdFrameIP)
	callg	memcmp
	jne	d2,#0,_263
;  448 |                                                      // to current session
;  449 |
;  450 |      if (TCPSegSourcePort != TCPRemotePort) break;   // drop segment if port doesn't match
	.symb	LINE, 450
	ld.hu	d15,TCPRemotePort		; TCPRemotePort
	jne	d10,d15,_263
;  451 |      
;  452 |      if (TCPCode & TCP_CODE_ACK)                // ACK field significant?
	.symb	LINE, 452
	and	d15,d11,#16
	jeq	d15,#0,_209
;  453 |        if (TCPSegAck != TCPUNASeqNr)            // is our ISN ACKed?
	.symb	LINE, 453
	ld.w	d7,TCPUNASeqNr			; TCPUNASeqNr
	jeq	d12,d7,_209
;  454 |        {
;  455 |          if (!(TCPCode & TCP_CODE_RST))
	.symb	LINE, 455
	jnz.t	d11:2,_263
;  456 |          {
;  457 |            TCPSeqNr = TCPSegAck;
	.symb	LINE, 457
_207:
	mov16	d4,#4				; 4
	st.w	TCPSeqNr,d12			; TCPSeqNr
;  458 |            PrepareTCP_FRAME(TCP_CODE_RST);
	.symb	LINE, 458
	jg	PrepareTCP_FRAME
;  459 |          }
;  460 |          break;                                 // drop segment
;  461 |        }
;  462 |
;  463 |      if (TCPCode & TCP_CODE_RST)                // RST??
	.symb	LINE, 463
_209:
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	jz.t	d11:2,_210
;  464 |      {
;  465 |        if (TCPCode & TCP_CODE_ACK)              // if ACK was acceptable, reset
	.symb	LINE, 465
	jeq	d15,#0,_263
;  466 |        {                                        // connection
;  467 |          TCPStateMachine = CLOSED;
	.symb	LINE, 467
	j	_214
;  468 |          TCPFlags = 0;                          // reset all flags, stop retransmission...
;  469 |          SocketStatus = SOCK_ERR_CONN_RESET;
;  470 |        }
;  471 |        break;                                   // drop segment
;  472 |      }
	.symb	LINE, 472
_210:
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
;  473 |        
;  474 |      if (TCPCode & TCP_CODE_SYN)                // SYN??
	.symb	LINE, 474
	jz.t	d11:1,_263
;  475 |      {
;  476 |        TCPAckNr = TCPSegSeq;                    // get opponents ISN
;  477 |        TCPAckNr++;                              // inc. by one...
	.symb	LINE, 477
	add16	d13,#1				; TCPAckNr
	st.w	TCPAckNr,d13			; TCPAckNr
;  478 |
;  479 |        if (TCPCode & TCP_CODE_ACK)
	.symb	LINE, 479
	jeq	d15,#0,_211
;  480 |        {
;  481 |          TCPStopTimer();                        // stop retransmission, other TCP got our SYN
	.symb	LINE, 481
	callg	TCPStopTimer
	mov	d4,#16				; 16
;  482 |          TCPSeqNr = TCPUNASeqNr;                // advance our sequence number
	.symb	LINE, 482
	ld.w	d15,TCPUNASeqNr			; TCPUNASeqNr
	st.w	TCPSeqNr,d15			; TCPSeqNr
;  483 |
;  484 |          PrepareTCP_FRAME(TCP_CODE_ACK);        // ACK this ISN
	.symb	LINE, 484
	callg	PrepareTCP_FRAME
	mov16	d7,#4				; TCPStateMachine
	ld.bu	d15,SocketStatus		; SocketStatus
	or	d15,d15,#2			; $SocketStatus
;  485 |          TCPStateMachine = ESTABLISHED;
	.symb	LINE, 485
	st.b	TCPStateMachine,d7		; TCPStateMachine
;  486 |          SocketStatus |= SOCK_CONNECTED;
;  487 |          SocketStatus |= SOCK_TX_BUF_RELEASED;  // user may send data now :-)
	.symb	LINE, 487
	or	d15,d15,#8			; $SocketStatus
	extr.u	d15,d15,#0,#8			; $SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  488 |        }
	.symb	LINE, 488
	ret16
_211:
;  489 |        else
;  490 |        {
;  491 |          TCPStopTimer();
	.symb	LINE, 491
	callg	TCPStopTimer
;  492 |          PrepareTCP_FRAME(TCP_CODE_SYN | TCP_CODE_ACK);   // our SYN isn't ACKed yet,
	.symb	LINE, 492
_212:
	mov	d4,#18				; 18
	callg	PrepareTCP_FRAME
;  493 |          LastFrameSent = TCP_SYN_ACK_FRAME;               // now continue with sending
	.symb	LINE, 493
	mov16	d15,#2				; LastFrameSent
	st.b	LastFrameSent,d15		; LastFrameSent
;  494 |          TCPStartRetryTimer();                            // SYN_ACK frames
	.symb	LINE, 494
	callg	TCPStartRetryTimer
;  495 |          TCPStateMachine = SYN_RECD;
	.symb	LINE, 495
	mov16	d15,#3				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  496 |        }
;  497 |      }
;  498 |      break;
	.symb	LINE, 498
	ret16
;  499 |    }
;  500 |    default :
	.symb	LINE, 500
_213:
	.symb	LTIM, "TCPSegSeq", 13, 0, 0xcd
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0xcd
	mov16	d4,#4				; 4
;  501 |    {
;  502 |      if (memcmp(&RemoteIP, &RecdFrameIP, 4)) break;  // drop segment if IP doesn't belong
	.symb	LINE, 502
	movh.a	a4,#@his(RemoteIP)
	lea	a4,[a4]@los(RemoteIP)
	movh.a	a5,#@his(RecdFrameIP)
	lea	a5,[a5]@los(RecdFrameIP)
	callg	memcmp
	jne	d2,#0,_263
;  503 |                                                      // to current session
;  504 |
;  505 |      if (TCPSegSourcePort != TCPRemotePort) break;   // drop segment if port doesn't match
	.symb	LINE, 505
	ld.hu	d15,TCPRemotePort		; TCPRemotePort
	jne	d10,d15,_263
;  506 |
;  507 |      if (TCPSegSeq != TCPAckNr) break;               // drop if it's not the segment we expect
	.symb	LINE, 507
	ld.w	d15,TCPAckNr			; TCPAckNr
	jne	d13,d15,_263
;  508 |            
;  509 |      if (TCPCode & TCP_CODE_RST)                // RST??
	.symb	LINE, 509
	jz.t	d11:2,_215
;  510 |      {
;  511 |        TCPStateMachine = CLOSED;                // close the state machine
	.symb	LINE, 511
_214:
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  512 |        TCPFlags = 0;                            // reset all flags, stop retransmission...
	.symb	LINE, 512
	st.b	TCPFlags,d15			; TCPFlags
;  513 |        SocketStatus = SOCK_ERR_CONN_RESET;      // indicate an error to user
	.symb	LINE, 513
	mov16	d15,#48				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  514 |        break;
	.symb	LINE, 514
	ret16
;  515 |      }
	.symb	LINE, 515
_215:
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0x4d
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0xcd
;  516 |
;  517 |      if (TCPCode & TCP_CODE_SYN)                // SYN??
	.symb	LINE, 517
	jz.t	d11:1,_216
;  518 |      {
;  519 |        PrepareTCP_FRAME(TCP_CODE_RST);          // is NOT allowed here! send a reset,
	.symb	LINE, 519
	mov16	d4,#4				; 4
	callg	PrepareTCP_FRAME
;  520 |        TCPStateMachine = CLOSED;                // close connection...
	.symb	LINE, 520
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  521 |        TCPFlags = 0;                            // reset all flags, stop retransmission...
	.symb	LINE, 521
	st.b	TCPFlags,d15			; TCPFlags
;  522 |        SocketStatus = SOCK_ERR_REMOTE;          // fatal error!
	.symb	LINE, 522
	mov16	d15,#64				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  523 |        break;                                   // ...and drop the frame
	.symb	LINE, 523
	ret16
;  524 |      }
	.symb	LINE, 524
_216:
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0xcd
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0x4d
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0xcd
;  525 |
;  526 |      if (!(TCPCode & TCP_CODE_ACK)) break;      // drop segment if the ACK bit is off
	.symb	LINE, 526
	jz.t	d11:4,_263
;  527 |
;  528 |      if (TCPSegAck == TCPUNASeqNr)              // is our last data sent ACKed?
	.symb	LINE, 528
	ld.w	d15,TCPUNASeqNr			; TCPUNASeqNr
	jne	d12,d15,_228
;  529 |      {
;  530 |        TCPStopTimer();                          // stop retransmission
	.symb	LINE, 530
	callg	TCPStopTimer
;  531 |        TCPSeqNr = TCPUNASeqNr;                  // advance our sequence number
	.symb	LINE, 531
	ld.w	d15,TCPUNASeqNr			; TCPUNASeqNr
	st.w	TCPSeqNr,d15			; TCPSeqNr
;  532 |
;  533 |        switch (TCPStateMachine)                 // change state if necessary
	.symb	LINE, 533
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#3,_217			; case 3
	jeq	d15,#5,_218			; case 5
	add16	d15,#-8
	jeq	d15,#0,_219			; case 8
	jeq	d15,#1,_220			; case 9
	jeq	d15,#2,_221			; case 10
	j	_226				; default
;  534 |        {
;  535 |          case SYN_RECD :                        // ACK of our SYN?
	.symb	LINE, 535
_217:
;  536 |          {
;  537 |            TCPStateMachine = ESTABLISHED;       // user may send data now :-)
	.symb	LINE, 537
	mov16	d15,#4				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  538 |            SocketStatus |= SOCK_CONNECTED;
	.symb	LINE, 538
	ld.bu	d15,SocketStatus		; SocketStatus
	or	d15,d15,#2			; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  539 |            break;
	.symb	LINE, 539
	j	_226
;  540 |          }
;  541 |          case FIN_WAIT_1 : { TCPStateMachine = FIN_WAIT_2; break; } // ACK of our FIN?
	.symb	LINE, 541
_218:
	mov16	d15,#6				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
	j	_226
;  542 |          case CLOSING :    { TCPStateMachine = TIME_WAIT; break; }  // ACK of our FIN?
	.symb	LINE, 542
_219:
	mov16	d15,#10				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
	j	_226
;  543 |          case LAST_ACK :                                            // ACK of our FIN?
	.symb	LINE, 543
_220:
;  544 |          {
;  545 |            TCPStateMachine = CLOSED;
	.symb	LINE, 545
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  546 |            TCPFlags = 0;                        // reset all flags, stop retransmission...
	.symb	LINE, 546
	st.b	TCPFlags,d15			; TCPFlags
;  547 |            SocketStatus &= SOCK_DATA_AVAILABLE; // clear all flags but data available
	.symb	LINE, 547
	ld.bu	d15,SocketStatus		; SocketStatus
	and	d15,d15,#4			; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  548 |            break;
	.symb	LINE, 548
	j	_226
;  549 |          }
;  550 |          case TIME_WAIT :
	.symb	LINE, 550
_221:
;  551 |          {
;  552 |            PrepareTCP_FRAME(TCP_CODE_ACK);      // ACK a retransmission of remote FIN
	.symb	LINE, 552
	mov	d4,#16				; 16
	callg	PrepareTCP_FRAME
;  553 |            TCPRestartTimer();                   // restart TIME_WAIT timeout
	.symb	LINE, 553
	callg	TCPRestartTimer
;  554 |            break;
;  555 |          }
;  556 |        }
	.symb	LINE, 556
_226:
;  557 |        
;  558 |        if (TCPStateMachine == ESTABLISHED)      // if true, give the frame buffer back
	.symb	LINE, 558
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jne	d15,#4,_228
;  559 |          SocketStatus |= SOCK_TX_BUF_RELEASED;  // to user
	.symb	LINE, 559
	ld.bu	d15,SocketStatus		; SocketStatus
	or	d15,d15,#8			; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  560 |      }
	.symb	LINE, 560
_228:
;  561 |
;  562 |      if ((TCPStateMachine == ESTABLISHED) || (TCPStateMachine == FIN_WAIT_1) || (TCPStateMachine == FIN_WAIT_2))
	.symb	LINE, 562
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#4,_230
	jeq	d15,#5,_230
	jne	d15,#6,_233
_230:
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0x4d
	.symb	LTIM, "NrOfDataBytes", 4, 0, 0xcd
	.symb	LTIM, "NrOfDataBytes", 4, 0, 0x4d
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0xcd
;  563 |        if (NrOfDataBytes)                                 // data available?
	.symb	LINE, 563
	jeq	d14,#0,_233			; NrOfDataBytes
;  564 |          if (!(SocketStatus & SOCK_DATA_AVAILABLE))       // rx data-buffer empty?
	.symb	LINE, 564
	ld.bu	d15,SocketStatus		; SocketStatus
	jnz.t	d15:2,_233
;  565 |          {
;  566 |            DummyReadFrame8900(6);                         // ignore window, checksum, urgent pointer
	.symb	LINE, 566
	mov16	d4,#6				; 6
	callg	DummyReadFrame8900
	mov16	d4,d14				; NrOfDataBytes
;  567 |            CopyFromFrame8900(&RxTCPBuffer, NrOfDataBytes);// fetch data and
	.symb	LINE, 567
	movh.a	a4,#@his(RxTCPBuffer)
	lea	a4,[a4]@los(RxTCPBuffer)
	callg	CopyFromFrame8900
	mov	d4,#16				; 16
;  568 |            TCPRxDataCount = NrOfDataBytes;                // ...tell the user...
	.symb	LINE, 568
	st.h	TCPRxDataCount,d14		; TCPRxDataCount
;  569 |            SocketStatus |= SOCK_DATA_AVAILABLE;           // indicate the new data to user
	.symb	LINE, 569
	ld.bu	d15,SocketStatus		; SocketStatus
	or	d15,d15,#4			; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  570 |            TCPAckNr += NrOfDataBytes;
	.symb	LINE, 570
	ld.w	d15,TCPAckNr			; TCPAckNr
	add16	d15,d14				; TCPAckNr
	st.w	TCPAckNr,d15			; TCPAckNr
;  571 |            PrepareTCP_FRAME(TCP_CODE_ACK);                // ACK rec'd data
	.symb	LINE, 571
	callg	PrepareTCP_FRAME
;  572 |          }
;  573 |              
;  574 |      if (TCPCode & TCP_CODE_FIN)                // FIN??
	.symb	LINE, 574
_233:
	jz.t	d11:0,_263
;  575 |      {
;  576 |        switch (TCPStateMachine)
	.symb	LINE, 576
	ld.b	d15,TCPStateMachine		; TCPStateMachine
	jeq	d15,#3,_235			; case 3
	jeq	d15,#4,_235			; case 4
	jeq	d15,#5,_236			; case 5
	jeq	d15,#6,_237			; case 6
	add16	d15,#-8
	jeq	d15,#2,_239			; case 10
	j	_242				; default
;  577 |        {
;  578 |          case SYN_RECD :
;  579 |          case ESTABLISHED :
	.symb	LINE, 579
_235:
;  580 |          {
;  581 |            TCPStateMachine = CLOSE_WAIT;
	.symb	LINE, 581
	mov16	d15,#7				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  582 |            break;
	.symb	LINE, 582
	j	_242
;  583 |          }
;  584 |          case FIN_WAIT_1 :
	.symb	LINE, 584
_236:
;  585 |          {                                      // if our FIN was ACKed, we automatically
;  586 |            TCPStateMachine = CLOSING;           // enter FIN_WAIT_2 (look above) and therefore
	.symb	LINE, 586
	mov16	d15,#8				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  587 |            SocketStatus &= ~SOCK_CONNECTED;     // TIME_WAIT
	.symb	LINE, 587
	j	_238
;  588 |            break;
;  589 |          }
;  590 |          case FIN_WAIT_2 :
	.symb	LINE, 590
_237:
;  591 |          {
;  592 |            TCPStartTimeWaitTimer();
	.symb	LINE, 592
	callg	TCPStartTimeWaitTimer
;  593 |            TCPStateMachine = TIME_WAIT;
	.symb	LINE, 593
	mov16	d15,#10				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  594 |            SocketStatus &= ~SOCK_CONNECTED;            
	.symb	LINE, 594
_238:
	mov16	d7,#-3				; -3
	ld.bu	d15,SocketStatus		; SocketStatus
	and16	d15,d7				; SocketStatus
	st.b	SocketStatus,d15		; SocketStatus
;  595 |            break;
	.symb	LINE, 595
	j	_242
;  596 |          }
;  597 |          case TIME_WAIT :
	.symb	LINE, 597
_239:
;  598 |          {
;  599 |            TCPRestartTimer();
	.symb	LINE, 599
	callg	TCPRestartTimer
;  600 |            break;
;  601 |          }
;  602 |        }
	.symb	LINE, 602
_242:
	mov	d4,#16				; 16
;  603 |        TCPAckNr++;                              // ACK remote's FIN flag
	.symb	LINE, 603
	ld.w	d15,TCPAckNr			; TCPAckNr
	add16	d15,#1				; TCPAckNr
	st.w	TCPAckNr,d15			; TCPAckNr
;  604 |        PrepareTCP_FRAME(TCP_CODE_ACK);
	.symb	LINE, 604
	callg	PrepareTCP_FRAME
;  605 |      }
;  606 |    }
;  607 |  }
;  608 |}
	.symb	LINE, 608
_263:
	ret16
	.symb	LTIM, "NrOfDataBytes", 14, 0, 0x4d
	.symb	LTIM, "TCPSegAck", 12, 0, 0x4d
	.symb	LTIM, "TCPSegSeq", 13, 0, 0x4d
	.symb	EFUN
;  609 |
;  610 |// easyWEB internal function
;  611 |// prepares the TxFrame2-buffer to send an ARP-request
;  612 |
;  613 |void PrepareARP_REQUEST(void)
;  614 |{
	.symb	LINE, 614
	.symb	TYPE, 277, 'X', 8, #1, 26, 0
	.symb	GFUN, "PrepareARP_REQUEST", PrepareARP_REQUEST, #277, 0, 0, 0
	.symb	ALAB, PrepareARP_REQUEST, #277
PrepareARP_REQUEST:
	mov	d4,#255				; 255
	.symb	SOFF, 0
	mov16	d5,#6				; 6
;  615 |  // Ethernet
;  616 |  memset(&TxFrame2[ETH_DA_OFS], 0xFF, 6);                  // we don't know opposites MAC!
	.symb	LINE, 616
	movh.a	a4,#@his(TxFrame2)
	lea	a4,[a4]@los(TxFrame2)
	callg	memset
	mov16	d4,#6				; 6
;  617 |  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
	.symb	LINE, 617
	movh.a	a4,#@his(TxFrame2+6)
	lea	a4,[a4]@los(TxFrame2+6)
	movh.a	a14,#@his(MyMAC)
	lea	a14,[a14]@los(MyMAC)
	mov16.aa a5,a14
	callg	memcpy
;  618 |  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_ARP);
	.symb	LINE, 618
	mov	d15,#1544
	mov	d7,#8
	movh.a	a15,#@his(TxFrame2+12)
	lea	a15,[a15]@los(TxFrame2+12)
	st16.h	[a15],d15
;  619 |
;  620 |  // ARP
;  621 |  *(unsigned short *)&TxFrame2[ARP_HARDW_OFS] = SWAPB(HARDW_ETH10);
	.symb	LINE, 621
	mov	d15,#256			; 256
	movh.a	a15,#@his(TxFrame2+14)
	lea	a15,[a15]@los(TxFrame2+14)
	st16.h	[a15],d15			; 256
;  622 |  *(unsigned short *)&TxFrame2[ARP_PROT_OFS] = SWAPB(FRAME_IP);
	.symb	LINE, 622
	movh.a	a15,#@his(TxFrame2+16)
	lea	a15,[a15]@los(TxFrame2+16)
	st16.h	[a15],d7
;  623 |  *(unsigned short *)&TxFrame2[ARP_HLEN_PLEN_OFS] = SWAPB(IP_HLEN_PLEN);
	.symb	LINE, 623
	mov	d7,#1030
	movh.a	a15,#@his(TxFrame2+18)
	mov16	d4,#6				; 6
	lea	a15,[a15]@los(TxFrame2+18)
	st16.h	[a15],d7
;  624 |  *(unsigned short *)&TxFrame2[ARP_OPCODE_OFS] = SWAPB(OP_ARP_REQUEST);
	.symb	LINE, 624
	movh.a	a15,#@his(TxFrame2+20)
	lea	a15,[a15]@los(TxFrame2+20)
	st16.h	[a15],d15			; 256
;  625 |  memcpy(&TxFrame2[ARP_SENDER_HA_OFS], &MyMAC, 6);
	.symb	LINE, 625
	movh.a	a4,#@his(TxFrame2+22)
	lea	a4,[a4]@los(TxFrame2+22)
	mov16.aa a5,a14
	callg	memcpy
	mov16	d4,#4				; 4
;  626 |  memcpy(&TxFrame2[ARP_SENDER_IP_OFS], &MyIP, 4);
	.symb	LINE, 626
	movh.a	a4,#@his(TxFrame2+28)
	lea	a4,[a4]@los(TxFrame2+28)
	movh.a	a5,#@his(MyIP)
	lea	a5,[a5]@los(MyIP)
	callg	memcpy
	mov16	d4,#0				; 0
	mov16	d5,#6				; 6
;  627 |  memset(&TxFrame2[ARP_TARGET_HA_OFS], 0x00, 6);           // we don't know opposites MAC!
	.symb	LINE, 627
	movh.a	a4,#@his(TxFrame2+32)
	lea	a4,[a4]@los(TxFrame2+32)
	callg	memset
;  628 |
;  629 |  if (((RemoteIP[0] ^ MyIP[0]) & SubnetMask[0]) || ((RemoteIP[1] ^ MyIP[1]) & SubnetMask[1]))
	.symb	LINE, 629
	movh.a	a15,#@his(RemoteIP)
	lea	a15,[a15]@los(RemoteIP)
	ld.hu	d15,[a15]
	movh.a	a15,#@his(MyIP)
	lea	a15,[a15]@los(MyIP)
	ld.hu	d7,[a15]
	xor16	d15,d7
	movh.a	a15,#@his(SubnetMask)
	lea	a15,[a15]@los(SubnetMask)
	ld.hu	d7,[a15]
	and16	d15,d7
	jne	d15,#0,_264
	movh.a	a15,#@his(RemoteIP+2)
	lea	a15,[a15]@los(RemoteIP+2)
	ld.hu	d15,[a15]
	movh.a	a15,#@his(MyIP+2)
	lea	a15,[a15]@los(MyIP+2)
	ld.hu	d7,[a15]
	xor16	d15,d7
	movh.a	a15,#@his(SubnetMask+2)
	lea	a15,[a15]@los(SubnetMask+2)
	ld.hu	d7,[a15]
	and16	d15,d7
	jeq	d15,#0,_265
_264:
	mov16	d4,#4				; 4
;  630 |    memcpy(&TxFrame2[ARP_TARGET_IP_OFS], &GatewayIP, 4);   // IP not in subnet, use gateway
	.symb	LINE, 630
	movh.a	a4,#@his(TxFrame2+38)
	lea	a4,[a4]@los(TxFrame2+38)
	movh.a	a5,#@his(GatewayIP)
	lea	a5,[a5]@los(GatewayIP)
	callg	memcpy
	j	_266
_265:
	mov16	d4,#4				; 4
;  631 |  else
;  632 |    memcpy(&TxFrame2[ARP_TARGET_IP_OFS], &RemoteIP, 4);    // other IP is next to us...
	.symb	LINE, 632
	movh.a	a4,#@his(TxFrame2+38)
	lea	a4,[a4]@los(TxFrame2+38)
	movh.a	a5,#@his(RemoteIP)
	lea	a5,[a5]@los(RemoteIP)
	callg	memcpy
_266:
;  633 |
;  634 |  TxFrame2Size = ETH_HEADER_SIZE + ARP_FRAME_SIZE;
	.symb	LINE, 634
	mov16	d15,#42				; TxFrame2Size
	st.b	TxFrame2Size,d15		; TxFrame2Size
;  635 |  TransmitControl |= SEND_FRAME2;
	.symb	LINE, 635
	ld.bu	d15,TransmitControl		; TransmitControl
	or	d15,d15,#2			; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  636 |}
	.symb	LINE, 636
	ret16
	.symb	EFUN
;  637 |
;  638 |// easyWEB internal function
;  639 |// prepares the TxFrame2-buffer to send an ARP-answer (reply)
;  640 |
;  641 |void PrepareARP_ANSWER(void)
;  642 |{
	.symb	LINE, 642
	.symb	TYPE, 278, 'X', 8, #1, 26, 0
	.symb	GFUN, "PrepareARP_ANSWER", PrepareARP_ANSWER, #278, 0, 0, 0
	.symb	ALAB, PrepareARP_ANSWER, #278
PrepareARP_ANSWER:
	mov16	d4,#6				; 6
	.symb	SOFF, 0
;  643 |  // Ethernet
;  644 |  memcpy(&TxFrame2[ETH_DA_OFS], &RecdFrameMAC, 6);
	.symb	LINE, 644
	movh.a	a4,#@his(TxFrame2)
	lea	a4,[a4]@los(TxFrame2)
	movh.a	a14,#@his(RecdFrameMAC)
	lea	a14,[a14]@los(RecdFrameMAC)
	mov16.aa a5,a14
	callg	memcpy
	mov16	d4,#6				; 6
;  645 |  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
	.symb	LINE, 645
	movh.a	a4,#@his(TxFrame2+6)
	lea	a4,[a4]@los(TxFrame2+6)
	movh.a	a13,#@his(MyMAC)
	lea	a13,[a13]@los(MyMAC)
	mov16.aa a5,a13
	callg	memcpy
;  646 |  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_ARP);
	.symb	LINE, 646
	mov	d15,#1544
	movh.a	a15,#@his(TxFrame2+12)
	lea	a15,[a15]@los(TxFrame2+12)
	st16.h	[a15],d15
;  647 |
;  648 |  // ARP
;  649 |  *(unsigned short *)&TxFrame2[ARP_HARDW_OFS] = SWAPB(HARDW_ETH10);
	.symb	LINE, 649
	mov	d15,#256
	movh.a	a15,#@his(TxFrame2+14)
	lea	a15,[a15]@los(TxFrame2+14)
	st16.h	[a15],d15
;  650 |  *(unsigned short *)&TxFrame2[ARP_PROT_OFS] = SWAPB(FRAME_IP);
	.symb	LINE, 650
	mov16	d15,#8
	movh.a	a15,#@his(TxFrame2+16)
	lea	a15,[a15]@los(TxFrame2+16)
	st16.h	[a15],d15
;  651 |  *(unsigned short *)&TxFrame2[ARP_HLEN_PLEN_OFS] = SWAPB(IP_HLEN_PLEN);
	.symb	LINE, 651
	mov	d15,#1030
	movh.a	a15,#@his(TxFrame2+18)
	mov16	d4,#6				; 6
	lea	a15,[a15]@los(TxFrame2+18)
	st16.h	[a15],d15
;  652 |  *(unsigned short *)&TxFrame2[ARP_OPCODE_OFS] = SWAPB(OP_ARP_ANSWER);
	.symb	LINE, 652
	mov	d15,#512
	movh.a	a15,#@his(TxFrame2+20)
	lea	a15,[a15]@los(TxFrame2+20)
	st16.h	[a15],d15
;  653 |  memcpy(&TxFrame2[ARP_SENDER_HA_OFS], &MyMAC, 6);
	.symb	LINE, 653
	movh.a	a4,#@his(TxFrame2+22)
	lea	a4,[a4]@los(TxFrame2+22)
	mov16.aa a5,a13
	callg	memcpy
	mov16	d4,#4				; 4
;  654 |  memcpy(&TxFrame2[ARP_SENDER_IP_OFS], &MyIP, 4);
	.symb	LINE, 654
	movh.a	a4,#@his(TxFrame2+28)
	lea	a4,[a4]@los(TxFrame2+28)
	movh.a	a5,#@his(MyIP)
	lea	a5,[a5]@los(MyIP)
	callg	memcpy
	mov16	d4,#6				; 6
;  655 |  memcpy(&TxFrame2[ARP_TARGET_HA_OFS], &RecdFrameMAC, 6);
	.symb	LINE, 655
	movh.a	a4,#@his(TxFrame2+32)
	lea	a4,[a4]@los(TxFrame2+32)
	mov16.aa a5,a14
	callg	memcpy
	mov16	d4,#4				; 4
;  656 |  memcpy(&TxFrame2[ARP_TARGET_IP_OFS], &RecdFrameIP, 4);
	.symb	LINE, 656
	movh.a	a4,#@his(TxFrame2+38)
	lea	a4,[a4]@los(TxFrame2+38)
	movh.a	a5,#@his(RecdFrameIP)
	lea	a5,[a5]@los(RecdFrameIP)
	callg	memcpy
;  657 |
;  658 |  TxFrame2Size = ETH_HEADER_SIZE + ARP_FRAME_SIZE;
	.symb	LINE, 658
	mov16	d15,#42				; TxFrame2Size
	st.b	TxFrame2Size,d15		; TxFrame2Size
;  659 |  TransmitControl |= SEND_FRAME2;
	.symb	LINE, 659
	ld.bu	d15,TransmitControl		; TransmitControl
	or	d15,d15,#2			; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  660 |}
	.symb	LINE, 660
	ret16
	.symb	EFUN
;  661 |
;  662 |// easyWEB internal function
;  663 |// prepares the TxFrame2-buffer to send an ICMP-echo-reply
;  664 |
;  665 |void PrepareICMP_ECHO_REPLY(void)
;  666 |{
	.symb	LINE, 666
	.symb	TYPE, 279, 'X', 8, #1, 26, 0
	.symb	GFUN, "PrepareICMP_ECHO_REPLY", PrepareICMP_ECHO_REPLY, #279, 0, 0, 0
	.symb	ALAB, PrepareICMP_ECHO_REPLY, #279
PrepareICMP_ECHO_REPLY:
	.symb	IDEN, "ICMPDataCount", -1, #5, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "ICMPDataCount", -1, 0, 0x45
	.symb	LTIM, "ICMPDataCount", 14, 0, 0xcd
;  667 |  unsigned short ICMPDataCount;
;  668 |
;  669 |  if (RecdIPFrameLength > MAX_ETH_TX_DATA_SIZE)                      // don't overload TX-buffer
	.symb	LINE, 669
	ld.hu	d15,RecdIPFrameLength		; RecdIPFrameLength
	ge	d7,d15,#61
	jeq	d7,#0,_267
;  670 |    ICMPDataCount = MAX_ETH_TX_DATA_SIZE - IP_HEADER_SIZE - ICMP_HEADER_SIZE;
	.symb	LINE, 670
	mov	d14,#36				; 36
	j	_268
_267:
	.symb	LTIM, "ICMPDataCount", 14, 0, 0x4d
	.symb	LTIM, "ICMPDataCount", 14, 0, 0xcd
;  671 |  else
;  672 |    ICMPDataCount = RecdIPFrameLength - IP_HEADER_SIZE - ICMP_HEADER_SIZE;
	.symb	LINE, 672
	addi	d14,d15,#-24
	extr.u	d14,d14,#0,#16			; ICMPDataCount
_268:
	.symb	LTIM, "ICMPDataCount", 14, 0, 0x4d
	.symb	LTIM, "ICMPDataCount", 4, 0, 0xcd
	.symb	LTIM, "ICMPDataCount", 4, 0, 0x4d
	.symb	LTIM, "ICMPDataCount", 14, 0, 0xcd
	.symb	LTIM, "ICMPDataCount", 14, 0, 0x4d
	mov16	d4,#6				; 6
;  673 |
;  674 |  // Ethernet
;  675 |  memcpy(&TxFrame2[ETH_DA_OFS], &RecdFrameMAC, 6);
	.symb	LINE, 675
	movh.a	a4,#@his(TxFrame2)
	lea	a4,[a4]@los(TxFrame2)
	movh.a	a5,#@his(RecdFrameMAC)
	lea	a5,[a5]@los(RecdFrameMAC)
	callg	memcpy
	mov16	d4,#6				; 6
;  676 |  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
	.symb	LINE, 676
	movh.a	a4,#@his(TxFrame2+6)
	lea	a4,[a4]@los(TxFrame2+6)
	movh.a	a5,#@his(MyMAC)
	lea	a5,[a5]@los(MyMAC)
	callg	memcpy
;  677 |  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_IP);
	.symb	LINE, 677
	mov16	d15,#8
	addi	d4,d14,#24
	movh.a	a15,#@his(TxFrame2+12)
	extr.u	d4,d4,#0,#16
	lea	a15,[a15]@los(TxFrame2+12)
	st16.h	[a15],d15
;  678 |  
;  679 |  // IP   
;  680 |  *(unsigned short *)&TxFrame2[IP_VER_IHL_TOS_OFS] = SWAPB(IP_VER_IHL);
	.symb	LINE, 680
	mov16	d15,#69
	movh.a	a15,#@his(TxFrame2+14)
	lea	a15,[a15]@los(TxFrame2+14)
	st16.h	[a15],d15
;  681 |  WriteWBE(&TxFrame2[IP_TOTAL_LENGTH_OFS], IP_HEADER_SIZE + ICMP_HEADER_SIZE + ICMPDataCount);
	.symb	LINE, 681
	movh.a	a4,#@his(TxFrame2+16)
	lea	a4,[a4]@los(TxFrame2+16)
	callg	WriteWBE
;  682 |  *(unsigned short *)&TxFrame2[IP_IDENT_OFS] = 0;
	.symb	LINE, 682
	mov16	d13,#0				; 0
	mov	d15,#320
	movh.a	a15,#@his(TxFrame2+18)
	lea	a15,[a15]@los(TxFrame2+18)
	st16.h	[a15],d13			; 0
;  683 |  *(unsigned short *)&TxFrame2[IP_FLAGS_FRAG_OFS] = 0;
	.symb	LINE, 683
	movh.a	a15,#@his(TxFrame2+20)
	lea	a15,[a15]@los(TxFrame2+20)
	st16.h	[a15],d13			; 0
;  684 |  *(unsigned short *)&TxFrame2[IP_TTL_PROT_OFS] = SWAPB((DEFAULT_TTL << 8) | PROT_ICMP);
	.symb	LINE, 684
	movh.a	a15,#@his(TxFrame2+22)
	mov16	d4,#4				; 4
	lea	a15,[a15]@los(TxFrame2+22)
	st16.h	[a15],d15
;  685 |  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = 0;
	.symb	LINE, 685
	movh.a	a15,#@his(TxFrame2+24)
	lea	a15,[a15]@los(TxFrame2+24)
	st16.h	[a15],d13			; 0
;  686 |  memcpy(&TxFrame2[IP_SOURCE_OFS], &MyIP, 4);
	.symb	LINE, 686
	movh.a	a4,#@his(TxFrame2+26)
	lea	a4,[a4]@los(TxFrame2+26)
	movh.a	a5,#@his(MyIP)
	lea	a5,[a5]@los(MyIP)
	callg	memcpy
	mov16	d4,#4				; 4
;  687 |  memcpy(&TxFrame2[IP_DESTINATION_OFS], &RecdFrameIP, 4);
	.symb	LINE, 687
	movh.a	a4,#@his(TxFrame2+30)
	lea	a4,[a4]@los(TxFrame2+30)
	movh.a	a5,#@his(RecdFrameIP)
	lea	a5,[a5]@los(RecdFrameIP)
	callg	memcpy
	mov	d4,#20				; 20
	mov16	d5,#0				; 0
;  688 |  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = CalcChecksum(&TxFrame2[IP_VER_IHL_TOS_OFS], IP_HEADER_SIZE, 0);
	.symb	LINE, 688
	movh.a	a4,#@his(TxFrame2+14)
	lea	a4,[a4]@los(TxFrame2+14)
	callg	CalcChecksum
	movh.a	a15,#@his(TxFrame2+24)
	lea	a15,[a15]@los(TxFrame2+24)
	mov16	d4,d14				; ICMPDataCount
	st16.h	[a15],d2
;  689 |
;  690 |  // ICMP
;  691 |  *(unsigned short *)&TxFrame2[ICMP_TYPE_CODE_OFS] = SWAPB(ICMP_ECHO_REPLY << 8);
	.symb	LINE, 691
	movh.a	a15,#@his(TxFrame2+34)
	lea	a15,[a15]@los(TxFrame2+34)
	st16.h	[a15],d13			; 0
;  692 |  *(unsigned short *)&TxFrame2[ICMP_CHKSUM_OFS] = 0;                   // initialize checksum field
	.symb	LINE, 692
	movh.a	a15,#@his(TxFrame2+36)
	lea	a15,[a15]@los(TxFrame2+36)
	st16.h	[a15],d13			; 0
;  693 |
;  694 |  CopyFromFrame8900(&TxFrame2[ICMP_DATA_OFS], ICMPDataCount);        // get data to echo...
	.symb	LINE, 694
	movh.a	a4,#@his(TxFrame2+38)
	lea	a4,[a4]@los(TxFrame2+38)
	callg	CopyFromFrame8900
	addi	d4,d14,#4
	mov16	d5,#0				; 0
;  695 |  *(unsigned short *)&TxFrame2[ICMP_CHKSUM_OFS] = CalcChecksum(&TxFrame2[IP_DATA_OFS], ICMPDataCount + ICMP_HEADER_SIZE, 0);
	.symb	LINE, 695
	movh.a	a4,#@his(TxFrame2+34)
	extr.u	d4,d4,#0,#16
	lea	a4,[a4]@los(TxFrame2+34)
	callg	CalcChecksum
	addi	d14,d14,#38
	movh.a	a15,#@his(TxFrame2+36)
	lea	a15,[a15]@los(TxFrame2+36)
	st16.h	[a15],d2
;  696 |
;  697 |  TxFrame2Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + ICMP_HEADER_SIZE + ICMPDataCount;
	.symb	LINE, 697
	st.b	TxFrame2Size,d14		; TxFrame2Size
;  698 |  TransmitControl |= SEND_FRAME2;
	.symb	LINE, 698
	ld.bu	d15,TransmitControl		; TransmitControl
	or	d15,d15,#2			; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  699 |}
	.symb	LINE, 699
	ret16
	.symb	EFUN
;  700 |
;  701 |// easyWEB internal function
;  702 |// prepares the TxFrame2-buffer to send a general TCP frame
;  703 |// the TCPCode-field is passed as an argument
;  704 |
;  705 |void PrepareTCP_FRAME(unsigned short TCPCode)
;  706 |{
	.symb	LINE, 706
	.symb	TYPE, 280, 'X', 8, #1, 26, 1, #5
	.symb	GFUN, "PrepareTCP_FRAME", PrepareTCP_FRAME, #280, 0, 0, 0
	.symb	ALAB, PrepareTCP_FRAME, #280
PrepareTCP_FRAME:
	.symb	IDEN, "TCPCode", 12, #5, 0, 0x80d
	.symb	SOFF, 0
	.symb	LTIM, "TCPCode", 4, 0, 0x8cd
	.symb	LTIM, "TCPCode", 4, 0, 0x84d
	.symb	LTIM, "TCPCode", 12, 0, 0x8cd
	mov16	d12,d4				; TCPCode
;  707 |  // Ethernet
;  708 |  memcpy(&TxFrame2[ETH_DA_OFS], &RemoteMAC, 6);
	.symb	LINE, 708
	movh.a	a4,#@his(TxFrame2)
	mov16	d4,#6				; 6
	lea	a4,[a4]@los(TxFrame2)
	movh.a	a5,#@his(RemoteMAC)
	lea	a5,[a5]@los(RemoteMAC)
	callg	memcpy
	mov16	d4,#6				; 6
;  709 |  memcpy(&TxFrame2[ETH_SA_OFS], &MyMAC, 6);
	.symb	LINE, 709
	movh.a	a4,#@his(TxFrame2+6)
	lea	a4,[a4]@los(TxFrame2+6)
	movh.a	a5,#@his(MyMAC)
	lea	a5,[a5]@los(MyMAC)
	callg	memcpy
;  710 |  *(unsigned short *)&TxFrame2[ETH_TYPE_OFS] = SWAPB(FRAME_IP);
	.symb	LINE, 710
	mov16	d15,#8
	and	d14,d12,#2
	movh.a	a15,#@his(TxFrame2+12)
	lea	a15,[a15]@los(TxFrame2+12)
	st16.h	[a15],d15
;  711 |  
;  712 |  // IP   
;  713 |  *(unsigned short *)&TxFrame2[IP_VER_IHL_TOS_OFS] = SWAPB(IP_VER_IHL | IP_TOS_D);
	.symb	LINE, 713
	mov	d15,#4165
	movh.a	a15,#@his(TxFrame2+14)
	lea	a15,[a15]@los(TxFrame2+14)
	st16.h	[a15],d15
;  714 |
;  715 |  if (TCPCode & TCP_CODE_SYN)                    // if SYN, we want to use the MSS option
	.symb	LINE, 715
	jeq	d14,#0,_269
;  716 |    *(unsigned short *)&TxFrame2[IP_TOTAL_LENGTH_OFS] = SWAPB(IP_HEADER_SIZE + TCP_HEADER_SIZE + TCP_OPT_MSS_SIZE);
	.symb	LINE, 716
	mov	d15,#11264
	movh.a	a15,#@his(TxFrame2+16)
	lea	a15,[a15]@los(TxFrame2+16)
	st16.h	[a15],d15
	j	_270
_269:
;  717 |  else
;  718 |    *(unsigned short *)&TxFrame2[IP_TOTAL_LENGTH_OFS] = SWAPB(IP_HEADER_SIZE + TCP_HEADER_SIZE);
	.symb	LINE, 718
	mov	d15,#10240
	movh.a	a15,#@his(TxFrame2+16)
	lea	a15,[a15]@los(TxFrame2+16)
	st16.h	[a15],d15
_270:
;  719 |    
;  720 |  *(unsigned short *)&TxFrame2[IP_IDENT_OFS] = 0;
	.symb	LINE, 720
	mov16	d13,#0				; 0
	movh.a	a15,#@his(TxFrame2+18)
	mov	d15,#1600
	lea	a15,[a15]@los(TxFrame2+18)
	st16.h	[a15],d13			; 0
;  721 |  *(unsigned short *)&TxFrame2[IP_FLAGS_FRAG_OFS] = 0;
	.symb	LINE, 721
	movh.a	a15,#@his(TxFrame2+20)
	lea	a15,[a15]@los(TxFrame2+20)
	st16.h	[a15],d13			; 0
;  722 |  *(unsigned short *)&TxFrame2[IP_TTL_PROT_OFS] = SWAPB((DEFAULT_TTL << 8) | PROT_TCP);
	.symb	LINE, 722
	movh.a	a15,#@his(TxFrame2+22)
	mov16	d4,#4				; 4
	lea	a15,[a15]@los(TxFrame2+22)
	st16.h	[a15],d15
;  723 |  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = 0;
	.symb	LINE, 723
	movh.a	a15,#@his(TxFrame2+24)
	lea	a15,[a15]@los(TxFrame2+24)
	st16.h	[a15],d13			; 0
;  724 |  memcpy(&TxFrame2[IP_SOURCE_OFS], &MyIP, 4);
	.symb	LINE, 724
	movh.a	a4,#@his(TxFrame2+26)
	lea	a4,[a4]@los(TxFrame2+26)
	movh.a	a5,#@his(MyIP)
	lea	a5,[a5]@los(MyIP)
	callg	memcpy
	mov16	d4,#4				; 4
;  725 |  memcpy(&TxFrame2[IP_DESTINATION_OFS], &RemoteIP, 4);
	.symb	LINE, 725
	movh.a	a4,#@his(TxFrame2+30)
	lea	a4,[a4]@los(TxFrame2+30)
	movh.a	a5,#@his(RemoteIP)
	lea	a5,[a5]@los(RemoteIP)
	callg	memcpy
	mov	d4,#20				; 20
	mov16	d5,#0				; 0
;  726 |  *(unsigned short *)&TxFrame2[IP_HEAD_CHKSUM_OFS] = CalcChecksum(&TxFrame2[IP_VER_IHL_TOS_OFS], IP_HEADER_SIZE, 0);
	.symb	LINE, 726
	movh.a	a4,#@his(TxFrame2+14)
	lea	a4,[a4]@los(TxFrame2+14)
	callg	CalcChecksum
	movh.a	a15,#@his(TxFrame2+24)
	lea	a15,[a15]@los(TxFrame2+24)
	st16.h	[a15],d2
;  727 |
;  728 |  // TCP
;  729 |  WriteWBE(&TxFrame2[TCP_SRCPORT_OFS], TCPLocalPort);
	.symb	LINE, 729
	movh.a	a14,#@his(TxFrame2+34)
	lea	a14,[a14]@los(TxFrame2+34)
	ld.hu	d4,TCPLocalPort			; TCPLocalPort
	mov16.aa a4,a14
	callg	WriteWBE
;  730 |  WriteWBE(&TxFrame2[TCP_DESTPORT_OFS], TCPRemotePort);
	.symb	LINE, 730
	movh.a	a4,#@his(TxFrame2+36)
	lea	a4,[a4]@los(TxFrame2+36)
	ld.hu	d4,TCPRemotePort		; TCPRemotePort
	callg	WriteWBE
;  731 |
;  732 |  WriteDWBE(&TxFrame2[TCP_SEQNR_OFS], TCPSeqNr);
	.symb	LINE, 732
	movh.a	a4,#@his(TxFrame2+38)
	lea	a4,[a4]@los(TxFrame2+38)
	ld.w	d4,TCPSeqNr			; TCPSeqNr
	callg	WriteDWBE
;  733 |  WriteDWBE(&TxFrame2[TCP_ACKNR_OFS], TCPAckNr);
	.symb	LINE, 733
	movh.a	a4,#@his(TxFrame2+42)
	lea	a4,[a4]@los(TxFrame2+42)
	ld.w	d4,TCPAckNr			; TCPAckNr
	callg	WriteDWBE
;  734 |
;  735 |  *(unsigned short *)&TxFrame2[TCP_WINDOW_OFS] = SWAPB(MAX_TCP_RX_DATA_SIZE);    // data bytes to accept
	.symb	LINE, 735
	mov16	d15,#1				; 1
	movh.a	a15,#@his(TxFrame2+48)
	lea	a15,[a15]@los(TxFrame2+48)
	st16.h	[a15],d15			; 1
;  736 |  *(unsigned short *)&TxFrame2[TCP_CHKSUM_OFS] = 0;             // initalize checksum
	.symb	LINE, 736
	movh.a	a15,#@his(TxFrame2+50)
	lea	a15,[a15]@los(TxFrame2+50)
	st16.h	[a15],d13			; 0
;  737 |  *(unsigned short *)&TxFrame2[TCP_URGENT_OFS] = 0;
	.symb	LINE, 737
	movh.a	a15,#@his(TxFrame2+52)
	lea	a15,[a15]@los(TxFrame2+52)
	st16.h	[a15],d13			; 0
;  738 |
;  739 |  if (TCPCode & TCP_CODE_SYN)                    // if SYN, we want to use the MSS option
	.symb	LINE, 739
	jeq	d14,#0,_271
;  740 |  {
;  741 |    *(unsigned short *)&TxFrame2[TCP_DATA_CODE_OFS] = SWAPB(0x6000 | TCPCode);   // TCP header length = 24
	.symb	LINE, 741
	mov	d7,#24576			; 24576
	movh.a	a15,#@his(TxFrame2+46)
	or16	d7,d12
	lea	a15,[a15]@los(TxFrame2+46)
	sha	d6,d7,#8
	extr.u	d6,d6,#0,#16
	sha16	d7,#-8
	or16	d7,d6
	st16.h	[a15],d7
;  742 |    *(unsigned short *)&TxFrame2[TCP_DATA_OFS] = SWAPB(TCP_OPT_MSS);             // MSS option
	.symb	LINE, 742
	mov	d7,#1026
	movh.a	a15,#@his(TxFrame2+54)
	mov	d4,#24				; 24
	lea	a15,[a15]@los(TxFrame2+54)
	mov16	d5,#1				; 1
	st16.h	[a15],d7
;  743 |    *(unsigned short *)&TxFrame2[TCP_DATA_OFS + 2] = SWAPB(MAX_TCP_RX_DATA_SIZE);// max. length of TCP-data we accept
	.symb	LINE, 743
	movh.a	a15,#@his(TxFrame2+56)
	lea	a15,[a15]@los(TxFrame2+56)
	st16.h	[a15],d15			; 1
;  744 |    *(unsigned short *)&TxFrame2[TCP_CHKSUM_OFS] = CalcChecksum(&TxFrame2[TCP_SRCPORT_OFS], TCP_HEADER_SIZE + TCP_OPT_MSS_SIZE, 1);
	.symb	LINE, 744
	mov16.aa a4,a14
	callg	CalcChecksum
	mov16	d15,#58				; TxFrame2Size
	movh.a	a15,#@his(TxFrame2+50)
	lea	a15,[a15]@los(TxFrame2+50)
	st16.h	[a15],d2
;  745 |    TxFrame2Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE + TCP_OPT_MSS_SIZE;
	.symb	LINE, 745
	st.b	TxFrame2Size,d15		; TxFrame2Size
;  746 |  }
	.symb	LINE, 746
	j	_272
_271:
	.symb	LTIM, "TCPCode", 12, 0, 0x84d
	.symb	LTIM, "TCPCode", 12, 0, 0x8cd
;  747 |  else
;  748 |  {
;  749 |    *(unsigned short *)&TxFrame2[TCP_DATA_CODE_OFS] = SWAPB(0x5000 | TCPCode);   // TCP header length = 20
	.symb	LINE, 749
	mov	d15,#20480			; 20480
	movh.a	a15,#@his(TxFrame2+46)
	or16	d15,d12
	lea	a15,[a15]@los(TxFrame2+46)
	sha	d7,d15,#8
	mov16.aa a4,a14
	extr.u	d7,d7,#0,#16
	sha16	d15,#-8
	or16	d15,d7
	st16.h	[a15],d15
;  750 |    *(unsigned short *)&TxFrame2[TCP_CHKSUM_OFS] = CalcChecksum(&TxFrame2[TCP_SRCPORT_OFS], TCP_HEADER_SIZE, 1);
	.symb	LINE, 750
	mov	d4,#20				; 20
	mov16	d5,#1				; 1
	callg	CalcChecksum
	mov16	d15,#54				; TxFrame2Size
	movh.a	a15,#@his(TxFrame2+50)
	lea	a15,[a15]@los(TxFrame2+50)
	st16.h	[a15],d2
;  751 |    TxFrame2Size = ETH_HEADER_SIZE + IP_HEADER_SIZE + TCP_HEADER_SIZE;
	.symb	LINE, 751
	st.b	TxFrame2Size,d15		; TxFrame2Size
;  752 |  }
	.symb	LINE, 752
_272:
;  753 |
;  754 |  TransmitControl |= SEND_FRAME2;
	.symb	LINE, 754
	ld.bu	d15,TransmitControl		; TransmitControl
	or	d15,d15,#2			; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  755 |}
	.symb	LINE, 755
	ret16
	.symb	LTIM, "TCPCode", 12, 0, 0x84d
	.symb	EFUN
;  756 |
;  757 |// easyWEB internal function
;  758 |// prepares the TxFrame1-buffer to send a payload-packet
;  759 |
;  760 |void PrepareTCP_DATA_FRAME(void)
;  761 |{
	.symb	LINE, 761
	.symb	TYPE, 281, 'X', 8, #1, 26, 0
	.symb	GFUN, "PrepareTCP_DATA_FRAME", PrepareTCP_DATA_FRAME, #281, 0, 0, 0
	.symb	ALAB, PrepareTCP_DATA_FRAME, #281
PrepareTCP_DATA_FRAME:
	mov16	d4,#6				; 6
	.symb	SOFF, 0
;  762 |  // Ethernet
;  763 |  memcpy(&TxFrame1[ETH_DA_OFS], &RemoteMAC, 6);
	.symb	LINE, 763
	movh.a	a4,#@his(TxFrame1)
	lea	a4,[a4]@los(TxFrame1)
	movh.a	a5,#@his(RemoteMAC)
	lea	a5,[a5]@los(RemoteMAC)
	callg	memcpy
	mov16	d4,#6				; 6
;  764 |  memcpy(&TxFrame1[ETH_SA_OFS], &MyMAC, 6);
	.symb	LINE, 764
	movh.a	a4,#@his(TxFrame1+6)
	lea	a4,[a4]@los(TxFrame1+6)
	movh.a	a5,#@his(MyMAC)
	lea	a5,[a5]@los(MyMAC)
	callg	memcpy
;  765 |  *(unsigned short *)&TxFrame1[ETH_TYPE_OFS] = SWAPB(FRAME_IP);
	.symb	LINE, 765
	mov16	d15,#8
	movh.a	a15,#@his(TxFrame1+12)
	lea	a15,[a15]@los(TxFrame1+12)
	st16.h	[a15],d15
;  766 |  
;  767 |  // IP   
;  768 |  *(unsigned short *)&TxFrame1[IP_VER_IHL_TOS_OFS] = SWAPB(IP_VER_IHL | IP_TOS_D);
	.symb	LINE, 768
	mov	d15,#4165
	movh.a	a15,#@his(TxFrame1+14)
	lea	a15,[a15]@los(TxFrame1+14)
	st16.h	[a15],d15
;  769 |  WriteWBE(&TxFrame1[IP_TOTAL_LENGTH_OFS], IP_HEADER_SIZE + TCP_HEADER_SIZE + TCPTxDataCount);
	.symb	LINE, 769
	movh.a	a4,#@his(TxFrame1+16)
	lea	a4,[a4]@los(TxFrame1+16)
	ld.hu	d4,TCPTxDataCount		; TCPTxDataCount
	addi	d4,d4,#40
	extr.u	d4,d4,#0,#16
	callg	WriteWBE
;  770 |  *(unsigned short *)&TxFrame1[IP_IDENT_OFS] = 0;
	.symb	LINE, 770
	mov16	d14,#0				; 0
	mov	d15,#1600
	movh.a	a15,#@his(TxFrame1+18)
	lea	a15,[a15]@los(TxFrame1+18)
	st16.h	[a15],d14			; 0
;  771 |  *(unsigned short *)&TxFrame1[IP_FLAGS_FRAG_OFS] = 0;
	.symb	LINE, 771
	movh.a	a15,#@his(TxFrame1+20)
	lea	a15,[a15]@los(TxFrame1+20)
	st16.h	[a15],d14			; 0
;  772 |  *(unsigned short *)&TxFrame1[IP_TTL_PROT_OFS] = SWAPB((DEFAULT_TTL << 8) | PROT_TCP);
	.symb	LINE, 772
	movh.a	a15,#@his(TxFrame1+22)
	mov16	d4,#4				; 4
	lea	a15,[a15]@los(TxFrame1+22)
	st16.h	[a15],d15
;  773 |  *(unsigned short *)&TxFrame1[IP_HEAD_CHKSUM_OFS] = 0; 
	.symb	LINE, 773
	movh.a	a15,#@his(TxFrame1+24)
	lea	a15,[a15]@los(TxFrame1+24)
	st16.h	[a15],d14			; 0
;  774 |  memcpy(&TxFrame1[IP_SOURCE_OFS], &MyIP, 4);
	.symb	LINE, 774
	movh.a	a4,#@his(TxFrame1+26)
	lea	a4,[a4]@los(TxFrame1+26)
	movh.a	a5,#@his(MyIP)
	lea	a5,[a5]@los(MyIP)
	callg	memcpy
	mov16	d4,#4				; 4
;  775 |  memcpy(&TxFrame1[IP_DESTINATION_OFS], &RemoteIP, 4);
	.symb	LINE, 775
	movh.a	a4,#@his(TxFrame1+30)
	lea	a4,[a4]@los(TxFrame1+30)
	movh.a	a5,#@his(RemoteIP)
	lea	a5,[a5]@los(RemoteIP)
	callg	memcpy
	mov	d4,#20				; 20
	mov16	d5,#0				; 0
;  776 |  *(unsigned short *)&TxFrame1[IP_HEAD_CHKSUM_OFS] = CalcChecksum(&TxFrame1[IP_VER_IHL_TOS_OFS], IP_HEADER_SIZE, 0);
	.symb	LINE, 776
	movh.a	a4,#@his(TxFrame1+14)
	lea	a4,[a4]@los(TxFrame1+14)
	callg	CalcChecksum
	movh.a	a15,#@his(TxFrame1+24)
	lea	a15,[a15]@los(TxFrame1+24)
	st16.h	[a15],d2
;  777 |
;  778 |  // TCP
;  779 |  WriteWBE(&TxFrame1[TCP_SRCPORT_OFS], TCPLocalPort);
	.symb	LINE, 779
	movh.a	a14,#@his(TxFrame1+34)
	lea	a14,[a14]@los(TxFrame1+34)
	ld.hu	d4,TCPLocalPort			; TCPLocalPort
	mov16.aa a4,a14
	callg	WriteWBE
;  780 |  WriteWBE(&TxFrame1[TCP_DESTPORT_OFS], TCPRemotePort);
	.symb	LINE, 780
	movh.a	a4,#@his(TxFrame1+36)
	lea	a4,[a4]@los(TxFrame1+36)
	ld.hu	d4,TCPRemotePort		; TCPRemotePort
	callg	WriteWBE
;  781 |
;  782 |  WriteDWBE(&TxFrame1[TCP_SEQNR_OFS], TCPSeqNr);
	.symb	LINE, 782
	movh.a	a4,#@his(TxFrame1+38)
	lea	a4,[a4]@los(TxFrame1+38)
	ld.w	d4,TCPSeqNr			; TCPSeqNr
	callg	WriteDWBE
;  783 |  WriteDWBE(&TxFrame1[TCP_ACKNR_OFS], TCPAckNr);
	.symb	LINE, 783
	movh.a	a4,#@his(TxFrame1+42)
	lea	a4,[a4]@los(TxFrame1+42)
	ld.w	d4,TCPAckNr			; TCPAckNr
	callg	WriteDWBE
;  784 |  *(unsigned short *)&TxFrame1[TCP_DATA_CODE_OFS] = SWAPB(0x5000 | TCP_CODE_ACK);   // TCP header length = 20
	.symb	LINE, 784
	mov	d15,#4176
	movh.a	a15,#@his(TxFrame1+46)
	lea	a15,[a15]@los(TxFrame1+46)
	st16.h	[a15],d15
;  785 |  *(unsigned short *)&TxFrame1[TCP_WINDOW_OFS] = SWAPB(MAX_TCP_RX_DATA_SIZE);       // data bytes to accept
	.symb	LINE, 785
	mov16	d15,#1
	movh.a	a15,#@his(TxFrame1+48)
	lea	a15,[a15]@los(TxFrame1+48)
	mov16	d5,#1				; 1
	st16.h	[a15],d15
;  786 |  *(unsigned short *)&TxFrame1[TCP_CHKSUM_OFS] = 0; 
	.symb	LINE, 786
	movh.a	a15,#@his(TxFrame1+50)
	lea	a15,[a15]@los(TxFrame1+50)
	st16.h	[a15],d14			; 0
;  787 |  *(unsigned short *)&TxFrame1[TCP_URGENT_OFS] = 0;
	.symb	LINE, 787
	movh.a	a15,#@his(TxFrame1+52)
	lea	a15,[a15]@los(TxFrame1+52)
	st16.h	[a15],d14			; 0
;  788 |  *(unsigned short *)&TxFrame1[TCP_CHKSUM_OFS] = CalcChecksum(&TxFrame1[TCP_SRCPORT_OFS], TCP_HEADER_SIZE + TCPTxDataCount, 1);
	.symb	LINE, 788
	ld.hu	d4,TCPTxDataCount		; TCPTxDataCount
	addi	d4,d4,#20
	mov16.aa a4,a14
	extr.u	d4,d4,#0,#16
	callg	CalcChecksum
	movh.a	a15,#@his(TxFrame1+50)
	lea	a15,[a15]@los(TxFrame1+50)
	st16.h	[a15],d2
;  789 |}
	.symb	LINE, 789
	ret16
	.symb	EFUN
;  790 |
;  791 |// easyWEB internal function
;  792 |// calculates the TCP/IP checksum. if 'IsTCP != 0', the TCP pseudo-header
;  793 |// will be included.
;  794 |
;  795 |unsigned short CalcChecksum(void *Start, unsigned short Count, unsigned char IsTCP)
;  796 |{
	.symb	LINE, 796
	.symb	TYPE, 284, 'P', #1
	.symb	TYPE, 282, 'X', 8, #5, 26, 3, #284, #5, #3
	.symb	GFUN, "CalcChecksum", CalcChecksum, #282, 0, 0, 0
	.symb	ALAB, CalcChecksum, #282
CalcChecksum:
	.symb	IDEN, "Start", 30, #284, 0, 0x80d
	.symb	IDEN, "Count", 14, #5, 0, 0x80d
	.symb	IDEN, "IsTCP", 5, #3, 0, 0x80d
	.symb	IDEN, "Sum", -1, #7, 131, 0x5
	.symb	TYPE, 286, 'P', #5
	.symb	IDEN, "piStart", -1, #286, 131, 0x5
	.symb	SOFF, 0
	.symb	LTIM, "Start", 20, 0, 0x8cd
	.symb	LTIM, "Count", 4, 0, 0x8cd
	.symb	LTIM, "IsTCP", 5, 0, 0x8cd
	.symb	LTIM, "Count", 4, 0, 0x84d
	.symb	LTIM, "Count", 14, 0, 0x8cd
	.symb	LTIM, "Start", 20, 0, 0x84d
	.symb	LTIM, "Start", 30, 0, 0x8cd
	.symb	LTIM, "Sum", -1, 0, 0x45
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "piStart", -1, 0, 0x45
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 13, 0, 0xcd
	.symb	LTIM, "Count", 14, 0, 0x84d
	.symb	LTIM, "Count", 4, 0, 0x8cd
	.symb	LTIM, "Count", 4, 0, 0x84d
	.symb	LTIM, "Count", 14, 0, 0x8cd
	.symb	LTIM, "IsTCP", 5, 0, 0x84d
	.symb	LTIM, "Sum", 13, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	mov16	d14,d4				; Count
	mov16.aa a14,a4				; Start
;  797 |  unsigned long Sum = 0;
	.symb	LINE, 797
	mov16	d15,#0				; 0
;  798 |  unsigned short * piStart;                        // Keil: Pointer added to correct expression
;  799 |
;  800 |  if (IsTCP) {                                   // if we've a TCP frame...
	.symb	LINE, 800
	jeq	d5,#0,_280			; IsTCP
;  801 |    Sum += MyIP[0];                              // ...include TCP pseudo-header
	.symb	LINE, 801
	movh.a	a15,#@his(MyIP)
	lea	a15,[a15]@los(MyIP)
	ld.hu	d13,[a15]
;  802 |    Sum += MyIP[1];
	.symb	LINE, 802
	movh.a	a15,#@his(MyIP+2)
	lea	a15,[a15]@los(MyIP+2)
	ld.hu	d15,[a15]
	add16	d13,d15				; Sum
;  803 |    Sum += RemoteIP[0];
	.symb	LINE, 803
	movh.a	a15,#@his(RemoteIP)
	mov16	d4,d14				; Count
	lea	a15,[a15]@los(RemoteIP)
	ld.hu	d15,[a15]
	add16	d13,d15				; Sum
;  804 |    Sum += RemoteIP[1];
	.symb	LINE, 804
	movh.a	a15,#@his(RemoteIP+2)
	lea	a15,[a15]@los(RemoteIP+2)
	ld.hu	d15,[a15]
	add16	d13,d15				; Sum
;  805 |    Sum += SwapBytes(Count);                     // TCP header length plus data length
	.symb	LINE, 805
	callg	SwapBytes
	add	d15,d13,d2			; Sum
;  806 |    Sum += SWAPB(PROT_TCP);
	.symb	LINE, 806
	addi	d15,d15,#1536			; Sum
;  807 |  }
	.symb	LINE, 807
_280:
	.symb	LTIM, "piStart", 31, 0, 0xcd
;  808 |
;  809 |  piStart = Start;                               // Keil: Line added
	.symb	LINE, 809
	mov16.aa a15,a14			; piStart
;  810 |  while (Count > 1) {                            // sum words
	.symb	LINE, 810
	j	_282
_281:
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "piStart", 31, 0, 0x4d
	.symb	LTIM, "piStart", 31, 0, 0xcd
	.symb	LTIM, "piStart", 31, 0, 0x4d
	.symb	LTIM, "piStart", 31, 0, 0xcd
	.symb	LTIM, "Count", 14, 0, 0x84d
	.symb	LTIM, "Count", 14, 0, 0x8cd
	add16	d14,#-2				; Count
;  811 |//  Sum += *((unsigned short *)Start)++;		     // Keil: Line replaced with following line
;  812 |    Sum += *piStart++;
	.symb	LINE, 812
	ld.hu	d7,[a15]
	add16	d15,d7				; Sum
	add16.a	a15,#2				; piStart
;  813 |    Count -= 2;
	.symb	LINE, 813
	extr.u	d14,d14,#0,#16			; Count
	.symb	LINE, 810
_282:
	.symb	LTIM, "piStart", 31, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
	jge	d14,#2,_281
;  814 |  }
;  815 |
;  816 |  if (Count)                                     // add left-over byte, if any
	.symb	LINE, 816
	jeq	d14,#0,_283			; Count
;  817 |//  Sum += *(unsigned char *)Start; 	         // Keil: Line replaced with following line
;  818 |    Sum += *(unsigned char *)piStart;
	.symb	LINE, 818
	ld16.bu	d7,[a15]
	add16	d15,d7				; Sum
;  819 |  
;  820 |  while (Sum >> 16)                              // fold 32-bit sum to 16 bits
	.symb	LINE, 820
_283:
	j	_285
_284:
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Sum", 15, 0, 0xcd
;  821 |    Sum = (Sum & 0xFFFF) + (Sum >> 16);
	.symb	LINE, 821
	mov.u	d7,#65535			; 65535
	and16	d7,d15
	sh	d15,d15,#-16
	add16	d15,d7
	.symb	LINE, 820
_285:
	sh	d7,d15,#-16
	jne	d7,#0,_284
;  822 |  
;  823 |  return ~Sum;
	.symb	LINE, 823
	xnor	d2,d15,#0
	extr.u	d2,d2,#0,#16
;  824 |}
	.symb	LINE, 824
	ret16
	.symb	LTIM, "Sum", 15, 0, 0x4d
	.symb	LTIM, "Count", 14, 0, 0x84d
	.symb	LTIM, "Start", 30, 0, 0x84d
	.symb	EFUN
;  825 |
;  826 |// easyWEB internal function
;  827 |// starts the timer as a retry-timer (used for retransmission-timeout)
;  828 |
;  829 |void TCPStartRetryTimer(void)
;  830 |{
	.symb	LINE, 830
	.symb	TYPE, 287, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPStartRetryTimer", TCPStartRetryTimer, #287, 0, 0, 0
	.symb	ALAB, TCPStartRetryTimer, #287
TCPStartRetryTimer:
	mov16	d7,#0				; TCPTimer
	.symb	SOFF, 0
	ld.bu	d15,TCPFlags			; TCPFlags
	or	d15,d15,#4			; $TCPFlags
;  831 |  TCPTimer = 0;
	.symb	LINE, 831
	st.b	TCPTimer,d7			; TCPTimer
;  832 |  RetryCounter = MAX_RETRYS;
	.symb	LINE, 832
	mov16	d7,#4				; RetryCounter
	st.b	RetryCounter,d7			; RetryCounter
;  833 |  TCPFlags |= TCP_TIMER_RUNNING;
;  834 |  TCPFlags |= TIMER_TYPE_RETRY;
	.symb	LINE, 834
	or	d15,d15,#8			; $TCPFlags
	extr.u	d15,d15,#0,#8			; $TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;  835 |}
	.symb	LINE, 835
	ret16
	.symb	EFUN
;  836 |
;  837 |// easyWEB internal function
;  838 |// starts the timer as a 'TIME_WAIT'-timer (used to finish a TCP-session)
;  839 |
;  840 |void TCPStartTimeWaitTimer(void)
;  841 |{
	.symb	LINE, 841
	.symb	TYPE, 288, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPStartTimeWaitTimer", TCPStartTimeWaitTimer, #288, 0, 0, 0
	.symb	ALAB, TCPStartTimeWaitTimer, #288
TCPStartTimeWaitTimer:
	mov16	d7,#0				; TCPTimer
	.symb	SOFF, 0
	ld.bu	d15,TCPFlags			; TCPFlags
	or	d15,d15,#4			; $TCPFlags
;  842 |  TCPTimer = 0;
	.symb	LINE, 842
	st.b	TCPTimer,d7			; TCPTimer
;  843 |  TCPFlags |= TCP_TIMER_RUNNING;
;  844 |  TCPFlags &= ~TIMER_TYPE_RETRY;  
	.symb	LINE, 844
	mov	d7,#-9				; -9
	and16	d15,d7				; $TCPFlags
	extr.u	d15,d15,#0,#8			; $TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;  845 |}
	.symb	LINE, 845
	ret16
	.symb	EFUN
;  846 |
;  847 |// easyWEB internal function
;  848 |// restarts the timer
;  849 |
;  850 |void TCPRestartTimer(void)
;  851 |{
	.symb	LINE, 851
	.symb	TYPE, 289, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPRestartTimer", TCPRestartTimer, #289, 0, 0, 0
	.symb	ALAB, TCPRestartTimer, #289
TCPRestartTimer:
;  852 |  TCPTimer = 0;
	.symb	LINE, 852
	mov16	d15,#0				; TCPTimer
	.symb	SOFF, 0
	st.b	TCPTimer,d15			; TCPTimer
;  853 |}
	.symb	LINE, 853
	ret16
	.symb	EFUN
;  854 |
;  855 |// easyWEB internal function
;  856 |// stopps the timer
;  857 |
;  858 |void TCPStopTimer(void)
;  859 |{
	.symb	LINE, 859
	.symb	TYPE, 290, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPStopTimer", TCPStopTimer, #290, 0, 0, 0
	.symb	ALAB, TCPStopTimer, #290
TCPStopTimer:
	mov16	d7,#-5				; -5
	.symb	SOFF, 0
;  860 |  TCPFlags &= ~TCP_TIMER_RUNNING;
	.symb	LINE, 860
	ld.bu	d15,TCPFlags			; TCPFlags
	and16	d15,d7				; TCPFlags
	st.b	TCPFlags,d15			; TCPFlags
;  861 |}
	.symb	LINE, 861
	ret16
	.symb	EFUN
;  862 |
;  863 |// easyWEB internal function
;  864 |// if a retransmission-timeout occured, check which packet
;  865 |// to resend.
;  866 |
;  867 |void TCPHandleRetransmission(void)
;  868 |{
	.symb	LINE, 868
	.symb	TYPE, 291, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPHandleRetransmission", TCPHandleRetransmission, #291, 0, 0, 0
	.symb	ALAB, TCPHandleRetransmission, #291
TCPHandleRetransmission:
	.symb	SOFF, 0
;  869 |  switch (LastFrameSent)
	.symb	LINE, 869
	ld.b	d15,LastFrameSent		; LastFrameSent
	jeq	d15,#0,_286			; case 0
	jeq	d15,#1,_287			; case 1
	jeq	d15,#2,_288			; case 2
	jeq	d15,#3,_289			; case 3
	jeq	d15,#4,_290			; case 4
	j	_295				; default
;  870 |  {
;  871 |    case ARP_REQUEST :       { PrepareARP_REQUEST(); break; }
	.symb	LINE, 871
_286:
	jg	PrepareARP_REQUEST
;  872 |    case TCP_SYN_FRAME :     { PrepareTCP_FRAME(TCP_CODE_SYN); break; }
	.symb	LINE, 872
_287:
	mov16	d4,#2				; 2
	jg	PrepareTCP_FRAME
;  873 |    case TCP_SYN_ACK_FRAME : { PrepareTCP_FRAME(TCP_CODE_SYN | TCP_CODE_ACK); break; }
	.symb	LINE, 873
_288:
	mov	d4,#18				; 18
	jg	PrepareTCP_FRAME
;  874 |    case TCP_FIN_FRAME :     { PrepareTCP_FRAME(TCP_CODE_FIN | TCP_CODE_ACK); break; }
	.symb	LINE, 874
_289:
	mov	d4,#17				; 17
	jg	PrepareTCP_FRAME
;  875 |    case TCP_DATA_FRAME :    { TransmitControl |= SEND_FRAME1; break; }
	.symb	LINE, 875
_290:
	ld.bu	d15,TransmitControl		; TransmitControl
	or	d15,d15,#1			; TransmitControl
	st.b	TransmitControl,d15		; TransmitControl
;  876 |  }
	.symb	LINE, 876
_295:
;  877 |}
	.symb	LINE, 877
	ret16
	.symb	EFUN
;  878 |
;  879 |// easyWEB internal function
;  880 |// if all retransmissions failed, close connection and indicate an error
;  881 |
;  882 |void TCPHandleTimeout(void)
;  883 |{
	.symb	LINE, 883
	.symb	TYPE, 292, 'X', 8, #1, 26, 0
	.symb	GFUN, "TCPHandleTimeout", TCPHandleTimeout, #292, 0, 0, 0
	.symb	ALAB, TCPHandleTimeout, #292
TCPHandleTimeout:
	.symb	SOFF, 0
;  884 |  TCPStateMachine = CLOSED;
	.symb	LINE, 884
	mov16	d15,#0				; TCPStateMachine
	st.b	TCPStateMachine,d15		; TCPStateMachine
;  885 |
;  886 |  if ((TCPFlags & (TCP_ACTIVE_OPEN | IP_ADDR_RESOLVED)) == TCP_ACTIVE_OPEN)
	.symb	LINE, 886
	ld.bu	d15,TCPFlags			; TCPFlags
	and	d15,d15,#3
	jne	d15,#1,_296
;  887 |    SocketStatus = SOCK_ERR_ARP_TIMEOUT;         // indicate an error to user
	.symb	LINE, 887
	mov16	d15,#16				; 16
	j	_297
_296:
;  888 |  else
;  889 |    SocketStatus = SOCK_ERR_TCP_TIMEOUT;
	.symb	LINE, 889
	mov16	d15,#32				; 32
_297:
;  890 |
;  891 |  TCPFlags = 0;                                  // clear all flags
	.symb	LINE, 891
	mov16	d7,#0				; TCPFlags
	st.b	TCPFlags,d7			; TCPFlags
	st.b	SocketStatus,d15		; SocketStatus
;  892 |}
	.symb	LINE, 892
	ret16
	.symb	EFUN
;  893 |
;  894 |
;  895 |// easyWEB internal function
;  896 |// function executed every 0.210s by the CPU. used for the
;  897 |// inital sequence number generator (ISN) and the TCP-timer
;  898 |
;  899 |//PHYTEC: void TCPClockHandler(void) interrupt 0x23        // Keil: interrupt service routine for timer 3  
;  900 |//PHYTEC:{
;  901 |//PHYTEC:  ISNGenHigh++;                                  // upper 16 bits of initial sequence number
;  902 |//PHYTEC:  TCPTimer++;                                    // timer for retransmissions
;  903 |//PHYTEC:}
;  904 |
;  905 |// easyWEB internal function
;  906 |// transfers the contents of 'TxFrame1'-Buffer to the CS8900A
;  907 |
;  908 |void SendFrame1(void)
;  909 |{
	.symb	LINE, 909
	.symb	TYPE, 293, 'X', 8, #1, 26, 0
	.symb	GFUN, "SendFrame1", SendFrame1, #293, 0, 0, 0
	.symb	ALAB, SendFrame1, #293
SendFrame1:
	.symb	SOFF, 0
;  910 |  CopyToFrame8900(&TxFrame1, TxFrame1Size);
	.symb	LINE, 910
	movh.a	a4,#@his(TxFrame1)
	lea	a4,[a4]@los(TxFrame1)
	ld.hu	d4,TxFrame1Size			; TxFrame1Size
	jg	CopyToFrame8900
	.symb	EFUN
;  911 |}
;  912 |
;  913 |// easyWEB internal function
;  914 |// transfers the contents of 'TxFrame2'-Buffer to the CS8900A
;  915 |
;  916 |void SendFrame2(void)
;  917 |{
	.symb	LINE, 917
	.symb	TYPE, 294, 'X', 8, #1, 26, 0
	.symb	GFUN, "SendFrame2", SendFrame2, #294, 0, 0, 0
	.symb	ALAB, SendFrame2, #294
SendFrame2:
	.symb	SOFF, 0
;  918 |  CopyToFrame8900(&TxFrame2, TxFrame2Size);
	.symb	LINE, 918
	movh.a	a4,#@his(TxFrame2)
	lea	a4,[a4]@los(TxFrame2)
	ld.bu	d4,TxFrame2Size			; TxFrame2Size
	jg	CopyToFrame8900
	.symb	EFUN
;  919 |}
;  920 |
;  921 |// easyWEB internal function
;  922 |// help function to write a WORD in big-endian byte-order
;  923 |// to MCU-memory
;  924 |
;  925 |void WriteWBE(unsigned char *Add, unsigned short Data)
;  926 |{
	.symb	LINE, 926
	.symb	TYPE, 297, 'P', #3
	.symb	TYPE, 295, 'X', 8, #1, 26, 2, #297, #5
	.symb	GFUN, "WriteWBE", WriteWBE, #295, 0, 0, 0
	.symb	ALAB, WriteWBE, #295
WriteWBE:
	.symb	IDEN, "Add", 20, #297, 0, 0x80d
	.symb	IDEN, "Data", 4, #5, 0, 0x80d
;  927 |  *Add++ = Data >> 8;
	.symb	LINE, 927
	sha	d15,d4,#-8
	.symb	SOFF, 0
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Data", 4, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	st16.b	[a4+],d15			; Add
;  928 |  *Add = Data;
	.symb	LINE, 928
	st16.b	[a4],d4				; Add
;  929 |}
	.symb	LINE, 929
	ret16
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Data", 4, 0, 0x84d
	.symb	EFUN
;  930 |
;  931 |// easyWEB internal function
;  932 |// help function to write a DWORD in big-endian byte-order
;  933 |// to MCU-memory
;  934 |
;  935 |void WriteDWBE(unsigned char *Add, unsigned long Data)
;  936 |{
	.symb	LINE, 936
	.symb	TYPE, 298, 'X', 8, #1, 26, 2, #297, #7
	.symb	GFUN, "WriteDWBE", WriteDWBE, #298, 0, 0, 0
	.symb	ALAB, WriteDWBE, #298
WriteDWBE:
	.symb	IDEN, "Add", 20, #297, 0, 0x80d
	.symb	IDEN, "Data", 4, #7, 0, 0x80d
;  937 |  *Add++ = Data >> 24;
	.symb	LINE, 937
	sh	d15,d4,#-24
	.symb	SOFF, 0
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Data", 4, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Add", 20, 0, 0x8cd
	st16.b	[a4+],d15			; Add
;  938 |  *Add++ = Data >> 16;
	.symb	LINE, 938
	sh	d15,d4,#-16
	st16.b	[a4+],d15			; Add
;  939 |  *Add++ = Data >> 8;
	.symb	LINE, 939
	sh	d15,d4,#-8
	st16.b	[a4+],d15			; Add
;  940 |  *Add = Data;
	.symb	LINE, 940
	st16.b	[a4],d4				; Add
;  941 |}
	.symb	LINE, 941
	ret16
	.symb	LTIM, "Add", 20, 0, 0x84d
	.symb	LTIM, "Data", 4, 0, 0x84d
	.symb	EFUN
;  942 |
;  943 |// easyWEB internal function
;  944 |// help function to swap the byte order of a WORD
;  945 |
;  946 |unsigned short SwapBytes(unsigned short Data)
;  947 |{
	.symb	LINE, 947
	.symb	TYPE, 299, 'X', 8, #5, 26, 1, #5
	.symb	GFUN, "SwapBytes", SwapBytes, #299, 0, 0, 0
	.symb	ALAB, SwapBytes, #299
SwapBytes:
	.symb	IDEN, "Data", 4, #5, 0, 0x80d
;  948 |  return (Data >> 8) | (Data << 8);
	.symb	LINE, 948
	sha	d2,d4,#-8
	.symb	SOFF, 0
	.symb	LTIM, "Data", 4, 0, 0x8cd
	sha	d15,d4,#8
	or16	d2,d15
	extr.u	d2,d2,#0,#16
;  949 |}
	.symb	LINE, 949
	ret16
	.symb	LTIM, "Data", 4, 0, 0x84d
	.symb	EFUN
;  950 |
	.symb	ENDF
	.symb	ALAB, TCPFlags, #3
	.symb	ALAB, TCPLocalPort, #5
	.symb	ALAB, RemoteIP, #272
	.symb	ALAB, MyIP, #272
	.symb	TYPE, 300, 'X', 8, #5, 26, 0
	.symb	ALAB, ReadFrameBE8900, #300
	.symb	ALAB, TCPTxDataCount, #5
	.symb	ALAB, GatewayIP, #272
	.symb	ALAB, TxFrame2Size, #3
	.symb	TYPE, 301, 'Z', #3, 73
	.symb	ALAB, TxFrame2, #301
	.symb	ALAB, LastFrameSent, #259
	.symb	TYPE, 303, 'Z', #3, 565
	.symb	ALAB, TxFrame1, #303
	.symb	ALAB, ISNGenHigh, #5
	.symb	TYPE, 305, 'X', 8, #1, 26, 2, #284, #5
	.symb	ALAB, CopyToFrame8900, #305
	.symb	TYPE, 306, 'Z', #5, 2
	.symb	ALAB, RecdFrameMAC, #306
	.symb	TYPE, 308, 'X', 8, #1, 26, 1, #5
	.symb	ALAB, RequestSend, #308
	.symb	TYPE, 309, 'Z', #3, 255
	.symb	ALAB, RxTCPBuffer, #309
	.symb	TYPE, 311, 'Z', #3, 5
	.symb	ALAB, MyMAC, #311
	.symb	ALAB, TxFrame1Size, #5
	.symb	TYPE, 313, 'X', 8, #1, 26, 1, #5
	.symb	ALAB, DummyReadFrame8900, #313
	.symb	TYPE, 314, 'X', 8, #5, 26, 0
	.symb	ALAB, Rdy4Tx, #314
	.symb	ALAB, RecdFrameIP, #272
	.symb	ALAB, TCPSeqNr, #7
	.symb	ALAB, RetryCounter, #3
	.symb	ALAB, TCPUNASeqNr, #7
	.symb	TYPE, 316, 'P', #1
	.symb	TYPE, 317, 'X', 8, #316, 26, 3, #284, #16, #18
	.symb	ALAB, memset, #317
	.symb	ALAB, TCPRxDataCount, #5
	.symb	TYPE, 318, 'X', 8, #1, 26, 0
	.symb	ALAB, Init8900, #318
	.symb	ALAB, TCPTimer, #3
	.symb	ALAB, TCPRemotePort, #5
	.symb	ALAB, TCPAckNr, #7
	.symb	TYPE, 319, 'X', 8, #5, 26, 1, #3
	.symb	ALAB, Read8900, #319
	.symb	ALAB, RecdIPFrameLength, #5
	.symb	ALAB, RecdFrameLength, #5
	.symb	ALAB, TCPStateMachine, #257
	.symb	TYPE, 320, 'X', 8, #5, 26, 1, #3
	.symb	ALAB, ReadHB1ST8900, #320
	.symb	ALAB, TransmitControl, #3
	.symb	TYPE, 321, 'X', 8, #16, 26, 3, #284, #284, #18
	.symb	ALAB, memcmp, #321
	.symb	ALAB, SubnetMask, #272
	.symb	ALAB, RemoteMAC, #306
	.symb	TYPE, 322, 'X', 8, #1, 26, 2, #284, #5
	.symb	ALAB, CopyFromFrame8900, #322
	.symb	TYPE, 323, 'X', 8, #316, 26, 3, #284, #284, #18
	.symb	ALAB, memcpy, #323
	.symb	ALAB, SocketStatus, #3
	.symb	TYPE, 324, 'X', 8, #1, 26, 2, #3, #5
	.symb	ALAB, Write8900, #324
	.global	CalcChecksum
	.global	DoNetworkStuff
	.global	PrepareARP_ANSWER
	.global	PrepareARP_REQUEST
	.global	PrepareICMP_ECHO_REPLY
	.global	PrepareTCP_DATA_FRAME
	.global	PrepareTCP_FRAME
	.global	ProcessEthBroadcastFrame
	.global	ProcessEthIAFrame
	.global	ProcessICMPFrame
	.global	ProcessTCPFrame
	.global	SendFrame1
	.global	SendFrame2
	.global	SwapBytes
	.global	TCPActiveOpen
	.global	TCPClose
	.global	TCPHandleRetransmission
	.global	TCPHandleTimeout
	.global	TCPLowLevelInit
	.global	TCPPassiveOpen
	.global	TCPReleaseRxBuffer
	.global	TCPRestartTimer
	.global	TCPStartRetryTimer
	.global	TCPStartTimeWaitTimer
	.global	TCPStopTimer
	.global	TCPTransmitTxBuffer
	.global	WriteDWBE
	.global	WriteWBE
	.extern	(CODE) CopyFromFrame8900
	.extern	(CODE) CopyToFrame8900
	.extern	(CODE) DummyReadFrame8900
	.extern	(DATA) GatewayIP
	.extern	(DATA,ABS18) ISNGenHigh
	.extern	(CODE) Init8900
	.extern	(DATA,ABS18) LastFrameSent
	.extern	(DATA) MyIP
	.extern	(DATA) MyMAC
	.extern	(CODE) Rdy4Tx
	.extern	(CODE) Read8900
	.extern	(CODE) ReadFrameBE8900
	.extern	(CODE) ReadHB1ST8900
	.extern	(DATA) RecdFrameIP
	.extern	(DATA,ABS18) RecdFrameLength
	.extern	(DATA) RecdFrameMAC
	.extern	(DATA,ABS18) RecdIPFrameLength
	.extern	(DATA) RemoteIP
	.extern	(DATA) RemoteMAC
	.extern	(CODE) RequestSend
	.extern	(DATA,ABS18) RetryCounter
	.extern	(DATA) RxTCPBuffer
	.extern	(DATA,ABS18) SocketStatus
	.extern	(DATA) SubnetMask
	.extern	(DATA,ABS18) TCPAckNr
	.extern	(DATA,ABS18) TCPFlags
	.extern	(DATA,ABS18) TCPLocalPort
	.extern	(DATA,ABS18) TCPRemotePort
	.extern	(DATA,ABS18) TCPRxDataCount
	.extern	(DATA,ABS18) TCPSeqNr
	.extern	(DATA,ABS18) TCPStateMachine
	.extern	(DATA,ABS18) TCPTimer
	.extern	(DATA,ABS18) TCPTxDataCount
	.extern	(DATA,ABS18) TCPUNASeqNr
	.extern	(DATA,ABS18) TransmitControl
	.extern	(DATA) TxFrame1
	.extern	(DATA,ABS18) TxFrame1Size
	.extern	(DATA) TxFrame2
	.extern	(DATA,ABS18) TxFrame2Size
	.extern	(CODE) Write8900
	.extern	(CODE) memcmp
	.extern	(CODE) memcpy
	.extern	(CODE) memset
	.calls	"CalcChecksum", "SwapBytes"
	.calls	"DoNetworkStuff", "PrepareTCP_DATA_FRAME"
	.calls	"DoNetworkStuff", "PrepareTCP_FRAME"
	.calls	"DoNetworkStuff", "ProcessEthBroadcastFrame"
	.calls	"DoNetworkStuff", "ProcessEthIAFrame"
	.calls	"DoNetworkStuff", "Rdy4Tx"
	.calls	"DoNetworkStuff", "Read8900"
	.calls	"DoNetworkStuff", "RequestSend"
	.calls	"DoNetworkStuff", "SendFrame1"
	.calls	"DoNetworkStuff", "SendFrame2"
	.calls	"DoNetworkStuff", "TCPHandleRetransmission"
	.calls	"DoNetworkStuff", "TCPHandleTimeout"
	.calls	"DoNetworkStuff", "TCPRestartTimer"
	.calls	"DoNetworkStuff", "TCPStartRetryTimer"
	.calls	"DoNetworkStuff", "TCPStopTimer"
	.calls	"DoNetworkStuff", "Write8900"
	.calls	"PrepareICMP_ECHO_REPLY", "CalcChecksum"
	.calls	"PrepareICMP_ECHO_REPLY", "CopyFromFrame8900"
	.calls	"PrepareICMP_ECHO_REPLY", "WriteWBE"
	.calls	"PrepareTCP_DATA_FRAME", "CalcChecksum"
	.calls	"PrepareTCP_DATA_FRAME", "WriteDWBE"
	.calls	"PrepareTCP_DATA_FRAME", "WriteWBE"
	.calls	"PrepareTCP_FRAME", "CalcChecksum"
	.calls	"PrepareTCP_FRAME", "WriteDWBE"
	.calls	"PrepareTCP_FRAME", "WriteWBE"
	.calls	"ProcessEthBroadcastFrame", "CopyFromFrame8900"
	.calls	"ProcessEthBroadcastFrame", "DummyReadFrame8900"
	.calls	"ProcessEthBroadcastFrame", "PrepareARP_ANSWER"
	.calls	"ProcessEthBroadcastFrame", "ReadFrameBE8900"
	.calls	"ProcessEthBroadcastFrame", "ReadHB1ST8900"
	.calls	"ProcessEthBroadcastFrame", "memcmp"
	.calls	"ProcessEthIAFrame", "CopyFromFrame8900"
	.calls	"ProcessEthIAFrame", "DummyReadFrame8900"
	.calls	"ProcessEthIAFrame", "ProcessICMPFrame"
	.calls	"ProcessEthIAFrame", "ProcessTCPFrame"
	.calls	"ProcessEthIAFrame", "ReadFrameBE8900"
	.calls	"ProcessEthIAFrame", "ReadHB1ST8900"
	.calls	"ProcessEthIAFrame", "TCPStopTimer"
	.calls	"ProcessEthIAFrame", "memcmp"
	.calls	"ProcessICMPFrame", "PrepareICMP_ECHO_REPLY"
	.calls	"ProcessICMPFrame", "ReadFrameBE8900"
	.calls	"ProcessTCPFrame", "CopyFromFrame8900"
	.calls	"ProcessTCPFrame", "DummyReadFrame8900"
	.calls	"ProcessTCPFrame", "PrepareTCP_FRAME"
	.calls	"ProcessTCPFrame", "ReadFrameBE8900"
	.calls	"ProcessTCPFrame", "TCPRestartTimer"
	.calls	"ProcessTCPFrame", "TCPStartRetryTimer"
	.calls	"ProcessTCPFrame", "TCPStartTimeWaitTimer"
	.calls	"ProcessTCPFrame", "TCPStopTimer"
	.calls	"ProcessTCPFrame", "memcmp"
	.calls	"SendFrame1", "CopyToFrame8900"
	.calls	"SendFrame2", "CopyToFrame8900"
	.calls	"TCPActiveOpen", "PrepareARP_REQUEST"
	.calls	"TCPActiveOpen", "TCPStartRetryTimer"
	.calls	"TCPHandleRetransmission", "PrepareARP_REQUEST"
	.calls	"TCPHandleRetransmission", "PrepareTCP_FRAME"
	.calls	"TCPLowLevelInit", "Init8900"
	.calls	"TCPTransmitTxBuffer", "TCPStartRetryTimer"
