From 83a5c609f5ebb473ff8cda7cbc6433714dca490f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Sat, 30 Oct 2021 06:16:28 +0300 Subject: [PATCH] Hexadecimal instruction parsing hotfix --- src/Extensions.cs | 3 ++- src/MainForm.cs | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Extensions.cs b/src/Extensions.cs index 724030e..e936e7c 100644 --- a/src/Extensions.cs +++ b/src/Extensions.cs @@ -22,7 +22,8 @@ namespace processor /// 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"); return ""; } diff --git a/src/MainForm.cs b/src/MainForm.cs index 032975b..1d8ca34 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -143,9 +143,9 @@ namespace processor if (radHex.Checked is true) { // 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 - 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 { @@ -159,7 +159,6 @@ namespace processor /// private void LoadHexCode(List codes) { - codes = (from x in codes select RemoveLeading(x)).ToList(); int j = 0; for (int i = 0; i < codes.Count; i++) {