forked from adesutherland/CMS-370-BREXX
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitand.c
55 lines (47 loc) · 1.25 KB
/
bitand.c
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
/*
* Lbitand for CMS
*/
#include "lstring.h"
/* ---------------- Lbitand ------------------ */
void __CDECL
Lbitand(const PLstr to, const PLstr s1, const PLstr s2,
const bool usepad, const char pad) {
long i;
/* Needed to store intermediate results - perhaps GCCMVS can only do AND with ints - who knows ... */
unsigned int v1, v2, res;
L2STR(s1);
L2STR(s2);
if (LLEN(*s1) < LLEN(*s2)) {
Lstrcpy(to, s2);
for (i = 0; i < LLEN(*s1); i++) {
v1 = LSTR(*s1)[i];
v2 = LSTR(*s2)[i];
res = v1 & v2;
LSTR(*to)[i] = res;
}
if (usepad) {
v1 = pad;
for (; i < LLEN(*s2); i++) {
v2 = LSTR(*s2)[i];
res = v1 & v2;
LSTR(*to)[i] = res;
}
}
} else {
Lstrcpy(to, s1);
for (i = 0; i < LLEN(*s2); i++) {
v1 = LSTR(*s1)[i];
v2 = LSTR(*s2)[i];
res = v1 & v2;
LSTR(*to)[i] = res;
}
if (usepad) {
v2 = pad;
for (; i < LLEN(*s1); i++) {
v1 = LSTR(*s1)[i];
res = v1 & v2;
LSTR(*to)[i] = res;
}
}
}
} /* Lbitand */