Debian Codegraph @

gcc/m2/gm2-libs-log/BitByteOps.def

raw
1 (* BitByteOps.def provides a Logitech-3.0 compatible library.
2
3 Copyright (C) 2007-2025 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <[email protected]>.
5
6 This file is part of GNU Modula-2.
7
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
11 any later version.
12
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
17
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
21
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
26
27 DEFINITION MODULE BitByteOps ;
28
29 FROM SYSTEM IMPORT BYTE ;
30
31
32 (*
33 GetBits - returns the bits firstBit..lastBit from source.
34 Bit 0 of byte maps onto the firstBit of source.
35 *)
36
37 PROCEDURE GetBits (source: BYTE; firstBit, lastBit: CARDINAL) : BYTE ;
38
39
40 (*
41 SetBits - sets bits in, byte, starting at, firstBit, and ending at,
42 lastBit, with, pattern. The bit zero of, pattern, will
43 be placed into, byte, at position, firstBit.
44 *)
45
46 PROCEDURE SetBits (VAR byte: BYTE; firstBit, lastBit: CARDINAL;
47 pattern: BYTE) ;
48
49
50 (*
51 ByteAnd - returns a bitwise (left AND right)
52 *)
53
54 PROCEDURE ByteAnd (left, right: BYTE) : BYTE ;
55
56
57 (*
58 ByteOr - returns a bitwise (left OR right)
59 *)
60
61 PROCEDURE ByteOr (left, right: BYTE) : BYTE ;
62
63
64 (*
65 ByteXor - returns a bitwise (left XOR right)
66 *)
67
68 PROCEDURE ByteXor (left, right: BYTE) : BYTE ;
69
70
71 (*
72 ByteNot - returns a byte with all bits inverted.
73 *)
74
75 PROCEDURE ByteNot (byte: BYTE) : BYTE ;
76
77
78 (*
79 ByteShr - returns a, byte, which has been shifted, count
80 bits to the right.
81 *)
82
83 PROCEDURE ByteShr (byte: BYTE; count: CARDINAL) : BYTE ;
84
85
86 (*
87 ByteShl - returns a, byte, which has been shifted, count
88 bits to the left.
89 *)
90
91 PROCEDURE ByteShl (byte: BYTE; count: CARDINAL) : BYTE ;
92
93
94 (*
95 ByteSar - shift byte arthemetic right. Preserves the top
96 end bit and as the value is shifted right.
97 *)
98
99 PROCEDURE ByteSar (byte: BYTE; count: CARDINAL) : BYTE ;
100
101
102 (*
103 ByteRor - returns a, byte, which has been rotated, count
104 bits to the right.
105 *)
106
107 PROCEDURE ByteRor (byte: BYTE; count: CARDINAL) : BYTE ;
108
109
110 (*
111 ByteRol - returns a, byte, which has been rotated, count
112 bits to the left.
113 *)
114
115 PROCEDURE ByteRol (byte: BYTE; count: CARDINAL) : BYTE ;
116
117
118 (*
119 HighNibble - returns the top nibble only from, byte.
120 The top nibble of, byte, is extracted and
121 returned in the bottom nibble of the return
122 value.
123 *)
124
125 PROCEDURE HighNibble (byte: BYTE) : BYTE ;
126
127
128 (*
129 LowNibble - returns the low nibble only from, byte.
130 The top nibble is replaced by zeros.
131 *)
132
133 PROCEDURE LowNibble (byte: BYTE) : BYTE ;
134
135
136 (*
137 Swap - swaps the low and high nibbles in the, byte.
138 *)
139
140 PROCEDURE Swap (byte: BYTE) : BYTE ;
141
142
143 END BitByteOps.