-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathbits.h
More file actions
77 lines (64 loc) · 964 Bytes
/
Copy pathbits.h
File metadata and controls
77 lines (64 loc) · 964 Bytes
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//
// bits.h
// (C) R.P.Bellis 1993 - 2025
//
// vim: ts=8
//
#pragma once
#include "typedefs.h"
// 8 bit operations
inline bool btst(Byte x, int n)
{
return (x & (1 << n)) ? true : false;
}
inline void bset(Byte& x, int n)
{
x |= (1 << n);
}
inline void bclr(Byte& x, int n)
{
x &= ~(1 << n);
}
// 16 bit operations
inline bool btst(Word x, int n)
{
return (x & (1 << n)) ? true : false;
}
inline void bset(Word& x, int n)
{
x |= (1 << n);
}
inline void bclr(Word& x, int n)
{
x &= ~(1 << n);
}
// 32 bit operations
inline bool btst(DWord x, int n)
{
return (x & (1L << n)) ? true : false;
}
inline void bset(DWord& x, int n)
{
x |= (1L << n);
}
inline void bclr(DWord& x, int n)
{
x &= ~(1L << n);
}
// Bit extend operations
inline Word extend5(Byte x)
{
if (x & 0x10) {
return (Word)x | 0xffe0;
} else {
return (Word)x;
}
}
inline Word extend8(Byte x)
{
if (x & 0x80) {
return (Word)x | 0xff00;
} else {
return (Word)x;
}
}