Skip to content

Commit

Permalink
Adding better debug info
Browse files Browse the repository at this point in the history
  • Loading branch information
sictransit committed Feb 17, 2020
1 parent 2da39ba commit bb8ec55
Show file tree
Hide file tree
Showing 11 changed files with 35 additions and 21 deletions.
9 changes: 8 additions & 1 deletion Core8/CPU.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ public void Run()
{
if (debug)
{
Log.Information(Registers.ToString());

if (breakpoints.Contains(Registers.PC.Content))
{
Log.Information($"Breakpoint hit!");
Expand All @@ -74,7 +76,7 @@ public void Run()
{
break;
}
}
}

Interrupts.Interrupt();

Expand All @@ -83,6 +85,11 @@ public void Run()
Registers.PC.Increment();

instruction.Execute();

if (debug)
{
Log.Information(instruction.ToString());
}
}
}
catch (Exception ex)
Expand Down
7 changes: 7 additions & 0 deletions Core8/Registers.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using Core8.Model.Interfaces;
using Core8.Model.Register;
using Core8.Model.Register.Abstract;
using System.Linq;

namespace Core8
{
Expand Down Expand Up @@ -35,5 +37,10 @@ public Registers()
public UserFlag UF { get; }

public SaveField SF { get; }

public override string ToString()
{
return string.Join(' ', new RegisterBase[] { PC, AC, DF, IB, UB, UF, SF, MQ }.Select(x => x.ToString()));
}
}
}
2 changes: 2 additions & 0 deletions Emulator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ private static void Assemble(string palbart, string file, bool run, int starting
pdp.DumpMemory();
}

pdp.CPU.Debug(true);

pdp.Continue(waitForHalt: true);

Thread.Sleep(1000);
Expand Down
24 changes: 12 additions & 12 deletions Emulator/pal/gc.asm
Original file line number Diff line number Diff line change
Expand Up @@ -15,35 +15,35 @@ MTCHAR, 0000 /MYST CHARACTER

LOOP, /READ AND PRINT LOOP
TAD I AIX1 /INCREMENT AIX1, THEN LOAD ACC FROM THAT LOCATION
SNA /AC != 0? SKIP
HLT /HALT
SPA /POSITIVE AC? SKIP
JMS MYST /PERFORM MYST MAGIC!
SNA /AC != 0? SKIP!
HLT /WE'VE REACHED EOT, SO HALT
SPA /POSITIVE AC? SKIP!
JMS MYST /PERFORM MYST MAGIC
JMS TTYO /TTY OUTPUT
JMP LOOP /LOOP

MYST, 0 /MYST SUB-ROUTINE
DCA MTCHAR /TEMP STORE CHAR
TAD MTDATA /LOAD MYST DATA

SMA /BIT 0 SET? SKIP!
JMP .+3
ISZ MTCHAR /TWEAK IT!
ISZ MTCHAR /TWEAK IT!
SMA /BIT 0 SET? TIME FOR MAGIC!
JMP .+3 /APPARENTLY NOT
ISZ MTCHAR /DO MAGIC!
ISZ MTCHAR /MORE MAGIC!

RAL /ROTATE LEFT
SPA /BIT 0 CLEAR? SKIP!
ISZ MTCHAR /TWEAK IT!
SPA /BIT 0 CLEAR? NO MAGIC!
ISZ MTCHAR /DO MAGIC!

RAL /ROTATE LEFT
DCA MTDATA /AND STORE

TAD MTCHAR /LOAD SAVED CHAR
TAD MTCHAR /LOAD TEMP STORED CHAR
JMP I MYST /RETURN

TTYO, 0 /TTY OUTPUT SUB-ROUTINE
TLS /WRITE ACC TO TTY
TSF /TTY READY? SKIP
TSF /TTY READY? SKIP!
JMP .-1 /CHECK AGAIN
CLA /CLEAR ACC
JMP I TTYO /RETURN
Expand Down
2 changes: 1 addition & 1 deletion Model/Register/DataField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void SetDF(int value)

public override string ToString()
{
return string.Format($"{base.ToString()} {Content.ToOctalString()}");
return string.Format($"{base.ToString()} {Content.ToOctalString(1)}");
}
}
}
2 changes: 1 addition & 1 deletion Model/Register/InstructionBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void SetIB(int value)

public override string ToString()
{
return string.Format($"{base.ToString()} {Content.ToOctalString()}");
return string.Format($"{base.ToString()} {Content.ToOctalString(1)}");
}
}
}
2 changes: 1 addition & 1 deletion Model/Register/SaveField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void SetUF(int value)

public override string ToString()
{
return string.Format($"{base.ToString()} {Content.ToOctalString()}");
return string.Format($"{base.ToString()} {Content.ToOctalString(3)}");
}
}
}
2 changes: 1 addition & 1 deletion Model/Register/UserBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void SetUB(int value)

public override string ToString()
{
return string.Format($"{base.ToString()} {Content.ToOctalString()}");
return string.Format($"{base.ToString()} {Content.ToOctalString(1)}");
}
}
}
2 changes: 1 addition & 1 deletion Model/Register/UserFlag.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void SetUF(int value)

public override string ToString()
{
return string.Format($"{base.ToString()} {Content.ToOctalString()}");
return string.Format($"{base.ToString()} {Content.ToOctalString(1)}");
}
}
}
2 changes: 1 addition & 1 deletion Tests/Core8Tests/MAINDEC/Abstract/MAINDECTestsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public abstract class MAINDECTestsBase : InstructionTestsBase

protected virtual string[] UnexpectedOutput => new string[] { };

protected virtual TimeSpan MaxRunningTime => TimeSpan.FromSeconds(60);
protected virtual TimeSpan MaxRunningTime => TimeSpan.FromSeconds(10);

protected virtual bool ExpectHLT => false;

Expand Down
2 changes: 0 additions & 2 deletions Tests/Core8Tests/MAINDEC/AdderTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class AdderTest : MAINDECTestsBase

protected override string[] ExpectedOutput => new[] { "SIMAD", "SIMROT", "FCT", "RANDOM" };

protected override TimeSpan MaxRunningTime => TimeSpan.FromSeconds(600);

[TestMethod]
public override void Start()
{
Expand Down

0 comments on commit bb8ec55

Please sign in to comment.