Ejemplo n.º 1
0
        public SPUOpcodeTreeNode getTreeNodeByKey(string key)
        {
            SPUOpcodeTreeNode current = Root;

            char[] nodes = key.ToCharArray();
            int    depth = 0;

            foreach (char node in nodes)
            {
                if (node == '0')
                {
                    if (current.child[0] == null)
                    {
                        current.child[0] = new SPUOpcodeTreeNode(depth);
                    }
                    current = current.child[0];
                }
                else if (node == '1')
                {
                    if (current.child[1] == null)
                    {
                        current.child[1] = new SPUOpcodeTreeNode(depth);
                    }
                    current = current.child[1];
                }
                depth++;
            }
            return(current);
        }
Ejemplo n.º 2
0
        public string getCmdString(byte[] cmd, int pc)
        {
            string key = "";

            foreach (byte b in cmd)
            {
                string keyB = "";
                keyB  = ((b & 128) != 0) ? "1" : "0";
                keyB += ((b & 64) != 0) ? "1" : "0";
                keyB += ((b & 32) != 0) ? "1" : "0";
                keyB += ((b & 16) != 0) ? "1" : "0";
                keyB += ((b & 8) != 0) ? "1" : "0";
                keyB += ((b & 4) != 0) ? "1" : "0";
                keyB += ((b & 2) != 0) ? "1" : "0";
                keyB += ((b & 1) != 0) ? "1" : "0";
                key  += keyB;
            }
            SPUOpcodeTreeNode node = Opcodes.getTreeNodeFirstLeafByKey(key);

            try
            {
                return(node.data.getParameterString(key, pc));
            }
            catch (Exception)
            {
                return("UNKNOWN: " + key);
            }
        }
Ejemplo n.º 3
0
        public string getMnemonic(byte[] cmd)
        {
            string key = "";

            foreach (byte b in cmd)
            {
                string keyB = "";
                keyB  = ((b & 128) != 0) ? "1" : "0";
                keyB += ((b & 64) != 0) ? "1" : "0";
                keyB += ((b & 32) != 0) ? "1" : "0";
                keyB += ((b & 16) != 0) ? "1" : "0";
                keyB += ((b & 8) != 0) ? "1" : "0";
                keyB += ((b & 4) != 0) ? "1" : "0";
                keyB += ((b & 2) != 0) ? "1" : "0";
                keyB += ((b & 1) != 0) ? "1" : "0";
                key  += keyB;
            }
            SPUOpcodeTreeNode node = Opcodes.getTreeNodeFirstLeafByKey(key);

            try
            {
                return(node.data.mnemonic);
            }
            catch (Exception)
            {
                return("UNKNOWN");
            }
        }
Ejemplo n.º 4
0
        public SPUCommand(byte[] cmd, int offset)
        {
            string key = ConversionUtil.byteToBinString(cmd, offset);

            key         += ConversionUtil.byteToBinString(cmd, offset + 1);
            key         += ConversionUtil.byteToBinString(cmd, offset + 2);
            key         += ConversionUtil.byteToBinString(cmd, offset + 3);
            node         = SPUOpcodeTable.Instance.Opcodes.getTreeNodeFirstLeafByKey(key);
            rt           = ra = rb = rc = idx = 0;
            functionName = "";

            try
            {
                fullCommand = node.data.getParameterString(key, offset);
                mnemonics   = node.data.mnemonic;
                type        = node.data.type;
                parseParameter(key);
            }
            catch (Exception)
            {
                mnemonics   = ".byte";
                fullCommand = "";
                type        = SPUOpcodeType.FAIL;
            }
        }
Ejemplo n.º 5
0
 public SPUCommand(string key)
 {
     node = SPUOpcodeTable.Instance.Opcodes.getTreeNodeFirstLeafByKey(key);
     rt = ra = rb = rc = idx = 0;
     try
     {
         mnemonics = node.data.mnemonic;
         type = node.data.type;
         parseParameter(key);
     }
     catch (Exception)
     {
         mnemonics = ".byte";
         type = SPUOpcodeType.Special;
     }
 }
Ejemplo n.º 6
0
 public SPUCommand(string key)
 {
     node = SPUOpcodeTable.Instance.Opcodes.getTreeNodeFirstLeafByKey(key);
     rt   = ra = rb = rc = idx = 0;
     try
     {
         mnemonics = node.data.mnemonic;
         type      = node.data.type;
         parseParameter(key);
     }
     catch (Exception)
     {
         mnemonics = ".byte";
         type      = SPUOpcodeType.Special;
     }
 }
Ejemplo n.º 7
0
        public SPUCommand(byte[] cmd, int offset)
        {
            string key = ConversionUtil.byteToBinString(cmd, offset);
            key += ConversionUtil.byteToBinString(cmd, offset + 1);
            key += ConversionUtil.byteToBinString(cmd, offset + 2);
            key += ConversionUtil.byteToBinString(cmd, offset + 3);
            node = SPUOpcodeTable.Instance.Opcodes.getTreeNodeFirstLeafByKey(key);
            rt = ra = rb = rc = idx = 0;
            functionName = "";

            try
            {
                fullCommand = node.data.getParameterString(key, offset);
                mnemonics = node.data.mnemonic;
                type = node.data.type;
                parseParameter(key);
            }
            catch (Exception)
            {
                mnemonics = ".byte";
                fullCommand = "";
                type = SPUOpcodeType.FAIL;
            }
        }
Ejemplo n.º 8
0
 public SPUOpcodeTree()
 {
     Root = new SPUOpcodeTreeNode(-1);
 }
Ejemplo n.º 9
0
        public void setTreeNodeData(string key, string[] data)
        {
            SPUOpcodeTreeNode     node     = getTreeNodeByKey(key);
            SPUOpcodeTreeNodeData treeData = new SPUOpcodeTreeNodeData();

            treeData.opcode   = data[0];
            treeData.mnemonic = data[2];
            treeData.shift    = 0;
            treeData.signed   = false;
            treeData.size     = 128;
            treeData.stop     = false;
            treeData.trap     = false;
            treeData.type     = SPUOpcodeTreeNodeData.typeByString(data[1]);

            for (int i = 3; i < data.Length; i++)
            {
                switch (data[i])
                {
                case "signed":
                    treeData.signed = true;
                    break;

                case "shift2":
                    treeData.shift = 2;
                    break;

                case "shift4":
                    treeData.shift = 4;
                    break;

                case "stop":
                    treeData.stop = true;
                    break;

                case "trap":
                    treeData.trap = true;
                    break;

                case "Bits":
                    treeData.size = 1;
                    break;

                case "byte":
                    treeData.size = 8;
                    break;

                case "half":
                    treeData.size = 16;
                    break;

                case "float":
                    treeData.size = 32;
                    break;

                case "double":
                    treeData.size = 64;
                    break;
                }
            }

            node.data = treeData;
            node.leaf = true;
        }
Ejemplo n.º 10
0
 public SPUOpcodeTree()
 {
     Root = new SPUOpcodeTreeNode(-1);
 }