示例#1
0
文件: TestBase.cs 项目: claassen/CmC
        public void AssertValueAtMemoryByDereferencingValueAtStackOffset(int offset, int value, int size)
        {
            int stackValue  = _cpu.Memory.Get(_cpu.Registers[RIVM.Register.BP] + offset, false, 4);
            int memoryValue = BitHelper.ExtractBytes(_cpu.Memory.Get(stackValue, false, size), size);

            Assert.AreEqual(value, memoryValue);
        }
示例#2
0
文件: TestBase.cs 项目: claassen/CmC
 public void AssertStackOffsetValue(int offset, int value, int size)
 {
     Assert.AreEqual(
         value,
         BitHelper.ExtractBytes(_cpu.Memory.Get(_cpu.Registers[RIVM.Register.BP] + offset, false, size), size)
         );
 }
示例#3
0
        protected override void ExecuteImpl(CPU cpu)
        {
            int val4 = cpu.Memory[cpu.Registers[_r2]];
            int val  = BitHelper.ExtractBytes(val4, _memoryAccessSize);

            cpu.Registers[_r1] = val;
        }
示例#4
0
文件: Debugger.cs 项目: claassen/RIVM
        private void updateMemoryDisplay()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("address", typeof(string)));
            dt.Columns.Add(new DataColumn("value", typeof(string)));
            dt.Columns.Add(new DataColumn("instruction", typeof(String)));

            int start = _memoryDisplayStartAddress;
            int end   = start + 1000;

            for (int address = start; address < end;)
            {
                if (_memoryDisplaySize == 4)
                {
                    int machineCode = _vm.cpu.Memory.Get(address, false, 4);

                    object[] firstRowData = new object[3];
                    firstRowData[0] = address;
                    firstRowData[1] = machineCode;

                    address += 4;

                    Instruction instruction = InstructionDecoder.Decode(machineCode);

                    if (instruction.HasImmediate)
                    {
                        instruction.Immediate = _vm.cpu.Memory.Get(address, false, 4);
                        address += 4;
                    }

                    firstRowData[2] = instruction.ToString();
                    dt.Rows.Add(firstRowData);

                    if (instruction.HasImmediate)
                    {
                        dt.Rows.Add(address - 4, instruction.Immediate, "[immediate value]");
                    }
                }
                else
                {
                    int value = BitHelper.ExtractBytes(_vm.cpu.Memory.Get(address, false, 1), 1);
                    dt.Rows.Add(address, value, "");
                    address++;
                }
            }

            memoryGridView.Invoke((MethodInvoker)(() =>
            {
                memoryGridView.DataSource = dt;
            }));
        }
示例#5
0
 public void Extract(byte[] arr)
 {
     version        = (byte)BitHelper.ExtractBits(arr, offset * 8, 4);
     ihl            = (byte)BitHelper.ExtractBits(arr, offset * 8 + 4, 4);
     diffserv       = BitHelper.Extract8(arr, offset + 1);
     totalLen       = BitHelper.Extract16(arr, offset + 2);
     identification = BitHelper.Extract16(arr, offset + 4);
     flags          = (byte)BitHelper.ExtractBits(arr, offset + 48, 3);
     fragOffset     = BitHelper.ExtractBits(arr, offset + 51, 13);
     ttl            = BitHelper.Extract8(arr, offset + 8);
     protocol       = BitHelper.Extract8(arr, offset + 9);
     hdrChecksum    = BitHelper.Extract16(arr, offset + 10);
     srcAddr        = BitHelper.Extract32(arr, offset + 12);
     dstAddr        = BitHelper.Extract32(arr, offset + 16);
     options        = BitHelper.ExtractBytes(arr, offset + 20, length - 20);
 }
示例#6
0
 protected override void ExecuteImpl(CPU cpu)
 {
     cpu.Registers[_r1] = BitHelper.ExtractBytes(cpu.Memory[cpu.Registers[_r2] + Immediate], _memoryAccessSize);
 }