コード例 #1
0
 /// <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));
 }
コード例 #2
0
        /// <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));
        }
コード例 #3
0
 /// <summary>
 /// Retrieves the data stored in each register half (AL/AH, BL/BH, CL/CH), returning the integer value
 /// If the specified register isn't A/B/C, throw a new exception.
 /// </summary>
 /// <param name="Register"></param>
 /// <returns>Two halves of the specified register combined into one integer</returns>
 public int GetSplit(char Register)
 {
     if (Register == 'A')
     {
         return(BitOps.CombineBytes(AL, AH));
     }
     else if (Register == 'B')
     {
         return(BitOps.CombineBytes(BL, BH));
     }
     else if (Register == 'C')
     {
         return(BitOps.CombineBytes(CL, CH));
     }
     throw new Exception("There was an internal error and the VM has had to close.");
 }
コード例 #4
0
 /// <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));
 }