1 /*
2  * Copyright (c) 2014 The KnightOS Group
3  * Modified to support the eZ80 processor by CEmu developers
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6  * documentation files (the "Software"), to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
8  * and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in all copies or substantial portions
11  * of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
14  * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
16  * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17  * DEALINGS IN THE SOFTWARE.
18 */
19 
20 #include "registers.h"
21 
parity(uint8_t x)22 int parity(uint8_t x) {
23     x ^= x >> 4;
24     x ^= x >> 2;
25     x ^= x >> 1;
26     return x & 1;
27 }
28