Exemple #1
0
        /// <summary>
        /// Dump opcode table in various ways.
        /// Returns a "selected" list of opcode numbers, that is, opcodes which were tagged by
        /// the optional input PLA table number given in arg parameter.
        /// </summary>
        public List <int> Table(ClassPlaEntry.Modifier modifier, int testNum, int arg)
        {
            ClassLog.Log(new string('-', 242));
            List <int> tagged = new List <int>();

            for (int y = 0; y < 16; y++)
            {
                string line = string.Format("{0:X} ", y);
                for (int x = 0; x < 16; x++)
                {
                    char          prefix = ' ';
                    byte          opcode = Convert.ToByte(y * 16 + x);
                    List <string> match  = TableMatch(modifier, opcode);
                    foreach (string oneMatch in match.Where(oneMatch => Convert.ToInt32(oneMatch.Substring(1, oneMatch.LastIndexOf(']') - 1)) == arg))
                    {
                        tagged.Add(y * 16 + x);
                        prefix = '*';
                    }
                    string entry = "";

                    //===============================================================================
                    // Table 0 - Show the number of PLA entries that match each opcode
                    //===============================================================================
                    if (testNum == 0)
                    {
                        entry = string.Join(",", match);
                        if (match.Count == 0)
                        {
                            entry = ".";
                        }
                        if (match.Count > 1)
                        {
                            entry = "[" + match.Count + "]";
                        }
                    }

                    //===============================================================================
                    // Table 1 - For each opcode, show all PLA entries that trigger
                    //===============================================================================
                    if (testNum == 1)
                    {
                        foreach (string oneMatch in match)
                        {
                            string n = oneMatch.Substring(1, oneMatch.LastIndexOf(']') - 1);
                            entry += n + ",";
                        }
                        entry = entry.TrimEnd(',');
                    }

                    // -------------------------------------------
                    if (entry.Length > 12)
                    {
                        entry = entry.Substring(0, 12);
                    }
                    line += string.Format(" |{0}{1,-12}", prefix, entry);
                }
                ClassLog.Log(line);
            }
            return(tagged);
        }
Exemple #2
0
        /// <summary>
        /// Find and return all PLA table entries that trigger on a given condition.
        /// </summary>
        public List <string> TableMatch(ClassPlaEntry.Modifier modifier, byte instr)
        {
            var t = new bool[pla.Count];

            // First do a simple search to find the list of *all* PLA entries that match
            foreach (var p in pla)
            {
                if (p.Ignored)
                {
                    continue;
                }
                String match = p.Match(modifier, instr);
                t[p.N] = !string.IsNullOrEmpty(match);
            }

            ////============================================================
            //// Apply any intra-PLA conditions. These are hard-coded into the
            //// timing spreadsheet and we are duplicating them here:

            //// INC/DEC variations with register, (hl) or (ix+d)
            //if (t[66] && !(t[53] || t[105])) ; else t[66] = false;

            //// Generic LD r,r' + (hl), IX variations and on top of that NHALT
            //if (t[61] && !(t[59] || t[103] || t[58] || t[102] || t[95])) ; else t[61] = false;
            //if (t[58] && !t[95]) ; else t[58] = false;
            //if (t[102] && !t[95]) ; else t[102] = false;
            //if (t[59] && !t[95]) ; else t[59] = false;
            //if (t[103] && !t[95]) ; else t[103] = false;

            //// A single LD (hl),n and LD (ix+d),n has precedence over a set of LD r,n
            //if (t[17] && !(t[40] || t[50])) ; else t[17] = false;

            //// ALU A,r' and variations on (hl) and (ix+d)
            //if (t[65] && !(t[52] || t[104])) ; else t[65] = false;

            //// ALU
            //if (t[88] && (t[65] || t[64] || t[52] || t[104])) ; else t[88] = false;
            //if (t[86] && (t[65] || t[64] || t[52] || t[104])) ; else t[86] = false;
            //if (t[85] && (t[65] || t[64] || t[52] || t[104])) ; else t[85] = false;
            //if (t[84] && (t[65] || t[64] || t[52] || t[104])) ; else t[84] = false;
            //if (t[80] && (t[65] || t[64] || t[52] || t[104])) ; else t[80] = false;
            //if (t[79] && (t[65] || t[64] || t[52] || t[104])) ; else t[79] = false;
            //if (t[78] && (t[65] || t[64] || t[52] || t[104])) ; else t[78] = false;
            //if (t[76] && (t[65] || t[64] || t[52] || t[104])) ; else t[76] = false;

            //============================================================

            // Finally, collect and return all PLA entries that are left asserted
            return((from p in pla
                    where t[p.N]
                    select p.Match(modifier, instr)).ToList());
        }
Exemple #3
0
 private void BtEdClick(object sender, EventArgs e)
 {
     if ((modifier & ClassPlaEntry.Modifier.ED) != 0)
     {
         modifier &= ~ClassPlaEntry.Modifier.ED;
     }
     else
     {
         modifier |= ClassPlaEntry.Modifier.ED;
         modifier &= ~(ClassPlaEntry.Modifier.XX | ClassPlaEntry.Modifier.CB);
     }
     UpdateButtons();
 }
Exemple #4
0
 private void BtIx1Click(object sender, EventArgs e)
 {
     if ((modifier & ClassPlaEntry.Modifier.IXY1) != 0)
     {
         modifier &= ~ClassPlaEntry.Modifier.IXY1;
     }
     else
     {
         modifier |= ClassPlaEntry.Modifier.IXY1;
         modifier &= ~ClassPlaEntry.Modifier.IXY0;
     }
     UpdateButtons();
 }
Exemple #5
0
        /// <summary>
        /// List all opcodes that trigger on a given PLA table index
        /// </summary>
        private void MatchOpcodes(ClassPlaEntry.Modifier modifier, string arg)
        {
            int index = ScanNumber(arg, 10);

            if (index < 0)
            {
                return;
            }
            List <string> m = pla.MatchPLA(modifier, index);

            if (m.Count == 0)
            {
                return;
            }
            ClassLog.Log(String.Format("PLA Entry: {0}  Modifier: {1}", index, modifier));
            foreach (var s in m)
            {
                ClassLog.Log(s);
            }
        }
Exemple #6
0
        /// <summary>
        /// Given the PLA ID, return a list of all opcodes that trigger it
        /// </summary>
        public List <string> MatchPLA(ClassPlaEntry.Modifier modifier, int id)
        {
            var m = new List <string>();

            // Find the pla with a given index
            foreach (ClassPlaEntry p in pla)
            {
                if (p.N == id)
                {
                    // For each possible opcode...
                    for (int i = 0; i < 256; i++)
                    {
                        String match = p.Match(modifier, Convert.ToByte(i));
                        if (!string.IsNullOrEmpty(match))
                        {
                            m.Add(string.Format("{0:X02} => {1}", i, match));
                        }
                    }
                    return(m);
                }
            }
            ClassLog.Log("Non-existent PLA index");
            return(m);
        }
Exemple #7
0
 private void BtAluClick(object sender, EventArgs e)
 {
     modifier ^= ClassPlaEntry.Modifier.ALU;
     UpdateButtons();
 }
Exemple #8
0
 private void BtNHaltClick(object sender, EventArgs e)
 {
     modifier ^= ClassPlaEntry.Modifier.NHALT;
     UpdateButtons();
 }