📄 in_checksum.s
字号:
/* @(#)in_checksum.s 4.1 (ULTRIX) 7/2/90 *//************************************************************************ * * * Copyright (c) 1988 by * * Digital Equipment Corporation, Maynard, MA * * All rights reserved. * * * * This software is furnished under a license and may be used and * * copied only in accordance with the terms of such license and * * with the inclusion of the above copyright notice. This * * software or any other copies thereof may not be provided or * * otherwise made available to any other person. No title to and * * ownership of the software is hereby transferred. * * * * This software is derived from software received from the * * University of California, Berkeley, and from Bell * * Laboratories. Use, duplication, or disclosure is subject to * * restrictions under license agreements with University of * * California and with AT&T. * * * * The information in this software is subject to change without * * notice and should not be construed as a commitment by Digital * * Equipment Corporation. * * * * Digital assumes no responsibility for the use or reliability * * of its software on equipment which is not supplied by Digital. * * * ************************************************************************/#include <machine/asm.h>#include <machine/regdef.h>/* * in_checksum(addr, len, prevcksum) * * Calculates a 16 bit ones-complement checksum. * Note that for a big-endian machine, this routine always adds even * address bytes to the high order 8 bits of the 16 bit checksum and * odd address bytes are added to the low order 8 bits of the 16 bit checksum. * For little-endian machines, this routine always adds even address bytes * to the low order 8 bits of the 16 bit checksum and the odd address bytes * to the high order 8 bits of the 16 bit checksum. */LEAF(in_checksum) move v0,a2 # copy previous checksum beq a1,zero,4f # count exhausted and v1,a0,1 beq v1,zero,2f # already on a halfword boundry lbu t8,0(a0) addu a0,1#ifdef MIPSEL sll t8,8#endif MIPSEL addu v0,t8 subu a1,1 b 2f1: lhu t8,0(a0) addu a0,2 addu v0,t8 subu a1,22: bge a1,2,1b beq a1,zero,3f # no trailing byte lbu t8,0(a0)#ifdef MIPSEB sll t8,8#endif MIPSEB addu v0,t83: srl v1,v0,16 # add in all previous wrap around carries and v0,0xffff addu v0,v1 srl v1,v0,16 # wrap-arounds could cause carry, also addu v0,v1 and v0,0xffff4: j ra END(in_checksum)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -