Add Z80 processor (untested, but complete)

Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
Adrian Conlon
2019-02-16 21:32:34 +00:00
parent 3108a373d7
commit ea82c58777
11 changed files with 2213 additions and 14 deletions
+18
View File
@@ -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);
}
}