📄 tcp.s
字号:
; if (!SendDebugStr((char*)ScratchPad)) return;
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L18
.dbline 191
xjmp L1
L18:
.dbline 193
;
; if (!SendDebugRStr(tcp_str5)) return;
ldi R16,<_tcp_str5
ldi R17,>_tcp_str5
xcall _SendDebugRStr
tst R16
brne L20
.dbline 193
xjmp L1
L20:
.dbline 194
; sprintf((char*)ScratchPad, "%u", TCP_Header->DataOffset >> 4);
lds R30,_TCP_Header
lds R31,_TCP_Header+1
ldd R2,z+12
clr R3
asr R3
ror R2
asr R3
ror R2
asr R3
ror R2
asr R3
ror R2
std y+1,R3
std y+0,R2
ldi R18,<L4
ldi R19,>L4
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 195
; if (!SendDebugStr((char*)ScratchPad)) return;
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L22
.dbline 195
xjmp L1
L22:
.dbline 197
;
; b = TCP_Header->ControlBits;
lds R30,_TCP_Header
lds R31,_TCP_Header+1
ldd R22,z+13
.dbline 198
; if (!SendDebugRStr(tcp_str6)) return;
ldi R16,<_tcp_str6
ldi R17,>_tcp_str6
xcall _SendDebugRStr
tst R16
brne L24
.dbline 198
xjmp L1
L24:
.dbline 199
; if (b & TCP_SYN) SendDebugRStr(tcp_str11);
sbrs R22,1
rjmp L26
.dbline 199
ldi R16,<_tcp_str11
ldi R17,>_tcp_str11
xcall _SendDebugRStr
L26:
.dbline 200
; if (b & TCP_FIN) SendDebugRStr(tcp_str12);
sbrs R22,0
rjmp L28
.dbline 200
ldi R16,<_tcp_str12
ldi R17,>_tcp_str12
xcall _SendDebugRStr
L28:
.dbline 201
; if (b & TCP_RST) SendDebugRStr(tcp_str10);
sbrs R22,2
rjmp L30
.dbline 201
ldi R16,<_tcp_str10
ldi R17,>_tcp_str10
xcall _SendDebugRStr
L30:
.dbline 202
; if (b & TCP_URG) SendDebugRStr(tcp_str7);
sbrs R22,5
rjmp L32
.dbline 202
ldi R16,<_tcp_str7
ldi R17,>_tcp_str7
xcall _SendDebugRStr
L32:
.dbline 203
; if (b & TCP_ACK) SendDebugRStr(tcp_str8);
sbrs R22,4
rjmp L34
.dbline 203
ldi R16,<_tcp_str8
ldi R17,>_tcp_str8
xcall _SendDebugRStr
L34:
.dbline 204
; if (b & TCP_PSH) SendDebugRStr(tcp_str9);
sbrs R22,3
rjmp L36
.dbline 204
ldi R16,<_tcp_str9
ldi R17,>_tcp_str9
xcall _SendDebugRStr
L36:
.dbline 206
;
; if (!SendDebugRStr(tcp_str13)) return;
ldi R16,<_tcp_str13
ldi R17,>_tcp_str13
xcall _SendDebugRStr
tst R16
brne L38
.dbline 206
xjmp L1
L38:
.dbline 207
; sprintf((char*)ScratchPad, "%u", ntohs(TCP_Header->WindowSize));
lds R30,_TCP_Header
lds R31,_TCP_Header+1
ldd R16,z+14
ldd R17,z+15
xcall _ntohs
std y+1,R17
std y+0,R16
ldi R18,<L4
ldi R19,>L4
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 208
; if (!SendDebugStr((char*)ScratchPad)) return;
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L40
.dbline 208
xjmp L1
L40:
.dbline 210
;
; if (!SendDebugRStr(tcp_str14)) return;
ldi R16,<_tcp_str14
ldi R17,>_tcp_str14
xcall _SendDebugRStr
tst R16
brne L42
.dbline 210
xjmp L1
L42:
.dbline 211
; sprintf((char*)ScratchPad, "%04x", ntohs(TCP_Header->Checksum));
lds R30,_TCP_Header
lds R31,_TCP_Header+1
ldd R16,z+16
ldd R17,z+17
xcall _ntohs
std y+1,R17
std y+0,R16
ldi R18,<L44
ldi R19,>L44
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 212
; if (!SendDebugStr((char*)ScratchPad)) return;
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L45
.dbline 212
xjmp L1
L45:
.dbline 214
;
; if (!SendDebugRStr(tcp_str15)) return;
ldi R16,<_tcp_str15
ldi R17,>_tcp_str15
xcall _SendDebugRStr
tst R16
brne L47
.dbline 214
xjmp L1
L47:
.dbline 215
; sprintf((char*)ScratchPad, "%u", ntohs(TCP_Header->UrgentPointer));
lds R30,_TCP_Header
lds R31,_TCP_Header+1
ldd R16,z+18
ldd R17,z+19
xcall _ntohs
std y+1,R17
std y+0,R16
ldi R18,<L4
ldi R19,>L4
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 216
; if (!SendDebugStr((char*)ScratchPad)) return;
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L49
.dbline 216
xjmp L1
L49:
.dbline 220
;
; // display the options - if any
;
; i = HeaderIdx; //
std y+11,R21
std y+10,R20
.dbline 221
; j = (int)(TCP_Header->DataOffset >> 4); // header length in 32-bit dwords
lds R30,_TCP_Header
lds R31,_TCP_Header+1
ldd R10,z+12
clr R11
asr R11
ror R10
asr R11
ror R10
asr R11
ror R10
asr R11
ror R10
.dbline 222
; j <<= 2; // ... and now in bytes
lsl R10
rol R11
lsl R10
rol R11
.dbline 223
; j += i; // point to data (immediately follows the TCP header)
movw R0,R20
add R10,R20
adc R11,R21
.dbline 224
; i += sizeof(T_TCP_Header); //
movw R24,R0
adiw R24,20
std y+11,R25
std y+10,R24
xjmp L52
L51:
.dbline 226
; while (i < j) //
; { // go thru each IP header option
.dbline 227
; if (!SendDebugStr("\n")) return; //
ldi R16,<L56
ldi R17,>L56
xcall _SendDebugStr
tst R16
brne L54
.dbline 227
xjmp L1
L54:
.dbline 229
; //
; type = MainBuffer[i++]; // option type
ldd R2,y+10
ldd R3,y+11
movw R24,R2
adiw R24,1
std y+11,R25
std y+10,R24
ldi R24,<_MainBuffer
ldi R25,>_MainBuffer
movw R30,R2
add R30,R24
adc R31,R25
ldd R20,z+0
.dbline 230
; len = 0; //
clr R22
.dbline 231
; if (type >= 2) len = MainBuffer[i++]; //
cpi R20,2
brlo L57
.dbline 231
ldd R2,y+10
ldd R3,y+11
movw R24,R2
adiw R24,1
std y+11,R25
std y+10,R24
ldi R24,<_MainBuffer
ldi R25,>_MainBuffer
movw R30,R2
add R30,R24
adc R31,R25
ldd R22,z+0
L57:
.dbline 233
; //
; if (!SendDebugRStr(tcp_str16)) return; //
ldi R16,<_tcp_str16
ldi R17,>_tcp_str16
xcall _SendDebugRStr
tst R16
brne L59
.dbline 233
xjmp L1
L59:
.dbline 235
; //
; switch (type) //
mov R12,R20
clr R13
tst R12
brne X0
tst R13
breq L64
X0:
movw R24,R12
cpi R24,1
ldi R30,0
cpc R25,R30
breq L64
cpi R24,2
ldi R30,0
cpc R25,R30
breq L65
xjmp L61
X1:
.dbline 236
; { //
L64:
.dbline 238
; case 0 : //
; case 1 : sprintf((char*)ScratchPad, "%u", type); //
mov R2,R20
clr R3
std y+1,R3
std y+0,R2
ldi R18,<L4
ldi R19,>L4
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 239
; break; //
xjmp L62
L65:
.dbline 240
; case 2 : w = ntohs(*(u16*)(MainBuffer + i)); // max segment size
ldi R24,<_MainBuffer
ldi R25,>_MainBuffer
ldd R30,y+10
ldd R31,y+11
add R30,R24
adc R31,R25
ldd R16,z+0
ldd R17,z+1
xcall _ntohs
movw R14,R16
.dbline 241
; sprintf((char*)ScratchPad, "%u len:%u %u", type, len, w); //
std y+5,R15
std y+4,R14
mov R2,R22
clr R3
std y+3,R3
std y+2,R2
mov R2,R20
clr R3
std y+1,R3
std y+0,R2
ldi R18,<L66
ldi R19,>L66
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 242
; if (!SendDebugStr((char*)ScratchPad)) return; //
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L62
.dbline 242
xjmp L1
X2:
.dbline 243
; break; //
L61:
.dbline 244
; default : sprintf((char*)ScratchPad, "%u len:%u", type, len); //
mov R2,R22
clr R3
std y+3,R3
std y+2,R2
mov R2,R20
clr R3
std y+1,R3
std y+0,R2
ldi R18,<L69
ldi R19,>L69
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 245
; if (!SendDebugStr((char*)ScratchPad)) return; //
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L62
.dbline 245
xjmp L1
X3:
.dbline 246
; break; //
L62:
.dbline 249
; } //
;
; if (type == 0) break; // end of options
tst R20
brne L72
.dbline 249
xjmp L53
L72:
.dbline 250
; if (type == 1) continue; // no length byte
cpi R20,1
brne L74
.dbline 250
xjmp L52
L74:
.dbline 252
; //
; if (len < 2) len = 2; //
cpi R22,2
brsh L76
.dbline 252
ldi R22,2
L76:
.dbline 254
mov R24,R22
clr R25
sbiw R24,2
ldd R0,y+10
ldd R1,y+11
add R0,R24
adc R1,R25
std y+11,R1
std y+10,R0
.dbline 255
L52:
.dbline 225
ldd R0,y+10
ldd R1,y+11
cp R0,R10
cpc R1,R11
brge X4
xjmp L51
X4:
L53:
.dbline 256
;
; i += (len - 2); // point to next option
; } //
; i = j;
std y+11,R11
std y+10,R10
.dbline 258
;
; if (!SendDebugStr("\n")) return; //
ldi R16,<L56
ldi R17,>L56
xcall _SendDebugStr
tst R16
brne L78
.dbline 258
xjmp L1
L78:
.dbline 262
;
; // done
;
; if (!SendDebugRStr(tcp_str17)) return;
ldi R16,<_tcp_str17
ldi R17,>_tcp_str17
xcall _SendDebugRStr
tst R16
brne L80
.dbline 262
xjmp L1
L80:
.dbline 263
ldd R2,y+22
ldd R3,y+23
ldd R0,y+10
ldd R1,y+11
sub R2,R0
sbc R3,R1
std y+1,R3
std y+0,R2
ldi R18,<L82
ldi R19,>L82
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _sprintf
.dbline 264
ldi R16,<_ScratchPad
ldi R17,>_ScratchPad
xcall _SendDebugStr
tst R16
brne L83
.dbline 264
L83:
.dbline -2
L1:
adiw R28,12
xcall pop_gset5
adiw R28,2
.dbline 0 ; func end
ret
.dbsym r w 14 s
.dbsym l dw 6 l
.dbsym r b 22 c
.dbsym r j 10 I
.dbsym l i 10 I
.dbsym r len 22 c
.dbsym r type 20 c
.dbsym l TotalBytes 22 I
.dbsym r HeaderIdx 20 I
.dbend
.dbfunc e TCP_DisplaySocketStage _TCP_DisplaySocketStage fV
; Socket -> R20,R21
.even
_TCP_DisplaySocketStage::
xcall push_gset1
movw R20,R16
.dbline -1
.dbline 268
; sprintf((char*)ScratchPad, "%u\n", TotalBytes - i);
; if (!SendDebugStr((char*)ScratchPad)) return;
; }
;
; void TCP_DisplaySocketStage(T_TCP_Socket *Socket)
; { // display the tcp socket stage
.dbline 269
; if (Socket == NULL) return;
cpi R20,0
cpc R20,R21
brne L86
X5:
.dbline 269
xjmp L85
L86:
.dbline 271
;
; if (!SendDebugRStr(tcp_str22)) return;
ldi R16,<_tcp_str22
ldi R17,>_tcp_str22
xcall _SendDebugRStr
tst R16
brne L88
.dbline 271
xjmp L85
L88:
.dbline 272
; switch (Socket->Stage)
movw R30,R20
ldd R20,z+0
clr R21
cpi R20,0
cpc R20,R21
breq L93
X6:
cpi R20,1
ldi R30,0
cpc R21,R30
breq L94
cpi R20,2
ldi R30,0
cpc R21,R30
breq L95
cpi R20,3
ldi R30,0
cpc R21,R30
breq L96
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -