blob: f15f3fd406c577d7f0c123f43893d29c910c6c52 (
plain) (
blame)
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
|
# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
include <mach.h>
task sbit, tbit
define NWORDS 1 # limited to 1 longword at present
# SBIT, TBIT -- Test the bitpak and bitupk primitives.
procedure sbit()
int b[NWORDS]
int offset, nbits, value, i
int bitupk(), clgeti()
begin
offset = clgeti ("offset")
nbits = clgeti ("nbits")
value = clgeti ("value")
if (offset < 1 || offset > NWORDS * NBITS_INT)
call error (1, "bit offset out of range")
call bitpak (value, b, offset, nbits)
call printf ("\n")
call printf ("\t21098765432109876543210987654321\n")
call printf ("\t 3 2 1 0\n")
do i = 1, NWORDS {
call printf ("%4d\t%032r2 (%011oB)\n")
call pargi ((i-1) * 32 + 1)
call pargi (b[i])
call pargi (b[i])
}
return
entry tbit()
offset = clgeti ("offset")
nbits = clgeti ("nbits")
call printf ("bitfield=%d\n")
call pargi (bitupk (b, offset, nbits))
end
|