xref: /csrg-svn/usr.bin/f77/libF77/bit.c (revision 10440)
1*10440Sdlw /*
2*10440Sdlw  *	"@(#)bit.c	1.1"
3*10440Sdlw  *
4*10440Sdlw  * bit set, clear, test routines
5*10440Sdlw  *
6*10440Sdlw  * calling sequences:
7*10440Sdlw  *	logical l, bit, state
8*10440Sdlw  *	call bis (bitnum, word)
9*10440Sdlw  *	call bic (bitnum, word)
10*10440Sdlw  *	call setbit (bitnum, word, state)
11*10440Sdlw  *	l = bit (bitnum, word)
12*10440Sdlw  * where:
13*10440Sdlw  *	bis(bic) sets(clears) bitnum in word
14*10440Sdlw  *	setbit sets bitnum in word to 1 if state is .true.
15*10440Sdlw  *	bit tests bitnum in word and returns a logical (t/f) value
16*10440Sdlw  */
17*10440Sdlw 
bis_(n,w)18*10440Sdlw long bis_(n, w)
19*10440Sdlw long *n, *w;
20*10440Sdlw {
21*10440Sdlw 	if (*n >= 0 && *n <= 31)
22*10440Sdlw 		*w |= (1L << (*n));
23*10440Sdlw }
24*10440Sdlw 
bic_(n,w)25*10440Sdlw long bic_(n, w)
26*10440Sdlw long *n, *w;
27*10440Sdlw {
28*10440Sdlw 	if (*n >= 0 && *n <= 31)
29*10440Sdlw 		*w &= ~(1L << (*n));
30*10440Sdlw }
31*10440Sdlw 
bit_(n,w)32*10440Sdlw long bit_(n, w)
33*10440Sdlw long *n, *w;
34*10440Sdlw {
35*10440Sdlw 	if (*n < 0 || *n > 31)
36*10440Sdlw 		return(0);
37*10440Sdlw 	return((*w & (1L << (*n))) != 0);
38*10440Sdlw }
39*10440Sdlw 
setbit_(n,w,s)40*10440Sdlw setbit_(n, w, s)
41*10440Sdlw long *n, *w, *s;
42*10440Sdlw {
43*10440Sdlw 	if (*s)
44*10440Sdlw 		bis_(n, w);
45*10440Sdlw 	else
46*10440Sdlw 		bic_(n, w);
47*10440Sdlw }
48