Hexadecimal instruction parsing hotfix

This commit is contained in:
Ferit Yiğit BALABAN
2021-10-30 06:16:28 +03:00
parent ef6844bbfa
commit 83a5c609f5
2 changed files with 4 additions and 4 deletions

View File

@@ -22,7 +22,8 @@ namespace processor
/// <returns></returns> /// <returns></returns>
internal static string RemoveLeading(string text) internal static string RemoveLeading(string text)
{ {
if (text.StartsWith("0x") | text.StartsWith("1x")) return text.Remove(0, 2); if (text.StartsWith("0x") || text.StartsWith("1x"))
return text.Remove(0, 2);
MessageBox.Show("Error while parsing code:\nHexadecimal CPU instructions must start with \"0x\" and ram write instructions must start with \"1x\"!", "Vole Language Parser"); MessageBox.Show("Error while parsing code:\nHexadecimal CPU instructions must start with \"0x\" and ram write instructions must start with \"1x\"!", "Vole Language Parser");
return ""; return "";
} }

View File

@@ -143,9 +143,9 @@ namespace processor
if (radHex.Checked is true) if (radHex.Checked is true)
{ {
// This loads CPU instructions to RAM, starting from address 0x00 and going up to 0xFF // This loads CPU instructions to RAM, starting from address 0x00 and going up to 0xFF
LoadHexCode((from x in instructionList where x.StartsWith("0x") select x).ToList()); LoadHexCode((from x in instructionList where x.StartsWith("0x") select x.Remove(0, 2)).ToList());
// This executes RAM write instructions, ultimately overwriting RAM with data // This executes RAM write instructions, ultimately overwriting RAM with data
ExecuteRamWrite((from x in instructionList where x.StartsWith("1x") select x).ToList()); ExecuteRamWrite((from x in instructionList where x.StartsWith("1x") select x.Remove(0, 2)).ToList());
} }
else else
{ {
@@ -159,7 +159,6 @@ namespace processor
/// <param name="codes"></param> /// <param name="codes"></param>
private void LoadHexCode(List<string> codes) private void LoadHexCode(List<string> codes)
{ {
codes = (from x in codes select RemoveLeading(x)).ToList();
int j = 0; int j = 0;
for (int i = 0; i < codes.Count; i++) for (int i = 0; i < codes.Count; i++)
{ {