1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <mach.h>
# ISHIFT -- integer shift. To be used for calls to ISHIFT in NCAR routines.
int procedure ishift (in_word, n)
int in_word, n
int new_word, bit, index, i
int bitupk()
begin
if (n > NBITS_INT)
call error (0, "n > NBITS_INT in ishift")
if (n < 0)
# Right end-off shift
new_word = bitupk (in_word, abs(n) + 1, NBITS_INT - abs(n))
else {
# Left circular shift (rotate)
do i = 1, NBITS_INT {
index = n + i
if (index > NBITS_INT)
index = mod ((n + i), NBITS_INT)
bit = bitupk (in_word, i, 1)
call bitpak (bit, new_word, index, 1)
}
}
return (new_word)
end
# IAND -- AND two integers.
int procedure iand (a, b)
int a, b
int and()
begin
return (and (a, b))
end
# IOR -- OR two integers.
int procedure ior (a, b)
int a, b
int or()
begin
return (or (a, b))
end
|