From 587ab5d0c4e2cad60e17e2032683023a69f85938 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferit=20Yi=C4=9Fit=20BALABAN?= Date: Sat, 30 Oct 2021 04:58:00 +0300 Subject: [PATCH] Moved execution code to Execute() method btnStep_Click and btn_Start uses same functionality, moved execution code to an independent function to reduce line duplication --- src/MainForm.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/MainForm.cs b/src/MainForm.cs index 5b8f47c..e3cf596 100644 --- a/src/MainForm.cs +++ b/src/MainForm.cs @@ -166,9 +166,14 @@ namespace processor { } - private string Status = "Stopped"; + private CpuStatus _status = CpuStatus.Stopped; private void btnStep_Click(object sender, EventArgs e) + { + + } + + private void Execute() { if (ReadInstRegister()[0] is 12) // Do not run method if instruction is 0xC - halt opcode { @@ -178,10 +183,10 @@ namespace processor } int counter = ReadCounter(); - if (Status is "Running") // This check is useful to determine if the execution has just started or was already running + if (_status is CpuStatus.Running) // This check is useful to determine if the execution has just started or was already running SetCounter(counter + 2); else SetCounter(counter); - Status = "Running"; + _status = CpuStatus.Running; int[] fields = ReadInstRegister(); ResolveOpcode(fields[0], fields[1], fields[2], fields[3]);