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

📄 ffs.s

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 S
字号:
/*	@(#)ffs.s	4.1	(ULTRIX)	7/3/90				      *//* ------------------------------------------------------------------ *//* | Copyright Unpublished, MIPS Computer Systems, Inc.  All Rights | *//* | Reserved.  This software contains proprietary and confidential | *//* | information of MIPS and its suppliers.  Use, disclosure or     | *//* | reproduction is prohibited without the prior express written   | *//* | consent of MIPS.                                               | *//* ------------------------------------------------------------------ *//* $Header: ffs.s,v 1.1 87/02/16 11:17:26 dce Exp $ */#include <mips/regdef.h>#include <mips/asm.h>/* * ffs(word) * find first bit set in word (a la VAX instruction) * looks at low order bits first, lowest order bit is 1, highest bit is 32 * no bits returns 0 */LEAF(ffs)	.set	noreorder	move	v0,zero	beq	a0,zero,2f		# no bits set, return zero1:	and	v1,a0,1	addu	v0,1	beq	v1,zero,1b	srl	a0,1			# BDSLOT: shift right to next bit2:	j	ra	nop	.set	reorder.end ffs#ifdef notdefLEAF(ffs)	move	v1,zero			# initial table offset	and	v0,a0,0xffff		# check lower halfword	bne	v0,zero,1f		# bits in lower halfword	addu	v1,64			# table offset for halfword	srl	a0,16			# check upper halfword1:	and	v0,a0,0xff		# check lower byte of halfword	bne	v0,zero,2f		# bits in lower byte	addu	v1,32			# table offset for byte	srl	a0,8			# check upper byte of halfword2:	and	v0,a0,0xf		# check lower nibble	bne	v0,zero,3f		# bits in lower nibble	addu	v1,16			# table offset for nibble	srl	v0,a0,4			# check upper nibble	and	v0,0xf3:	addu	v1,v0			# total table offset	lbu	v0,ffstbl(v1)		# load bit number from table	j	ra.end ffs	.data#define NIBBLE(x) \	.byte	0,       1+(x)*4, 2+(x)*4, 1+(x)*4; \	.byte	3+(x)*4, 1+(x)*4, 2+(x)*4, 1+(x)*4; \	.byte	4+(x)*4, 1+(x)*4, 2+(x)*4, 1+(x)*4; \	.byte	3+(x)*4, 1+(x)*4, 2+(x)*4, 1+(x)*4ffstbl:	NIBBLE(0)	NIBBLE(1)	NIBBLE(2)	NIBBLE(3)	NIBBLE(4)	NIBBLE(5)	NIBBLE(6)	NIBBLE(7)#endif notdef

⌨️ 快捷键说明

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