OpenCores
URL https://opencores.org/ocsvn/a-z80/a-z80/trunk

Subversion Repositories a-z80

[/] [a-z80/] [trunk/] [tools/] [z80_pla_checker/] [source/] [ClassOpcodeTable.cs] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 gdevic
´╗┐using System;
2
using System.Collections.Generic;
3
using System.IO;
4
 
5
namespace z80_pla_checker
6
{
7
    /// 
8
    /// This class loads from a file the opcode table and provides
9
    /// access functions to a table.
10
    /// 
11
    class ClassOpcodeTable
12
    {
13
        /// 
14
        /// Contains the opcode description indexed by the opcode byte
15
        /// 
16
        private readonly Dictionary op = new Dictionary();
17
 
18
        /// 
19
        /// Loads an opcode table from a text file
20
        /// 
21
        public void Load(string filename, int xxindex)
22
        {
23
            ClassLog.Log("Loading opcode table: " + filename);
24
 
25
            try
26
            {
27
                string[] lines = File.ReadAllLines(filename);
28
                op.Clear();
29
                foreach (string line in lines)
30
                {
31
                    string hex = line.Substring(xxindex, 2);
32
                    string instr = line.Substring(12);
33
                    int xx = Convert.ToInt32(hex, 16);
34
                    op[xx] = instr;
35
                }
36
 
37
            }
38
            catch (Exception ex)
39
            {
40
                ClassLog.Log(ex.Message);
41
            }
42
        }
43
 
44
        /// 
45
        /// Dumps the opcode table in a table format
46
        /// The opcode numbers in the list t will be tagged (marked with *)
47
        /// 
48
        public void Dump(List t)
49
        {
50
            ClassLog.Log(new string('-', 242));
51
            for (int y = 0; y < 16; y++)
52
            {
53
                string line = string.Format("{0:X} ", y);
54
                for (int x = 0; x < 16; x++)
55
                {
56
                    string opcode = "";
57
                    if (op.ContainsKey(y * 16 + x))
58
                        opcode = op[y * 16 + x];
59
                    if (opcode.Length > 12)
60
                        opcode = opcode.Substring(0, 12);
61
                    char tag = ' ';
62
                    if (t.Contains(y * 16 + x)) tag = '*';
63
                    line += string.Format(" |{0}{1,-12}", tag, opcode);
64
                }
65
                ClassLog.Log(line);
66
            }
67
        }
68
    }
69
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.