diff --git a/src/MainForm.cs b/src/MainForm.cs
index d055119..032975b 100644
--- a/src/MainForm.cs
+++ b/src/MainForm.cs
@@ -73,7 +73,7 @@ namespace processor
///
///
///
- private void LoadProgram(int address, string value) => ramList.Items[address] = $"{CnvRespectfully(address, 2, 8)}: {value}";
+ private void LoadCode(int address, string value) => ramList.Items[address] = $"{CnvRespectfully(address, 2, 8)}: {value}";
///
/// Write data to addressed memory cell
@@ -140,21 +140,23 @@ namespace processor
// Removes comments from lines, drops empty lines and sets instructionList to this new collection
List instructionList = (from x in inputLines where !string.IsNullOrEmpty(RemoveComment(x)) select RemoveComment(x)).ToList();
- List funcCode, ramCode;
- funcCode = (from x in instructionList where x.StartsWith("0x") select x).ToList();
- ramCode = (from x in instructionList where x.StartsWith("1x") select x).ToList();
-
if (radHex.Checked is true)
{
- LoadHexCode(funcCode);
- LoadHexCode(ramCode);
+ // 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());
+ // This executes RAM write instructions, ultimately overwriting RAM with data
+ ExecuteRamWrite((from x in instructionList where x.StartsWith("1x") select x).ToList());
}
else
{
-
+
}
}
+ ///
+ /// Loads hexadecimal CPU instructions to RAM
+ ///
+ ///
private void LoadHexCode(List codes)
{
codes = (from x in codes select RemoveLeading(x)).ToList();
@@ -162,12 +164,34 @@ namespace processor
for (int i = 0; i < codes.Count; i++)
{
string[] enm = codes[i].Split2().ToArray();
- LoadProgram(j, enm[0]);
- LoadProgram(j+1, enm[1]);
+ LoadCode(j, enm[0]);
+ LoadCode(j+1, enm[1]);
j += 2;
}
}
+ ///
+ /// Writes data to RAM without using CPU instructions
+ ///
+ ///
+ private void ExecuteRamWrite(List codes)
+ {
+ foreach (string code in codes) // code is a 2 byte hexadecimal instruction: 1A34
+ {
+ string[] ia = code.Split2().ToArray();
+ WriteRam(CnvRespectfully(ia[0]), CnvRespectfully(ia[1]));
+ }
+ }
+
+ ///
+ /// Loads binary CPU instructions to RAM
+ ///
+ ///
+ private void LoadBinCode(List codes)
+ {
+ throw new NotImplementedException();
+ }
+
private void btnClear_Click(object sender, EventArgs e) => InitializeRamList();
private void btnStart_Click(object sender, EventArgs e)