mirror of
https://github.com/MoleskiCoder/EightBitNet.git
synced 2026-04-20 21:16:29 +00:00
Add Z80 processor (untested, but complete)
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
@@ -51,5 +51,23 @@ namespace EightBit
|
||||
public static int PromoteNibble(byte value) => LowByte(value << 4);
|
||||
|
||||
public static int DemoteNibble(byte value) => HighNibble(value);
|
||||
|
||||
public static int CountBits(int value)
|
||||
{
|
||||
int count = 0;
|
||||
while (value != 0)
|
||||
{
|
||||
++count;
|
||||
value &= value - 1;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public static int CountBits(byte value) => CountBits((int)value);
|
||||
|
||||
public static bool EvenParity(int value) => CountBits(value) % 2 == 0;
|
||||
|
||||
public static bool EvenParity(byte value) => EvenParity((int)value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user