public void Free(int start) { int idx = Segments.FindIndex(i => i.Start == start); Segments.RemoveAt(idx); Last = null; }
private void LoadSymbols(byte[] prg, int start) { ProgramReader r = new ProgramReader(prg, start); while (r.GetCounter() < Functions[0] + start) { string str = r.NextString(); RangeContainer c = MMU.Alloc(str.Length + 1); Array.Copy(str.Select(i => (byte)i).ToArray(), c.Memory, str.Length); } }
private void ComputeLast(uint dest) { try { if (Last == null || !Last.ContainsAddress(dest)) { Last = Segments.First(i => i.Start <= dest && i.End >= dest); } } catch (Exception e) { throw new Exception("Segmentation Fault"); } }
public RangeContainer Alloc(int size) { int start = 0; if (Segments.Any()) { start = Segments.Last().End + 1; } RangeContainer container = new RangeContainer(start, size); Last = container; Segments.Add(container); return(container); }
public StackContainer(RangeContainer memory, int counter) { ProgramCounter = counter; Memory = memory; }
public LibStackContainer(string lib, string fct, RangeContainer memory) : base(memory, 0) { Library = lib; Function = fct; }
public void Free(RangeContainer container) { Segments.Remove(container); Last = null; }