📄 uip_arch.s
字号:
.module uip_arch.c
.area text(rom, con, rel)
.dbfile D:\hexok项目\AVRNET项目\AVRNET光盘\AVRuIP\uip_arch.c
.dbfunc e uip_add32 _uip_add32 fV
; op16 -> R18,R19
; op32 -> R16,R17
.even
_uip_add32::
.dbline -1
.dbline 45
; /*
; * Copyright (c) 2001, Adam Dunkels.
; * All rights reserved.
; *
; * Redistribution and use in source and binary forms, with or without
; * modification, are permitted provided that the following conditions
; * are met:
; * 1. Redistributions of source code must retain the above copyright
; * notice, this list of conditions and the following disclaimer.
; * 2. Redistributions in binary form must reproduce the above copyright
; * notice, this list of conditions and the following disclaimer in the
; * documentation and/or other materials provided with the distribution.
; * 3. The name of the author may not be used to endorse or promote
; * products derived from this software without specific prior
; * written permission.
; *
; * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
; * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
; * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
; * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
; * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
; * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
; * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
; * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
; * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
; * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
; * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
; *
; * This file is part of the uIP TCP/IP stack.
; *
; * $Id: uip_arch.c,v 1.1 2004/05/09 00:24:47 Louis Exp $
; *
; */
;
;
; #include "uip.h"
; #include "uip_arch.h"
;
; #define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN])
; #define IP_PROTO_TCP 6
;
; /*-----------------------------------------------------------------------------------*/
; void
; uip_add32(u8_t *op32, u16_t op16)
; {
.dbline 47
;
; uip_acc32[3] = op32[3] + (op16 & 0xff);
movw R24,R18
andi R25,0
movw R30,R16
ldd R2,z+3
clr R3
add R2,R24
adc R3,R25
sts _uip_acc32+3,R2
.dbline 48
; uip_acc32[2] = op32[2] + (op16 >> 8);
movw R2,R18
mov R2,R3
clr R3
movw R30,R16
ldd R4,z+2
clr R5
add R4,R2
adc R5,R3
sts _uip_acc32+2,R4
.dbline 49
; uip_acc32[1] = op32[1];
movw R30,R16
ldd R2,z+1
sts _uip_acc32+1,R2
.dbline 50
; uip_acc32[0] = op32[0];
movw R30,R16
ldd R2,z+0
sts _uip_acc32,R2
.dbline 52
;
; if(uip_acc32[2] < (op16 >> 8)) {
movw R2,R18
mov R2,R3
clr R3
lds R4,_uip_acc32+2
clr R5
cp R4,R2
cpc R5,R3
brsh L11
.dbline 52
.dbline 53
; ++uip_acc32[1];
lds R24,_uip_acc32+1
subi R24,255 ; addi 1
sts _uip_acc32+1,R24
.dbline 54
; if(uip_acc32[1] == 0) {
lds R2,_uip_acc32+1
tst R2
brne L15
.dbline 54
.dbline 55
; ++uip_acc32[0];
lds R24,_uip_acc32
subi R24,255 ; addi 1
sts _uip_acc32,R24
.dbline 56
; }
L15:
.dbline 57
; }
L11:
.dbline 59
;
; if(uip_acc32[3] < (op16 & 0xff)) {
movw R24,R18
andi R25,0
lds R2,_uip_acc32+3
clr R3
cp R2,R24
cpc R3,R25
brsh L18
.dbline 59
.dbline 60
; ++uip_acc32[2];
lds R24,_uip_acc32+2
subi R24,255 ; addi 1
sts _uip_acc32+2,R24
.dbline 61
; if(uip_acc32[2] == 0) {
lds R2,_uip_acc32+2
tst R2
brne L22
.dbline 61
.dbline 62
; ++uip_acc32[1];
lds R24,_uip_acc32+1
subi R24,255 ; addi 1
sts _uip_acc32+1,R24
.dbline 63
; if(uip_acc32[1] == 0) {
lds R2,_uip_acc32+1
tst R2
brne L26
.dbline 63
.dbline 64
; ++uip_acc32[0];
lds R24,_uip_acc32
subi R24,255 ; addi 1
sts _uip_acc32,R24
.dbline 65
; }
L26:
.dbline 66
; }
L22:
.dbline 67
L18:
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbsym r op16 18 s
.dbsym r op32 16 pc
.dbend
.dbfunc e uip_chksum _uip_chksum fs
; acc -> R10,R11
; len -> R12,R13
; sdata -> R14,R15
.even
_uip_chksum::
xcall push_gset5x
movw R12,R18
movw R14,R16
.dbline -1
.dbline 72
; }
; }
; /*-----------------------------------------------------------------------------------*/
; u16_t
; uip_chksum(u16_t *sdata, u16_t len)
; {
.dbline 75
clr R10
clr R11
xjmp L33
L30:
.dbline 75
; u16_t acc;
;
; for(acc = 0; len > 1; len -= 2) {
.dbline 76
; acc += *sdata;
movw R30,R14
ldd R2,z+0
ldd R3,z+1
add R10,R2
adc R11,R3
.dbline 77
; if(acc < *sdata) {
cp R10,R2
cpc R11,R3
brsh L34
.dbline 77
.dbline 80
; /* Overflow, so we add the carry to acc (i.e., increase by
; one). */
; ++acc;
movw R24,R10
adiw R24,1
movw R10,R24
.dbline 81
; }
L34:
.dbline 82
movw R24,R14
adiw R24,2
movw R14,R24
.dbline 83
L31:
.dbline 75
movw R24,R12
sbiw R24,2
movw R12,R24
L33:
.dbline 75
ldi R24,1
ldi R25,0
cp R24,R12
cpc R25,R13
brlo L30
.dbline 86
; ++sdata;
; }
;
; /* add up any odd byte */
; if(len == 1) {
movw R24,R12
cpi R24,1
ldi R30,0
cpc R25,R30
brne L36
.dbline 86
.dbline 87
; acc += htons(((u16_t)(*(u8_t *)sdata)) << 8);
movw R30,R14
ldd R16,z+0
clr R17
mov R17,R16
clr R16
xcall _htons
add R10,R16
adc R11,R17
.dbline 88
; if(acc < htons(((u16_t)(*(u8_t *)sdata)) << 8)) {
movw R30,R14
ldd R16,z+0
clr R17
mov R17,R16
clr R16
xcall _htons
cp R10,R16
cpc R11,R17
brsh L38
.dbline 88
.dbline 89
; ++acc;
movw R24,R10
adiw R24,1
movw R10,R24
.dbline 90
; }
L38:
.dbline 91
; }
L36:
.dbline 93
;
; return acc;
movw R16,R10
.dbline -2
L29:
xcall pop_gset5x
.dbline 0 ; func end
ret
.dbsym r acc 10 s
.dbsym r len 12 s
.dbsym r sdata 14 ps
.dbend
.dbfunc e uip_ipchksum _uip_ipchksum fs
.even
_uip_ipchksum::
.dbline -1
.dbline 98
; }
; /*-----------------------------------------------------------------------------------*/
; u16_t
; uip_ipchksum(void)
; {
.dbline 99
; return uip_chksum((u16_t *)&uip_buf[UIP_LLH_LEN], 20);
ldi R18,20
ldi R19,0
ldi R16,<_uip_buf+14
ldi R17,>_uip_buf+14
xcall _uip_chksum
.dbline -2
L40:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uip_tcpchksum _uip_tcpchksum fs
; hsum -> R12,R13
; sum -> R10,R11
.even
_uip_tcpchksum::
xcall push_gset4x
.dbline -1
.dbline 104
; }
; /*-----------------------------------------------------------------------------------*/
; u16_t
; uip_tcpchksum(void)
; {
.dbline 109
; u16_t hsum, sum;
;
;
; /* Compute the checksum of the TCP header. */
; hsum = uip_chksum((u16_t *)&uip_buf[20 + UIP_LLH_LEN], 20);
ldi R18,20
ldi R19,0
ldi R16,<_uip_buf+34
ldi R17,>_uip_buf+34
xcall _uip_chksum
movw R12,R16
.dbline 113
;
; /* Compute the checksum of the data in the TCP packet and add it to
; the TCP header checksum. */
; sum = uip_chksum((u16_t *)uip_appdata,
lds R2,_uip_buf+14+2+1
lds R3,_uip_buf+14+2
mov R19,R3
mov R18,R2
subi R18,40
sbci R19,0
lds R16,_uip_appdata
lds R17,_uip_appdata+1
xcall _uip_chksum
movw R10,R16
.dbline 116
; (u16_t)(((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - 40)));
;
; if((sum += hsum) < hsum) {
movw R2,R10
add R2,R12
adc R3,R13
movw R10,R2
cp R10,R12
cpc R11,R13
brsh L49
.dbline 116
.dbline 117
; ++sum;
movw R24,R2
adiw R24,1
movw R10,R24
.dbline 118
; }
L49:
.dbline 120
;
; if((sum += BUF->srcipaddr[0]) < BUF->srcipaddr[0]) {
lds R2,_uip_buf+14+12
lds R3,_uip_buf+14+12+1
movw R4,R10
add R4,R2
adc R5,R3
movw R10,R4
cp R10,R2
cpc R11,R3
brsh L51
.dbline 120
.dbline 121
; ++sum;
movw R24,R4
adiw R24,1
movw R10,R24
.dbline 122
; }
L51:
.dbline 123
; if((sum += BUF->srcipaddr[1]) < BUF->srcipaddr[1]) {
lds R2,_uip_buf+14+12+2
lds R3,_uip_buf+14+12+2+1
movw R4,R10
add R4,R2
adc R5,R3
movw R10,R4
cp R10,R2
cpc R11,R3
brsh L57
.dbline 123
.dbline 124
; ++sum;
movw R24,R4
adiw R24,1
movw R10,R24
.dbline 125
; }
L57:
.dbline 126
; if((sum += BUF->destipaddr[0]) < BUF->destipaddr[0]) {
lds R2,_uip_buf+14+16
lds R3,_uip_buf+14+16+1
movw R4,R10
add R4,R2
adc R5,R3
movw R10,R4
cp R10,R2
cpc R11,R3
brsh L65
.dbline 126
.dbline 127
; ++sum;
movw R24,R4
adiw R24,1
movw R10,R24
.dbline 128
; }
L65:
.dbline 129
; if((sum += BUF->destipaddr[1]) < BUF->destipaddr[1]) {
lds R2,_uip_buf+14+16+2
lds R3,_uip_buf+14+16+2+1
movw R4,R10
add R4,R2
adc R5,R3
movw R10,R4
cp R10,R2
cpc R11,R3
brsh L71
.dbline 129
.dbline 130
; ++sum;
movw R24,R4
adiw R24,1
movw R10,R24
.dbline 131
; }
L71:
.dbline 132
; if((sum += (u16_t)htons((u16_t)IP_PROTO_TCP)) < (u16_t)htons((u16_t)IP_PROTO_TCP)) {
ldi R16,6
ldi R17,0
xcall _htons
movw R2,R10
add R2,R16
adc R3,R17
movw R10,R2
ldi R16,6
ldi R17,0
push R10
push R11
xcall _htons
pop R3
pop R2
cp R2,R16
cpc R3,R17
brsh L79
.dbline 132
.dbline 133
; ++sum;
movw R24,R10
adiw R24,1
movw R10,R24
.dbline 134
; }
L79:
.dbline 136
;
; hsum = (u16_t)htons((((u16_t)(BUF->len[0]) << 8) + BUF->len[1]) - 20);
lds R2,_uip_buf+14+2+1
lds R3,_uip_buf+14+2
mov R17,R3
mov R16,R2
subi R16,20
sbci R17,0
xcall _htons
movw R12,R16
.dbline 138
;
; if((sum += hsum) < hsum) {
movw R2,R10
add R2,R16
adc R3,R17
movw R10,R2
cp R10,R12
cpc R11,R13
brsh L86
.dbline 138
.dbline 139
; ++sum;
movw R24,R2
adiw R24,1
movw R10,R24
.dbline 140
; }
L86:
.dbline 142
;
; return sum;
movw R16,R10
.dbline -2
L42:
xcall pop_gset4x
.dbline 0 ; func end
ret
.dbsym r hsum 12 s
.dbsym r sum 10 s
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -