-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Major refactoring for 16 bit registers
Allows overflow correction, sign extending, and overlapping custom register actions with the memory map
- Loading branch information
Showing
21 changed files
with
507 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Base | ||
{ | ||
class ErasableMemory : IWord | ||
{ | ||
protected MemoryAddress memory; | ||
|
||
public ErasableMemory() | ||
{ | ||
} | ||
|
||
public ErasableMemory(MemoryAddress memory) | ||
{ | ||
this.memory = memory; | ||
} | ||
|
||
public void Write(IWord word) | ||
{ | ||
// if 16-bit, apply overflow correction and write 15-bit value | ||
if (word.Is16Bit) | ||
{ | ||
uint value = word.Read(); | ||
|
||
// get lower 14 bits | ||
uint lowerBits = value & 0x3FFF; | ||
|
||
// move 16-th bit, into 15th position, isolate it, and set it in above value; | ||
value = (value >> 1 & 0x4000) | lowerBits; | ||
|
||
memory.Write((ushort)value); | ||
} | ||
else | ||
memory.Write(word.Read()); | ||
} | ||
|
||
public bool Is16Bit | ||
{ | ||
get { return false; } | ||
} | ||
|
||
|
||
public ushort Address | ||
{ | ||
get { return memory.Address; } | ||
} | ||
|
||
public ushort Read() | ||
{ | ||
return memory.Read(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Base | ||
{ | ||
class FixedMemory : IWord | ||
{ | ||
private MemoryAddress memory; | ||
|
||
public FixedMemory(MemoryAddress memory) | ||
{ | ||
this.memory = memory; | ||
} | ||
|
||
public bool Is16Bit | ||
{ | ||
get { return false; } | ||
} | ||
|
||
public void Write(IWord word) | ||
{ | ||
throw new InvalidOperationException("Cannot write to a fixed memory location"); | ||
} | ||
|
||
public ushort Address | ||
{ | ||
get { return memory.Address; } | ||
} | ||
|
||
public ushort Read() | ||
{ | ||
return memory.Read(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Base | ||
{ | ||
interface IRegister | ||
{ | ||
MemoryAddress Memory { set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Base | ||
{ | ||
public interface IWord | ||
{ | ||
bool Is16Bit { get; } | ||
ushort Address { get; } | ||
|
||
ushort Read(); | ||
void Write(IWord word); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Base | ||
{ | ||
class Word : IWord | ||
{ | ||
public Word() | ||
{ | ||
} | ||
|
||
public Word(ushort value) | ||
{ | ||
this.Value = value; | ||
this.Is16Bit = true; | ||
} | ||
|
||
public ushort Value { get; set; } | ||
public bool Is16Bit { get; set; } | ||
public ushort Address { get;set; } | ||
|
||
public ushort Read() | ||
{ | ||
return Value; | ||
} | ||
|
||
public void Write(IWord word) | ||
{ | ||
Value = word.Read(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Apollo.Virtual.AGC.Base; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Instructions | ||
{ | ||
/// <summary> | ||
/// BZF - EX 0001 | ||
/// | ||
/// Jumps to a memory location in the fixed bank if the accumulator is 0 | ||
/// </summary> | ||
class BranchZeroToFixed : IInstruction | ||
{ | ||
public ushort Code | ||
{ | ||
get { return 0x01; } | ||
} | ||
|
||
public Processor CPU { get; set; } | ||
|
||
public void Execute(ushort K) | ||
{ | ||
if (CPU.A.Read() == 0) | ||
CPU.Z.Write(K); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
using Apollo.Virtual.AGC.Base; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
|
||
namespace Apollo.Virtual.AGC.Instructions | ||
{ | ||
/// <summary> | ||
/// EQC - EX 0010 | ||
/// 10-bit memroy instructions in the extra code set | ||
/// </summary> | ||
class ExtraQuarterCode: InstructionList, IInstruction | ||
{ | ||
public ExtraQuarterCode() | ||
: base(3) | ||
{ | ||
Add(new Augment { CPU = this.CPU }); | ||
} | ||
|
||
public ushort Code | ||
{ | ||
get { return 0x02; } | ||
} | ||
|
||
public Processor CPU { get; set; } | ||
|
||
public void Execute(ushort K) | ||
{ | ||
var quarterCode = (ushort)(K >> 10); | ||
K = (ushort)(K & 0x3FF); | ||
|
||
base[quarterCode].Execute(K); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.