Skip to content

Commit 22855f1

Browse files
committed
Code cleanup and minor performance fixes
1 parent a50720c commit 22855f1

File tree

11 files changed

+28
-27
lines changed

11 files changed

+28
-27
lines changed

Core8/CPU.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public void Run()
6161
{
6262
while (running)
6363
{
64-
if (debug)
64+
if (debug)
6565
{
6666
if (breakpoints.Contains(Registers.PC.Content))
6767
{

Core8/Interrupts.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using Core8.Model.Interfaces;
2-
using Serilog;
32

43
namespace Core8
54
{

Model/Instructions/Group3Instructions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class Group3Instructions : InstructionsBase
88
{
99
private const int MQL_MASK = 1 << 4;
1010
private const int MQA_MASK = 1 << 6;
11-
private const int SWP_MASK = 1 << 4 | 1 << 6;
11+
private const int SWP_MASK = MQL_MASK | MQA_MASK;
1212
private const int CLA_MASK = 1 << 7;
1313

1414
public Group3Instructions(ICPU cpu) : base(cpu)

Model/Instructions/KeyboardInstructions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class KeyboardInstructions : TeleptypeInstructionsBase
1111
private const int KCC_MASK = 0b_010;
1212
private const int KRS_MASK = 0b_100;
1313
private const int KIE_MASK = 0b_101;
14-
private const int KRB_MASK = 0b_110;
14+
private const int KRB_MASK = KCC_MASK | KRS_MASK;
1515

1616
public KeyboardInstructions(ICPU cpu) : base(cpu)
1717
{

Model/Instructions/MemoryManagementInstructions.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ namespace Core8.Model.Instructions
66
{
77
public class MemoryManagementInstructions : PrivilegedInstructionsBase
88
{
9-
private const int CINT_MASK = 0b_110_010_000_100;
10-
private const int RDF_MASK = 0b_110_010_001_100;
11-
private const int RIF_MASK = 0b_110_010_010_100;
12-
private const int RIB_MASK = 0b_110_010_011_100;
13-
private const int RMF_MASK = 0b_110_010_100_100;
14-
private const int SINT_MASK = 0b_110_010_101_100;
15-
private const int CUF_MASK = 0b_110_010_110_100;
16-
private const int SUF_MASK = 0b_110_010_111_100;
9+
private const int MEM_MGMT_MASK = 0b_110_010_000_100;
10+
11+
private const int CINT_MASK = MEM_MGMT_MASK;
12+
private const int RDF_MASK = (0b_001 << 3) | MEM_MGMT_MASK;
13+
private const int RIF_MASK = (0b_010 << 3) | MEM_MGMT_MASK;
14+
private const int RIB_MASK = (0b_011 << 3) | MEM_MGMT_MASK;
15+
private const int RMF_MASK = (0b_100 << 3) | MEM_MGMT_MASK;
16+
private const int SINT_MASK = (0b_101 << 3) | MEM_MGMT_MASK;
17+
private const int CUF_MASK = (0b_110 << 3) | MEM_MGMT_MASK;
18+
private const int SUF_MASK = (0b_111 << 3) | MEM_MGMT_MASK;
1719

1820
private const int CDF_MASK = 1 << 0;
1921
private const int CIF_MASK = 1 << 1;

Model/Instructions/MemoryReferenceInstructions.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ namespace Core8.Model.Instructions
88
{
99
public class MemoryReferenceInstructions : InstructionsBase
1010
{
11-
private const int AND_MASK = 0b_000_00_0000000;
12-
private const int TAD_MASK = 0b_001_00_0000000;
13-
private const int ISZ_MASK = 0b_010_00_0000000;
14-
private const int DCA_MASK = 0b_011_00_0000000;
15-
private const int JMS_MASK = 0b_100_00_0000000;
16-
private const int JMP_MASK = 0b_101_00_0000000;
11+
private const int AND_MASK = 0b_000 << 9;
12+
private const int TAD_MASK = 0b_001 << 9;
13+
private const int ISZ_MASK = 0b_010 << 9;
14+
private const int DCA_MASK = 0b_011 << 9;
15+
private const int JMS_MASK = 0b_100 << 9;
16+
private const int JMP_MASK = 0b_101 << 9;
1717

1818
private const int ZERO = 1 << 7;
1919
private const int INDIRECT = 1 << 8;

Model/Instructions/TeleprinterInstructions.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@ namespace Core8.Model.Instructions
66
{
77
public class TeleprinterInstructions : TeleptypeInstructionsBase
88
{
9-
private const int TFL_MASK = 0b_000;
10-
private const int TSF_MASK = 0b_001;
11-
private const int TCF_MASK = 0b_010;
12-
private const int TPC_MASK = 0b_100;
13-
private const int TLS_MASK = 0b_110;
9+
private const int TFL_MASK = 0;
10+
private const int TSF_MASK = 1 << 0;
11+
private const int TCF_MASK = 1 << 1;
12+
private const int TPC_MASK = 1 << 2;
13+
private const int TLS_MASK = TCF_MASK | TPC_MASK;
1414

1515
public TeleprinterInstructions(ICPU cpu) : base(cpu)
1616
{

Tests/Core8Tests/MAINDEC/Abstract/MAINDECTestsBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ protected void StartAndWaitForCompletion()
5252

5353
timeout = sw.Elapsed > MaxRunningTime;
5454

55-
Thread.Sleep(100);
55+
Thread.Sleep(50);
5656
}
5757

5858
if (!ExpectHLT)

Tests/Core8Tests/MAINDEC/RandomJMPJMSTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class RandomJMPJMSTest : MAINDECTestsBase
88
{
99
protected override string TapeName => @"MAINDEC/tapes/MAINDEC-8E-D0JC-PB.bin";
1010

11-
protected override string[] ExpectedOutput => new[] { "JC\r\n" };
11+
protected override string[] ExpectedOutput => new[] { "\r\nJC" };
1212

1313
protected override string[] UnexpectedOutput => new[] { "F " };
1414

Tests/Core8Tests/MAINDEC/RandomJMPTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class RandomJMPTest : MAINDECTestsBase
88
{
99
protected override string TapeName => @"MAINDEC/tapes/MAINDEC-8E-D0HC-PB.bin";
1010

11-
protected override string[] ExpectedOutput => new[] { "HC\r\n" };
11+
protected override string[] ExpectedOutput => new[] { "\r\nHC" };
1212

1313
protected override string[] UnexpectedOutput => new[] { "Z =" };
1414

Tests/Core8Tests/MAINDEC/RandomTADTest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ public class RandomTADTest : MAINDECTestsBase
88
{
99
protected override string TapeName => @"MAINDEC/tapes/MAINDEC-8E-D0EB-PB.bin";
1010

11-
protected override string[] ExpectedOutput => new[] { "T\r\n" };
11+
protected override string[] ExpectedOutput => new[] { "\r\nT" };
1212

1313
[TestMethod]
1414
public override void Start()

0 commit comments

Comments
 (0)