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); }
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); }
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)); }
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)); }
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)); }
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)); }
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)); }