From 5eb25154cba8ef9cac24a31571daf09f040adc81 Mon Sep 17 00:00:00 2001 From: Bob Baker <31376573+rbaker26@users.noreply.github.com> Date: Wed, 6 May 2020 01:52:15 -0700 Subject: [PATCH] huge code cleanup, used roslyn analyzers --- .editorconfig | 4 +++ SAP1EMU.Assembler/Assemble.cs | 2 +- SAP1EMU.Assembler/ParseException.cs | 3 ++ SAP1EMU.Engine-CLI/Program.cs | 29 +++++++++++-------- SAP1EMU.Engine/EngineProc.cs | 10 +++---- SAP1EMU.Engine/EngineRuntimeException.cs | 4 +++ SAP1EMU.Lib.Test/AssemblerTest.cs | 6 ++-- SAP1EMU.Lib/Components/ALU.cs | 18 +++++------- SAP1EMU.Lib/Components/Clock.cs | 6 ++-- SAP1EMU.Lib/Components/ClockException.cs | 8 ++++++ SAP1EMU.Lib/Components/RAM.cs | 9 +----- SAP1EMU.Lib/Components/SEQ.cs | 1 + SAP1EMU.Lib/Components/TicTok.cs | 36 +++++++++++++++++++----- SAP1EMU.Lib/Frame.cs | 2 +- SAP1EMU.Lib/RAMProgram.cs | 2 +- SAP1EMU.Lib/Registers/AReg.cs | 12 +------- SAP1EMU.Lib/Registers/BReg.cs | 8 +----- SAP1EMU.Lib/Registers/IReg.cs | 15 +--------- SAP1EMU.Lib/Registers/MReg.cs | 13 +-------- SAP1EMU.Lib/Registers/MarUpdate.cs | 24 ++++++++++++++++ SAP1EMU.Lib/Registers/OReg.cs | 7 +---- SAP1EMU.Lib/Registers/PC.cs | 29 +++++-------------- 22 files changed, 124 insertions(+), 124 deletions(-) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..bc332e48 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +[*.cs] + +# CA1031: Do not catch general exception types +dotnet_diagnostic.CA1031.severity = none diff --git a/SAP1EMU.Assembler/Assemble.cs b/SAP1EMU.Assembler/Assemble.cs index ee64d508..0bf79456 100644 --- a/SAP1EMU.Assembler/Assemble.cs +++ b/SAP1EMU.Assembler/Assemble.cs @@ -8,7 +8,7 @@ namespace SAP1EMU.Assembler { - public class Assemble + public static class Assemble { public static List ParseFileContents(List unchecked_assembly) diff --git a/SAP1EMU.Assembler/ParseException.cs b/SAP1EMU.Assembler/ParseException.cs index 752414b3..d2d9376a 100644 --- a/SAP1EMU.Assembler/ParseException.cs +++ b/SAP1EMU.Assembler/ParseException.cs @@ -14,5 +14,8 @@ public ParseException(string message, Exception innerException) : base(message, { } + private ParseException() + { + } } } diff --git a/SAP1EMU.Engine-CLI/Program.cs b/SAP1EMU.Engine-CLI/Program.cs index 84a52456..ea49966d 100644 --- a/SAP1EMU.Engine-CLI/Program.cs +++ b/SAP1EMU.Engine-CLI/Program.cs @@ -36,7 +36,9 @@ public class Options // Frame Support ****************************** // -f and -F are mutually exclusive. And error will appeear if the user tries to use both. [Option('f', "fframe", SetName = "fframe", Required = false, HelpText = "Include final frame in the output file.")] +#pragma warning disable IDE1006 // Naming Styles public bool fframe { get; set; } +#pragma warning restore IDE1006 // Naming Styles [Option('F', "Fframe", SetName = "Fframe", Required = false, HelpText = "Include all frames in the output file.")] public bool Fframe { get; set; } // ******************************************** @@ -62,8 +64,7 @@ static void Main(string[] args) List source_file_contents = new List(); ; FileType fileType = FileType.B; - - if (o.SourceFile != null || o.SourceFile != "") + if(!string.IsNullOrEmpty(o.SourceFile)) { if (!File.Exists(o.SourceFile)) { @@ -193,12 +194,16 @@ static void Main(string[] args) engine_output += "\n" + sb.ToString(); } - var standardOutput = new StreamWriter(Console.OpenStandardOutput()); - standardOutput.AutoFlush = true; + var standardOutput = new StreamWriter(Console.OpenStandardOutput()) + { + AutoFlush = true + }; Console.SetOut(standardOutput); - var standardError = new StreamWriter(Console.OpenStandardError()); - standardError.AutoFlush = true; + var standardError = new StreamWriter(Console.OpenStandardError()) + { + AutoFlush = true + }; Console.SetError(standardError); @@ -216,7 +221,7 @@ static void Main(string[] args) // Start the Single Stepping Debug Session if Debug Flag is set - Debug_Proc(o, source_file_contents, FrameStack, rmp.RamContents); + Debug_Proc(o, source_file_contents, FrameStack); Console.Out.WriteLine("Debug Session Complete"); //foreach(Frame f in FrameStack) @@ -233,7 +238,7 @@ static void Main(string[] args) }); } - private static void Debug_Proc(Options o, List source_file_contents, List FrameStack, List RamContentsList) + private static void Debug_Proc(Options o, List source_file_contents, List FrameStack) { if (o.Debug) { @@ -421,14 +426,14 @@ private static bool IsAfterHLT(string s) { return (s.ToUpper() == "HLT"); } - private static readonly string Banner = - "*********************************************************\n"+ + private const string Banner = + "*********************************************************\n" + "* ____ _ ____ _ _____ *\n" + "* / ___| / \\ | _ \\/ | ____|_ __ ___ _ _ *\n" + "* \\___ \\ / _ \\ | |_) | | _| | '_ ` _ \\| | | | *\n" + "* ___) / ___ \\| __/| | |___| | | | | | |_| | *\n" + - "* |____/_/ \\_\\_| |_|_____|_| |_| |_|\\__,_| *\n"+ - "* *\n"+ + "* |____/_/ \\_\\_| |_|_____|_| |_| |_|\\__,_| *\n" + + "* *\n" + "*********************************************************\n" + "* CC Bob Baker - 2020 *\n" + "*********************************************************\n"; diff --git a/SAP1EMU.Engine/EngineProc.cs b/SAP1EMU.Engine/EngineProc.cs index c66c8bad..f6306517 100644 --- a/SAP1EMU.Engine/EngineProc.cs +++ b/SAP1EMU.Engine/EngineProc.cs @@ -12,7 +12,7 @@ namespace SAP1EMU.Engine public class EngineProc { string OutPutRegContents = ""; - private List _FrameStack = new List(); + private readonly List _FrameStack = new List(); public List FrameStack() { @@ -38,14 +38,14 @@ public string GetOutput() } - private RAMProgram program { get; set; } + private RAMProgram Program { get; set; } public void Init(RAMProgram program) { if (program == null) { - this.program = new RAMProgram(new List()); + this.Program = new RAMProgram(new List()); } - this.program = program; + this.Program = program; } @@ -85,7 +85,7 @@ public void Run() // Load the program into the RAM - ram.LoadProgram(program); + ram.LoadProgram(Program); diff --git a/SAP1EMU.Engine/EngineRuntimeException.cs b/SAP1EMU.Engine/EngineRuntimeException.cs index c8e4a801..82147ed1 100644 --- a/SAP1EMU.Engine/EngineRuntimeException.cs +++ b/SAP1EMU.Engine/EngineRuntimeException.cs @@ -13,5 +13,9 @@ public EngineRuntimeException(string message) : base(message) public EngineRuntimeException(string message, Exception innerException) : base(message, innerException) { } + + private EngineRuntimeException() + { + } } } diff --git a/SAP1EMU.Lib.Test/AssemblerTest.cs b/SAP1EMU.Lib.Test/AssemblerTest.cs index be73ceba..dc55b164 100644 --- a/SAP1EMU.Lib.Test/AssemblerTest.cs +++ b/SAP1EMU.Lib.Test/AssemblerTest.cs @@ -362,7 +362,7 @@ public void TestParseList_Invalid_Code_1() _ = Assemble.ParseFileContents(asm); Assert.Fail(); } - catch (ParseException pe) + catch (ParseException) { Assert.IsTrue(true); } @@ -383,7 +383,7 @@ public void TestParseList_Invalid_Code_2() _ = Assemble.ParseFileContents(asm); Assert.Fail(); } - catch (ParseException pe) + catch (ParseException) { Assert.IsTrue(true); } @@ -409,7 +409,7 @@ public void TestParseList_Invalid_Code_3() _ = Assemble.ParseFileContents(asm); Assert.Fail(); } - catch (ParseException pe) + catch (ParseException) { Assert.IsTrue(true); } diff --git a/SAP1EMU.Lib/Components/ALU.cs b/SAP1EMU.Lib/Components/ALU.cs index 290b2170..fae5b21b 100644 --- a/SAP1EMU.Lib/Components/ALU.cs +++ b/SAP1EMU.Lib/Components/ALU.cs @@ -8,17 +8,14 @@ namespace SAP1EMU.Lib.Components { public class ALU : IObserver { - // CP EP LM_ CE_ LI_ EI_ LA_ EA SU EU LB_ LO_ - - private readonly string controlWordMask = "000000001100"; // SU EU private string RegContent { get; set; } - private AReg areg { get; set; } - private BReg breg { get; set; } + private AReg Areg { get; set; } + private BReg Breg { get; set; } public ALU(ref AReg areg, ref BReg breg) { - this.areg = areg; - this.breg = breg; + this.Areg = areg; + this.Breg = breg; } //************************************************************************************************************************ private void Exec(TicTok tictok) @@ -37,11 +34,11 @@ private void Exec(TicTok tictok) // Active Hi, SUB on Tic if (cw[8] == '1' && tictok.ClockState == TicTok.State.Tic) { - temp = Compute(areg.ToString(), breg.ToString(), false); + temp = Compute(Areg.ToString(), Breg.ToString(), false); } else // ADD { - temp = Compute(areg.ToString(), breg.ToString(), true); + temp = Compute(Areg.ToString(), Breg.ToString(), true); } // For Frame ToString support @@ -118,13 +115,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) diff --git a/SAP1EMU.Lib/Components/Clock.cs b/SAP1EMU.Lib/Components/Clock.cs index 61384b02..2a09fbdc 100644 --- a/SAP1EMU.Lib/Components/Clock.cs +++ b/SAP1EMU.Lib/Components/Clock.cs @@ -8,7 +8,7 @@ public class Clock : IObservable { public bool IsEnabled { get; set; } - private List> observers; + private readonly List> observers; public Clock() { @@ -35,8 +35,8 @@ public IDisposable Subscribe(IObserver observer) private class Unsubscriber : IDisposable { - private List> _observers; - private IObserver _observer; + private readonly List> _observers; + private readonly IObserver _observer; public Unsubscriber(List> observers, IObserver observer) { diff --git a/SAP1EMU.Lib/Components/ClockException.cs b/SAP1EMU.Lib/Components/ClockException.cs index f336533c..a86faf17 100644 --- a/SAP1EMU.Lib/Components/ClockException.cs +++ b/SAP1EMU.Lib/Components/ClockException.cs @@ -8,5 +8,13 @@ public class ClockException : Exception { internal ClockException() { } + + public ClockException(string message) : base(message) + { + } + + public ClockException(string message, Exception innerException) : base(message, innerException) + { + } } } diff --git a/SAP1EMU.Lib/Components/RAM.cs b/SAP1EMU.Lib/Components/RAM.cs index 177ecd48..104ebc60 100644 --- a/SAP1EMU.Lib/Components/RAM.cs +++ b/SAP1EMU.Lib/Components/RAM.cs @@ -10,8 +10,6 @@ public class RAM : IObserver { private List RamContents = new List(); - // CP EP LM_ CE_ LI_ EI_ LA_ EA SU EU LB_ LO_ - private readonly string controlWordMask = "000100000000"; // CE_ private string MARContents { get; set; } private string RAM_Register_Content { get; set; } // For ToString() @@ -27,7 +25,6 @@ private void Exec(TicTok tictok) { string content = GetWordAt(MARContents); Wbus.Instance().Value = content; - System.Console.Error.WriteLine($"R Out: {content}"); } // LR_, Active Low, Pull on Tok @@ -36,10 +33,7 @@ private void Exec(TicTok tictok) string word = Wbus.Instance().Value; SetWordAt(MARContents, word); RAM_Register_Content = word; - System.Console.Error.WriteLine($"R In: {word}"); } - - } @@ -98,13 +92,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) diff --git a/SAP1EMU.Lib/Components/SEQ.cs b/SAP1EMU.Lib/Components/SEQ.cs index ea130d68..b34afb39 100644 --- a/SAP1EMU.Lib/Components/SEQ.cs +++ b/SAP1EMU.Lib/Components/SEQ.cs @@ -223,6 +223,7 @@ public static SEQ Instance() _instance.SupportedCommandsBinTable.Add("STA", "0011"); _instance.SupportedCommandsBinTable.Add("JMP", "0100"); _instance.SupportedCommandsBinTable.Add("JEQ", "0101"); + _instance.SupportedCommandsBinTable.Add("JIC", "1001"); _instance.SupportedCommandsBinTable.Add("OUT", "1110"); _instance.SupportedCommandsBinTable.Add("HLT", "1111"); _instance.SupportedCommandsBinTable.Add("NOP", "0000"); diff --git a/SAP1EMU.Lib/Components/TicTok.cs b/SAP1EMU.Lib/Components/TicTok.cs index 0622f0c7..7d257d01 100644 --- a/SAP1EMU.Lib/Components/TicTok.cs +++ b/SAP1EMU.Lib/Components/TicTok.cs @@ -4,6 +4,10 @@ namespace SAP1EMU.Lib.Components { + /// + /// This will prevent "RaceCases" on the board. + /// All push functions will happen on Tic and all pull functions will happen on Tok + /// public struct TicTok { public enum State @@ -12,12 +16,7 @@ public enum State Tok }; - // - - - // TODO - This will prevent racecases when one reg is pushing to wbus and another is pulling - // All pushing to Wbus will happen on Tic - // All pulling from Wbus will happen on Toc + public State ClockState { get; private set; } public void ToggleClockState() @@ -29,12 +28,35 @@ public void ToggleClockState() else { ClockState = State.Tic; - } } public void Init() { ClockState = State.Tic; } + + + + #region Equals Override Sutff + public override bool Equals(object obj) + { + return base.Equals(obj) && this.ClockState == ((TicTok)obj).ClockState; + } + + public override int GetHashCode() + { + throw new NotImplementedException(); + } + + public static bool operator ==(TicTok left, TicTok right) + { + return left.Equals(right); + } + + public static bool operator !=(TicTok left, TicTok right) + { + return !(left == right); + } + #endregion } } diff --git a/SAP1EMU.Lib/Frame.cs b/SAP1EMU.Lib/Frame.cs index 7d11874c..1b539448 100644 --- a/SAP1EMU.Lib/Frame.cs +++ b/SAP1EMU.Lib/Frame.cs @@ -66,7 +66,7 @@ private string InstuctionDecode(string BinInstruction, int TState) { return "???"; } - if (temp != "") + if (!string.IsNullOrEmpty(temp)) { return temp; } diff --git a/SAP1EMU.Lib/RAMProgram.cs b/SAP1EMU.Lib/RAMProgram.cs index 3deceb6c..c8dfa092 100644 --- a/SAP1EMU.Lib/RAMProgram.cs +++ b/SAP1EMU.Lib/RAMProgram.cs @@ -28,7 +28,7 @@ public RAMProgram(List RamContents) { this.RamContents.Add(s); } - for (int i = count; count < 15; count++) + for (int i = count; i < 15; i++) { this.RamContents.Add("00000000"); } diff --git a/SAP1EMU.Lib/Registers/AReg.cs b/SAP1EMU.Lib/Registers/AReg.cs index adfb129f..b60ffce3 100644 --- a/SAP1EMU.Lib/Registers/AReg.cs +++ b/SAP1EMU.Lib/Registers/AReg.cs @@ -11,9 +11,6 @@ public class AReg : IObserver { private string RegContent { get; set; } - // LA_ EA - private readonly string controlWordMask = "000000110000"; - private void Exec(TicTok tictok) { string cw = SEQ.Instance().ControlWord; @@ -26,9 +23,6 @@ private void Exec(TicTok tictok) { // Send A to the WBus Wbus.Instance().Value = RegContent; - - System.Console.Error.WriteLine($"A Out: {RegContent}"); - } // Active Low, Pull on Tok @@ -36,8 +30,6 @@ private void Exec(TicTok tictok) { // Store Wbus val in A RegContent = Wbus.Instance().Value; - System.Console.Error.WriteLine($"A In : {RegContent}"); - } @@ -55,19 +47,17 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) { Exec(value); - //System.Console.WriteLine("AReg is registered!"); } public virtual void Unsubscribe() diff --git a/SAP1EMU.Lib/Registers/BReg.cs b/SAP1EMU.Lib/Registers/BReg.cs index e15eadf0..acddc046 100644 --- a/SAP1EMU.Lib/Registers/BReg.cs +++ b/SAP1EMU.Lib/Registers/BReg.cs @@ -9,8 +9,6 @@ public class BReg : IObserver { private string RegContent { get; set; } - - private readonly string controlWordMask = "000000000010"; // LB_ private void Exec(TicTok tictok) { string cw = SEQ.Instance().ControlWord; @@ -23,9 +21,6 @@ private void Exec(TicTok tictok) { // Store Wbus val in B RegContent = Wbus.Instance().Value; - System.Console.Error.WriteLine($"B IN : {RegContent}"); - - } } @@ -41,13 +36,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) diff --git a/SAP1EMU.Lib/Registers/IReg.cs b/SAP1EMU.Lib/Registers/IReg.cs index 72454c6c..77648257 100644 --- a/SAP1EMU.Lib/Registers/IReg.cs +++ b/SAP1EMU.Lib/Registers/IReg.cs @@ -10,8 +10,6 @@ public class IReg : IObserver private string RegContent { get; set; } = "00000000"; - private readonly string controlWordMask = "000011000000"; // LI_ EI_ - private void Exec(TicTok tictok) { string cw = SEQ.Instance().ControlWord; @@ -24,22 +22,12 @@ private void Exec(TicTok tictok) { // Send A to the WBus Wbus.Instance().Value = RegContent; - System.Console.Error.WriteLine($"I Out: {RegContent}"); - - } // Active Low, Pull on Tok if (cw[4] == '0' && tictok.ClockState == TicTok.State.Tok) { - // Store Wbus val in A - // Only upper 4 bits - //string temp = Wbus.Instance().Value.Substring(0, 4); - //RegContent = temp + "0000"; // Zero out the lowwer 4 bits RegContent = Wbus.Instance().Value; - - System.Console.Error.WriteLine($"I In : {RegContent}"); - } } @@ -64,13 +52,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) diff --git a/SAP1EMU.Lib/Registers/MReg.cs b/SAP1EMU.Lib/Registers/MReg.cs index e14a7dc5..79f9c8d1 100644 --- a/SAP1EMU.Lib/Registers/MReg.cs +++ b/SAP1EMU.Lib/Registers/MReg.cs @@ -8,7 +8,6 @@ namespace SAP1EMU.Lib.Registers public class MReg : IObserver { private string RegContent { get; set; } - private readonly string controlWordMask = "001000000000"; // LM_ private readonly RAM ram; public MReg(ref RAM ram) { @@ -25,21 +24,12 @@ private void Exec(TicTok tictok) // Active Low, Pull on Tok if (cw[2] == '0' && tictok.ClockState == TicTok.State.Tok) { - Wbus bus = Wbus.Instance(); // Store Wbus val in A RegContent = Wbus.Instance().Value.Substring(4,4); // Send the MAR data to the RAM ram.IncomingMARData(RegContent); - // TODO - likely bug here with this ram pointer bs. - // I didnt want to do this, but setting up the observer pattern twice in one object was not working well. - - - System.Console.Error.WriteLine($"M In : {RegContent}"); - } - - } @@ -55,13 +45,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) diff --git a/SAP1EMU.Lib/Registers/MarUpdate.cs b/SAP1EMU.Lib/Registers/MarUpdate.cs index 69b3e468..4f37ddae 100644 --- a/SAP1EMU.Lib/Registers/MarUpdate.cs +++ b/SAP1EMU.Lib/Registers/MarUpdate.cs @@ -4,8 +4,32 @@ namespace SAP1EMU.Lib.Registers { + // TODO for Observer Pattern between RAM and MAR public struct MarUpdate { public string Value { get; set; } + + + + + public override bool Equals(object obj) + { + return this.Value == ((MarUpdate)obj).Value; + } + + public override int GetHashCode() + { + return Value.GetHashCode(); + } + + public static bool operator ==(MarUpdate left, MarUpdate right) + { + return left.Equals(right); + } + + public static bool operator !=(MarUpdate left, MarUpdate right) + { + return !(left == right); + } } } diff --git a/SAP1EMU.Lib/Registers/OReg.cs b/SAP1EMU.Lib/Registers/OReg.cs index da6aa2d7..16e34818 100644 --- a/SAP1EMU.Lib/Registers/OReg.cs +++ b/SAP1EMU.Lib/Registers/OReg.cs @@ -8,7 +8,6 @@ namespace SAP1EMU.Lib.Registers public class OReg : IObserver { private string RegContent { get; set; } - private readonly string controlWordMask = "000000000001"; // LO_ private void Exec(TicTok tictok) { string cw = SEQ.Instance().ControlWord; @@ -21,9 +20,6 @@ private void Exec(TicTok tictok) { // Store Wbus val in A RegContent = Wbus.Instance().Value; - System.Console.Error.WriteLine($"O In : {RegContent}"); - - } } @@ -38,13 +34,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value) diff --git a/SAP1EMU.Lib/Registers/PC.cs b/SAP1EMU.Lib/Registers/PC.cs index 2ac6aa26..fd165ca4 100644 --- a/SAP1EMU.Lib/Registers/PC.cs +++ b/SAP1EMU.Lib/Registers/PC.cs @@ -8,11 +8,10 @@ namespace SAP1EMU.Lib.Registers { public class PC : IObserver { - // CP EP LM_ CE_ LI_ EI_ LA_ EA SU EU LB_ LO_ - IReg ireg; - AReg areg; + readonly IReg ireg; + readonly AReg areg; private string RegContent { get; set; } - private readonly string controlWordMask = "110000000000"; // CP EP + public PC(ref IReg ireg, ref AReg areg) { RegContent = "00000000"; @@ -35,8 +34,6 @@ public void Exec(TicTok tictok) { // Send A to the WBus Wbus.Instance().Value = RegContent; - System.Console.Error.WriteLine($"PCOut: {RegContent}"); - } @@ -74,20 +71,9 @@ public void Exec(TicTok tictok) } } - // Check Flags - // Check intruction - - - - // I might change LP_ to CJ for check_jump - // than i could pass an Ireg* to the PC to it can tell what the instruction is - // it would be like a mini-jmp register in the PC - - - - //// Send A to the WBus - //Wbus.Instance().Value = RegContent; - //System.Console.Error.WriteLine($"PCOut: {RegContent}"); + // I might change LP_ to CJ for check_jump + // than i could pass an Ireg* to the PC to it can tell what the instruction is + // it would be like a mini-jmp register in the PC } @@ -107,13 +93,12 @@ public virtual void Subscribe(IObservable clock) void IObserver.OnCompleted() { - Console.WriteLine("The Location Tracker has completed transmitting data to {0}.", "AReg"); this.Unsubscribe(); } void IObserver.OnError(Exception error) { - Console.WriteLine("{0}: The TicTok cannot be determined.", "AReg"); + throw error; } void IObserver.OnNext(TicTok value)