/// <summary> /// Retrieves the integer value of first six bits in a byte /// </summary> /// <param name="b"></param> /// <returns></returns> public int GetFirstSix(byte b) { for (int i = 0; i < 6; i++) { sixbits[i] = BitOps.GetBit(b, i); } return(BitOps.GetIntegerValue(sixbits)); }
/// <summary> /// Retrieves the last two bits from a single byte (8 bits) /// </summary> /// <param name="b"></param> /// <returns></returns> public int GetLastTwo(byte b) { byte c = 0; for (int i = 7; i > 5; i--) { twobits[c] = BitOps.GetBit(b, i); c++; } return(BitOps.GetIntegerValue(twobits)); }
/// <summary> /// /// </summary> /// <param name="startingIndex"></param> /// <returns>Integet value</returns> private int Get32BitParameter(int startingIndex) { byte[] seperate = new byte[4]; //First we need to get the bytes to convert. for (int i = 0; i < 4; i++) { // Get each byte seperate[i] = ram.memory[startingIndex + i]; } bool[] b1 = new bool[8]; bool[] b2 = new bool[8]; bool[] b3 = new bool[8]; bool[] b4 = new bool[8]; b1 = BitOps.GetBinaryValue(seperate[0]); b2 = BitOps.GetBinaryValue(seperate[1]); b3 = BitOps.GetBinaryValue(seperate[2]); b4 = BitOps.GetBinaryValue(seperate[3]); b1 = Conversions.BooleanArray.JoinBooleans(b1, b2); b1 = Conversions.BooleanArray.JoinBooleans(b1, b3); b1 = Conversions.BooleanArray.JoinBooleans(b1, b4); return(BitOps.GetIntegerValue(b1)); }