Beispiel #1
0
        public void Free(int start)
        {
            int idx = Segments.FindIndex(i => i.Start == start);

            Segments.RemoveAt(idx);
            Last = null;
        }
Beispiel #2
0
        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);
            }
        }
Beispiel #3
0
 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");
     }
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 public StackContainer(RangeContainer memory, int counter)
 {
     ProgramCounter = counter;
     Memory         = memory;
 }
Beispiel #6
0
 public LibStackContainer(string lib, string fct, RangeContainer memory) : base(memory, 0)
 {
     Library  = lib;
     Function = fct;
 }
Beispiel #7
0
 public void Free(RangeContainer container)
 {
     Segments.Remove(container);
     Last = null;
 }