You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
135 lines
3.3 KiB
135 lines
3.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 指令数据
|
|
/// </summary>
|
|
public class CommandData
|
|
{
|
|
|
|
//指令内容
|
|
public CommandType command;
|
|
|
|
public int num01;
|
|
|
|
public int num02;
|
|
|
|
public int result;
|
|
|
|
|
|
//具体执行名称
|
|
public string ActName;
|
|
|
|
/// <summary>
|
|
/// 指令名称
|
|
/// </summary>
|
|
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;
|
|
} }
|
|
|
|
/// <summary>
|
|
/// 返回算式指令
|
|
/// </summary>
|
|
public List<string> ActCommandList { get {
|
|
List<string> _temp = new List<string>();
|
|
string[] _tempArr;
|
|
switch (command)
|
|
{
|
|
case CommandType.Add:
|
|
_tempArr = new string[5] { "mov3","mov3","add","out","halt"};
|
|
_temp = new List<string>(_tempArr);
|
|
break;
|
|
case CommandType.Div:
|
|
_tempArr = new string[5] { "mov3", "mov3", "div", "out", "halt" };
|
|
_temp = new List<string>(_tempArr);
|
|
break;
|
|
case CommandType.Mul:
|
|
_tempArr = new string[5] { "mov3", "mov3", "mul", "out", "halt" };
|
|
_temp = new List<string>(_tempArr);
|
|
break;
|
|
case CommandType.Sub:
|
|
_tempArr = new string[5] { "mov3", "mov3", "sub", "out", "halt" };
|
|
_temp = new List<string>(_tempArr);
|
|
break;
|
|
}
|
|
return _temp;
|
|
} }
|
|
|
|
|
|
/// <summary>
|
|
/// 随机干扰指令
|
|
/// </summary>
|
|
public List<string> JamCommandList { get {
|
|
string[] _tempArr = new string[9] { "mov1", "mov2","add","div","mul" , "sub" ,"jmp","jz","in"};
|
|
List<string> _temp = new List<string>(_tempArr);
|
|
return _temp;
|
|
}}
|
|
|
|
|
|
|
|
}
|
|
|
|
public enum CommandType
|
|
{
|
|
Null,
|
|
//加法
|
|
Add,
|
|
//减法
|
|
Sub,
|
|
//乘法,
|
|
Mul,
|
|
//除法
|
|
Div
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 诺依曼指令数据
|
|
/// </summary>
|
|
public class VonNeumann
|
|
{
|
|
public static CommandData data;
|
|
/// <summary>
|
|
/// 指令下标
|
|
/// </summary>
|
|
public static int CommandIndex = 0;
|
|
|
|
/// <summary>
|
|
/// 指令正在运行
|
|
/// </summary>
|
|
public static bool isRunning = false;
|
|
|
|
/// <summary>
|
|
/// 是否完成
|
|
/// </summary>
|
|
public static bool isFinish = false;
|
|
|
|
}
|
|
|