diff --git a/MainForm.cs b/MainForm.cs
index 52dcaa3..5600b8f 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -52,9 +52,14 @@ namespace processor
}
#region RAM
- private void ReadRam(int address, string value)
+ ///
+ /// Returns data as integers hold in addressed memory cell
+ ///
+ ///
+ ///
+ private int ReadRam(int address)
{
-
+
}
private void WriteRam(int address, string hexValue)
@@ -63,11 +68,19 @@ namespace processor
}
#endregion
- private string CnvRespectfully(string value)
- {
- if (radHex.Checked is true) return value.Hex2Int().ToHex2();
- else throw new NotImplementedException();
- }
+ ///
+ /// Converts integer to hexadecimal or binary representation in text according to selected view mode
+ ///
+ ///
+ ///
+ private string CnvRespectfully(int value) => radHex.Checked ? Convert.ToString(value, 16).PadLeft(2, '0') : Convert.ToString(value, 2).PadLeft(8, '0');
+
+ ///
+ /// Converts hexadecimal or binary representation to integer according to selected view mode
+ ///
+ ///
+ ///
+ private int CnvRespectfully(string value) => radHex.Checked ? Convert.ToInt32(value, 16) : Convert.ToInt32(value, 2);
///
/// Parses and loads instructions to ramList
@@ -76,7 +89,7 @@ namespace processor
///
private void btnLoad_Click(object sender, EventArgs e)
{
- List instructionList = new List();
+ List instructionList = new();
if (!string.IsNullOrWhiteSpace(txtCode.Text))
{
@@ -88,16 +101,13 @@ namespace processor
if (radHex.Checked is true)
{
instructionList = (from x in instructionList select RemoveLeading(x)).ToList();
- List inst = new();
+ int j = 0;
for (int i = 0; i < instructionList.Count; i++)
{
- IEnumerable enm = instructionList[i].Split2();
- inst.Add(enm.ElementAt(0));
- inst.Add(enm.ElementAt(1)); // i am quite sure that there is a much better approach but it's 1 am and i'm tired af
- }
- for (int i = 0; i < inst.Count; i++)
- {
- WriteRam(i, inst[i]);
+ string[] enm = instructionList[i].Split2().ToArray();
+ WriteRam(j, enm[0]);
+ WriteRam(j+1, enm[1]);
+ j += 2;
}
}
else
@@ -107,5 +117,10 @@ namespace processor
}
private void btnClear_Click(object sender, EventArgs e) => InitializeRamList();
+
+ private void btnStart_Click(object sender, EventArgs e)
+ {
+
+ }
}
}