Added Register Naming support in ISADefinition.

This commit is contained in:
2025-07-24 23:09:01 +10:00
parent c5d27b65e9
commit be99821ced
4 changed files with 87 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ namespace SVM.Assembler.Core
[Serializable]
public class ISADefinition
{
public Dictionary<string, byte> RegisterNames = new Dictionary<string, byte>();
public Dictionary<string, Dictionary<string, string>> Enums = new Dictionary<string, Dictionary<string, string>>();
public Dictionary<PrimaryInstruction, InstructionDefinition> InstructionDefinitions = new Dictionary<PrimaryInstruction, InstructionDefinition>();
[NonSerialized]
@@ -240,6 +241,36 @@ namespace SVM.Assembler.Core
}
}
break;
case "Registers":
{
foreach (XmlNode enumNode in item.ChildNodes)
{
if (enumNode.Name == "Item")
{
var keyAttr = enumNode.Attributes.GetNamedItem("Key");
var valueAttr = enumNode.Attributes.GetNamedItem("Value");
if (keyAttr == null || valueAttr == null)
{
definition = null;
return false;
}
if (!byte.TryParse(valueAttr.InnerText, out var RegID))
{
definition = null;
return false;
}
isaDefinition.RegisterNames.Add(keyAttr.InnerText, RegID);
}
else
{
definition = null;
return false;
}
}
}
break;
case "Definitions":
if (ParseDefinitions(item, ref isaDefinition) == false)
{