示例#1
0
 public void Free()
 {
     Instructions.Movi(_cpu, Register.A, 10);
     Instructions.Alloc(_cpu, Register.A, Register.B);
     Assert.That(B, Is.Not.EqualTo(0));
     Instructions.FreeMemory(_cpu, Register.B);
 }
示例#2
0
        public void MemoryClear()
        {
            Instructions.Movi(_cpu, Register.A, 10);
            Instructions.Alloc(_cpu, Register.A, Register.B);

            Instructions.Movi(_cpu, Register.A, 0x12345678);
            Instructions.Pushr(_cpu, Register.B);
            Instructions.Movrm(_cpu, Register.B, Register.A);
            Instructions.Addi(_cpu, Register.B, 4);
            Instructions.Movrm(_cpu, Register.B, Register.A);
            Instructions.Addi(_cpu, Register.B, 4);
            Instructions.Movrm(_cpu, Register.B, Register.A);
            Instructions.Popr(_cpu, Register.B);

            var value = BitConverter.ToUInt64(_ram, _heapOffset);

            Assert.That(value, Is.EqualTo(0x1234567812345678));

            Instructions.Pushr(_cpu, Register.B);
            Instructions.Addi(_cpu, Register.B, 1);
            Instructions.Movi(_cpu, Register.A, 4);
            Instructions.MemoryClear(_cpu, Register.B, Register.A);
            Instructions.Popr(_cpu, Register.B);

            value = BitConverter.ToUInt64(_ram, _heapOffset);
            Console.WriteLine(value.ToString("x8"));
            Assert.That(value, Is.EqualTo(0x1234560000000078));

            Instructions.FreeMemory(_cpu, Register.B);
        }
示例#3
0
        public void Alloc()
        {
            int count = _cpu.CurrentProcess.PageTable.Count();

            Instructions.Movi(_cpu, Register.A, 10);
            Instructions.Alloc(_cpu, Register.A, Register.B);
            Assert.That(_cpu.CurrentProcess.PageTable.Count(), Is.EqualTo(count + 1));
        }
示例#4
0
        public void Movmr()
        {
            Instructions.Movi(_cpu, Register.A, 10);
            Instructions.Alloc(_cpu, Register.A, Register.B);

            Array.Copy(BitConverter.GetBytes(88), 0, _ram, _heapOffset, 4);

            Instructions.Movmr(_cpu, Register.A, Register.B);

            Assert.That(A, Is.EqualTo(88));
        }
示例#5
0
        public void Printm()
        {
            var printStack = new Stack <uint>();

            _cpu.PrintMethod = printStack.Push;

            Instructions.Movi(_cpu, Register.A, 4);
            Instructions.Alloc(_cpu, Register.A, Register.B);
            Instructions.Movi(_cpu, Register.A, 99);
            Instructions.Movrm(_cpu, Register.B, Register.A);
            Instructions.Printm(_cpu, Register.B);
            Assert.That(printStack.Peek(), Is.EqualTo(99));
        }
示例#6
0
        public void Movrm()
        {
            Instructions.Movi(_cpu, Register.A, 10);
            Instructions.Alloc(_cpu, Register.A, Register.B);

            Instructions.Movi(_cpu, Register.A, 88);
            Instructions.Movrm(_cpu, Register.B, Register.A);

            var heap  = GetHeap();
            var value = BitConverter.ToUInt32(_ram, _heapOffset);

            Assert.That(value, Is.EqualTo(88));
        }
示例#7
0
        public void Movmm()
        {
            Instructions.Movi(_cpu, Register.A, 4);
            Instructions.Alloc(_cpu, Register.A, Register.B);
            Instructions.Alloc(_cpu, Register.A, Register.C);

            Array.Copy(BitConverter.GetBytes(88), 0, _ram, _heapOffset, 4);

            Instructions.Movmm(_cpu, Register.C, Register.B);

            var value = BitConverter.ToUInt32(_ram, (int)(_heapOffset + _cpu.Ram.FrameSize));

            Assert.That(value, Is.EqualTo(88));
        }