using System.Collections; using System.Collections.Generic; using UnityEngine; /// /// 指令数据 /// public class CommandData { //指令内容 public CommandType command; public int num01; public int num02; public int result; //具体执行名称 public string ActName; /// /// 指令名称 /// public string Name { get { string _name = "空指令"; switch (command) { case CommandType.Add: _name = "加法指令"; break; case CommandType.Div: _name = "除法指令"; break; case CommandType.Mul: _name = "乘法指令"; break; case CommandType.Sub: _name = "减法指令"; break; } return _name; } } /// /// 返回算式指令 /// public List ActCommandList { get { List _temp = new List(); string[] _tempArr; switch (command) { case CommandType.Add: _tempArr = new string[5] { "mov3","mov3","add","out","halt"}; _temp = new List(_tempArr); break; case CommandType.Div: _tempArr = new string[5] { "mov3", "mov3", "div", "out", "halt" }; _temp = new List(_tempArr); break; case CommandType.Mul: _tempArr = new string[5] { "mov3", "mov3", "mul", "out", "halt" }; _temp = new List(_tempArr); break; case CommandType.Sub: _tempArr = new string[5] { "mov3", "mov3", "sub", "out", "halt" }; _temp = new List(_tempArr); break; } return _temp; } } /// /// 随机干扰指令 /// public List JamCommandList { get { string[] _tempArr = new string[9] { "mov1", "mov2","add","div","mul" , "sub" ,"jmp","jz","in"}; List _temp = new List(_tempArr); return _temp; }} } public enum CommandType { Null, //加法 Add, //减法 Sub, //乘法, Mul, //除法 Div } /// /// 诺依曼指令数据 /// public class VonNeumann { public static CommandData data; /// /// 指令下标 /// public static int CommandIndex = 0; /// /// 指令正在运行 /// public static bool isRunning = false; /// /// 是否完成 /// public static bool isFinish = false; }