|
|
1.1 root 1: .TI F77/BITS "June 15, 1985"
2: Bit Manipulation: Octal, Hexadecimal and Binary
3:
4: The built-in bit manipulation functions:
5:
6: .nf
7: and, or, xor, not, rshift, lshift
8: .fi
9:
10: are described in "man 3f bit". That manual section
11: also illustrates how to use them to set, clear,
12: and access bits within words.
13:
14: Bit strings can be used in data statements:
15:
16: .nf
17: integer a(3)
18: data a/b'1010', o'12', z'a'/
19: .fi
20:
21: These statements initialize the three elements of a() to the
22: decimal value 10 using
23: binary, octal and hexadecimal constants.
24:
25: When using bit strings and bit manipulation, be careful as
26: VAXs access memory bytes in a different order depending on whether
27: the operand is a byte, word, long word or character string.
28:
29: Values can be printed out in octal and hex by using the 'o' and 'z'
30: format terms. The program:
31: .nf
32:
33: i = 125
34: print 100, i, i, i
35: 100 format(' decimal: octal: hex:'/ i10, o10, z10 )
36: end
37:
38: prints:
39:
40: decimal: octal: hex:
41: 125 175 7d
42:
43: .fi
44: The next sample illustrates how to use the unsigned format specifier, 'su',
45: to treat the sign as an ordinary bit and how to print leading blanks as zeros:
46: .nf
47:
48: i = -127
49: j = 63
50: print 100, i, i, j, j
51: 100 format('hex: ',su,z8.8/ 'octal: ', o11.11)
52: end
53:
54: prints:
55:
56: hex: ffffff81
57: octal: 37777777601
58: hex: 0000003f
59: octal: 00000000077
60:
61: .fi
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.