public string parse_c_instruction(string instruction)
        {
            string c_instruction_bin;
            string dest = "000";
            string comp = "00000000";
            string jump = "000";
            Symbol Match;
            int    index;

            index = instruction.IndexOf('=');
            if (index > 0)
            {
                jump  = "000";
                dest  = instruction.Substring(0, index);
                Match = DestTable.FirstOrDefault(i => i.Name == dest);
                if (Match != null)
                {
                    dest = Match.Value;
                }
                comp  = instruction.Substring(index + 1, instruction.Length - index - 1);
                Match = CompTable.FirstOrDefault(i => i.Name == comp);
                if (Match != null)
                {
                    comp = Match.Value;
                }
            }
            index = instruction.IndexOf(';');
            if (index > 0)
            {
                dest  = "000";
                comp  = instruction.Substring(0, index);
                Match = CompTable.FirstOrDefault(i => i.Name == comp);
                if (Match != null)
                {
                    comp = Match.Value;
                }
                jump  = instruction.Substring(index + 1, instruction.Length - index - 1);
                Match = JumpTable.FirstOrDefault(i => i.Name == jump);
                if (Match != null)
                {
                    jump = Match.Value;
                }
            }
            c_instruction_bin = "11" + comp + dest + jump;
            return(c_instruction_bin);
        }
 public void load_all_Tables()
 {
     // SymbolTable
     SymbolTable.Add(new Symbol("R0", Convert.ToString(0)));
     SymbolTable.Add(new Symbol("R1", Convert.ToString(1)));
     SymbolTable.Add(new Symbol("R2", Convert.ToString(2)));
     SymbolTable.Add(new Symbol("R3", Convert.ToString(3)));
     SymbolTable.Add(new Symbol("R4", Convert.ToString(4)));
     SymbolTable.Add(new Symbol("R5", Convert.ToString(5)));
     SymbolTable.Add(new Symbol("R6", Convert.ToString(6)));
     SymbolTable.Add(new Symbol("R7", Convert.ToString(7)));
     SymbolTable.Add(new Symbol("R8", Convert.ToString(8)));
     SymbolTable.Add(new Symbol("R9", Convert.ToString(9)));
     SymbolTable.Add(new Symbol("R10", Convert.ToString(10)));
     SymbolTable.Add(new Symbol("R11", Convert.ToString(11)));
     SymbolTable.Add(new Symbol("R12", Convert.ToString(12)));
     SymbolTable.Add(new Symbol("R13", Convert.ToString(13)));
     SymbolTable.Add(new Symbol("R14", Convert.ToString(14)));
     SymbolTable.Add(new Symbol("R15", Convert.ToString(15)));
     SymbolTable.Add(new Symbol("SCREEN", Convert.ToString(16384)));
     SymbolTable.Add(new Symbol("KBD", Convert.ToString(24576)));
     // Destination Parts
     DestTable.Add(new Symbol(null, "000"));
     DestTable.Add(new Symbol("M", "001"));
     DestTable.Add(new Symbol("D", "010"));
     DestTable.Add(new Symbol("MD", "011"));
     DestTable.Add(new Symbol("A", "100"));
     DestTable.Add(new Symbol("AM", "101"));
     DestTable.Add(new Symbol("AD", "110"));
     DestTable.Add(new Symbol("AMD", "111"));
     // Jump Parts
     JumpTable.Add(new Symbol(null, "000"));
     JumpTable.Add(new Symbol("JGT", "001"));
     JumpTable.Add(new Symbol("JEQ", "010"));
     JumpTable.Add(new Symbol("JGE", "011"));
     JumpTable.Add(new Symbol("JLT", "100"));
     JumpTable.Add(new Symbol("JNE", "101"));
     JumpTable.Add(new Symbol("JLE", "110"));
     JumpTable.Add(new Symbol("JMP", "111"));
     // Computation Parts
     CompTable.Add(new Symbol("0", "10101010"));
     CompTable.Add(new Symbol("1", "10111111"));
     CompTable.Add(new Symbol("-1", "10111010"));
     CompTable.Add(new Symbol("D", "10001100"));
     CompTable.Add(new Symbol("A", "10110000"));
     CompTable.Add(new Symbol("!D", "10001101"));
     CompTable.Add(new Symbol("!A", "10110001"));
     CompTable.Add(new Symbol("-D", "10001111"));
     CompTable.Add(new Symbol("-A", "10110011"));
     CompTable.Add(new Symbol("D+1", "10011111"));
     CompTable.Add(new Symbol("A+1", "10110111"));
     CompTable.Add(new Symbol("D-1", "10001110"));
     CompTable.Add(new Symbol("A-1", "10110010"));
     CompTable.Add(new Symbol("D+A", "10000010"));
     CompTable.Add(new Symbol("D-A", "10010011"));
     CompTable.Add(new Symbol("A-D", "10000111"));
     CompTable.Add(new Symbol("D&A", "10000000"));
     CompTable.Add(new Symbol("D|A", "10010101"));
     CompTable.Add(new Symbol("M", "11110000"));
     CompTable.Add(new Symbol("!M", "11110001"));
     CompTable.Add(new Symbol("-M", "11110011"));
     CompTable.Add(new Symbol("M+1", "11110111"));
     CompTable.Add(new Symbol("M-1", "11110010"));
     CompTable.Add(new Symbol("D+M", "11000010"));
     CompTable.Add(new Symbol("D-M", "11010011"));
     CompTable.Add(new Symbol("M-D", "11000111"));
     CompTable.Add(new Symbol("D&M", "11000000"));
     CompTable.Add(new Symbol("D|M", "11010101"));
     // New computations from our ALU
     CompTable.Add(new Symbol("M*D", "00000010"));
     CompTable.Add(new Symbol("M/D", "00000011"));
     CompTable.Add(new Symbol("M+D^2", "00010000"));
     CompTable.Add(new Symbol("M-D^2", "00010001"));
     CompTable.Add(new Symbol("M*D^2", "00010010"));
     CompTable.Add(new Symbol("M/D^2", "00010011"));
     CompTable.Add(new Symbol("-M+D", "00100000"));
     CompTable.Add(new Symbol("-M-D", "00100001"));
     CompTable.Add(new Symbol("-M*D", "00100010"));
     CompTable.Add(new Symbol("-M/D", "00100011"));
     CompTable.Add(new Symbol("-M+D^2", "00110000"));
     CompTable.Add(new Symbol("-M-D^2", "00110001"));
     CompTable.Add(new Symbol("-M*D^2", "00110010"));
     CompTable.Add(new Symbol("-M/D^2", "00110011"));
     CompTable.Add(new Symbol("M^2+D", "01000000"));
     CompTable.Add(new Symbol("M^2-D", "01000001"));
     CompTable.Add(new Symbol("M^2*D", "01000010"));
     CompTable.Add(new Symbol("M^2/D", "01000011"));
     CompTable.Add(new Symbol("M^2+D^2", "01010000"));
     CompTable.Add(new Symbol("M^2-D^2", "01010001"));
     CompTable.Add(new Symbol("M^2*D^2", "01010010"));
     CompTable.Add(new Symbol("M^2/D^2", "01010011"));
     CompTable.Add(new Symbol("-M^2+D", "01100000"));
     CompTable.Add(new Symbol("-M^2-D", "01100001"));
     CompTable.Add(new Symbol("-M^2*D", "01100010"));
     CompTable.Add(new Symbol("-M^2/D", "01100011"));
     CompTable.Add(new Symbol("-M^2+D^2", "01110000"));
     CompTable.Add(new Symbol("-M^2-D^2", "01110001"));
     CompTable.Add(new Symbol("-M^2*D^2", "01110010"));
     CompTable.Add(new Symbol("-M^2/D^2", "01110011"));
     CompTable.Add(new Symbol("M^2", "00000100"));
     CompTable.Add(new Symbol("D^2", "00000101"));
 }