Ejemplo n.º 1
0
        //------------------------------------------------------------------------------------------------------------
        public string Output()
        {
            string response = "";

            if (_description.Trim() != "")
            {
                response += $"-1 {_description}\n";
            }
            int count = _instructions.Count();

            for (int i = 0; i < count; ++i)
            {
                var    instruction = _instructions[i];
                string line        = $"{i.ToString("D2")} ";
                if (EPC.ValidWord(instruction))
                {
                    line += $"{instruction.ToString(Memory.FORMAT)}";
                }
                else // Assume this is a variable or constant field
                {
                    line += $"{instruction.ToString()}";
                }
                response += line;
                if (i < count - 1)
                {
                    response += '\n';
                }
            }
            return(response);
        }
Ejemplo n.º 2
0
        //------------------------------------------------------------------------------------------------------------
        public string Dump()
        {
            if (_block == null)
            {
                return("Memory Stack not initialized");
            }
            string response = "Memory:\n";
            int    cols     = 10;
            int    inCol    = 0;

            // column headings
            response += "        ";
            for (int i = 0; i < cols; ++i) // numbered column headings
            {
                response += String.Format("{0,8}", i.ToString("D2"));
            }
            response += "\n";
            for (int i = 0; i < _size; ++i)
            {
                if (inCol == 0) // first column of new row
                {
                    response += $"{i.ToString("D2"),8}";
                }
                decimal value = _block[i];
                if (EPC.ValidWord(value))
                {
                    response += String.Format("{0,8}", value.ToString(FORMAT));
                }
                else
                {
                    response += String.Format("{0,8}", value.ToString());
                }
                ++inCol;
                if (inCol == cols) // last column of row
                {
                    response += "\n";
                    inCol     = 0;
                }
            }
            return(response);
        }