public int JSR(string func_string) { string res = analyze_string_jump(func_string); if (!String.IsNullOrWhiteSpace(res)) { value_of_processor_registers[13]--; RAM[value_of_processor_registers[13]] = value_of_processor_registers[12]; //salvo il pc //Console.WriteLine("into " + find_jump(res, rc)); value_of_processor_registers[12] = find_jump(res); //salto nel label //stack.Push(add_stack(RAM[value_of_processor_registers[13]],func_string)); funzioni f = new funzioni(); f.add = value_of_processor_registers[13]; f.str = func_string; func.Add(f); return(1); } return(0); }
/// <summary> /// MODIFY STACK /// </summary> /// <param name="panel"></param> /// <param name="rowElements"></param> /*public void add_row_stack(TableLayoutPanel panel, string[] rowElements) * { * if (panel.ColumnCount != rowElements.Length) * throw new Exception("Elements number doesn't match!"); * //get a reference to the previous existent row * RowStyle temp = panel.RowStyles[panel.RowCount - 1]; * //increase panel rows count by one * panel.RowCount++; * //add a new RowStyle as a copy of the previous one * panel.RowStyles.Add(new RowStyle(temp.SizeType, temp.Height)); * //add the control * for (int i = 0; i < rowElements.Length; i++) * { * panel.Controls.Add(new Label() { Text = rowElements[i] }, i, panel.RowCount - 1); * } * }*/ public Panel add_stack(int data, int row_add) { /****cella****/ Panel sta = new Panel(); sta.BackColor = Color.LightGray; sta.BorderStyle = BorderStyle.FixedSingle; sta.Dock = DockStyle.Fill; sta.Height = 30; /****valore****/ Label value = new Label(); value.Text = "" + data; value.Font = new Font("Curier", 10.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));; sta.Controls.Add(value); value.Dock = DockStyle.Right; /****ADDRESS****/ Label addr = new Label(); addr.Text = "" + row_add; addr.Font = new Font("Curier", 10.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));; sta.Controls.Add(addr); addr.Dock = DockStyle.Left; if (func.FindIndex(a => a.add == row_add) > -1) { funzioni f = func.Find(a => a.add == row_add); Label label = new Label();//NOME FUNZIONE label.Text = f.str; label.Font = new Font("Curier", 10.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); sta.Controls.Add(label); label.Dock = DockStyle.Left; } return(sta); }
public int LINK(string func_string) { if (compile_LINK(func_string) != 0) { int[] ind = analyze_string_link(func_string); //RAM[value_of_processor_registers[13]] = ind[0]; ind[1] /= grandezza_parole; value_of_processor_registers[13]--; RAM[value_of_processor_registers[13]] = value_of_processor_registers[14]; //stack.Push(add_stack(RAM[value_of_processor_registers[13]],"FP precedente")); funzioni f = new funzioni(); f.add = value_of_processor_registers[13]; f.str = "FP precedente"; func.Add(f); value_of_processor_registers[14] = value_of_processor_registers[13];//di solito setto fp allo stack corrente while (ind[1] > 0) { value_of_processor_registers[13]--; RAM[value_of_processor_registers[13]] = 0; funzioni f1 = new funzioni(); f1.add = value_of_processor_registers[13]; f1.str = "Local var"; func.Add(f1); //stack.Push(add_stack(RAM[value_of_processor_registers[13]],"Local var")); ind[1]--; } value_of_processor_registers[13] = value_of_processor_registers[13]; //setto sp a max value_of_processor_registers[12]++; //incremento pc return(1); } return(0); }