-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
161 additions
and
23 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
10 changes: 10 additions & 0 deletions
10
src/MimaSim/MimaSim/Controls/MimaComponents/StackControl.axaml
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,10 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="MimaSim.Controls.MimaComponents.StackControl"> | ||
<Border BorderBrush="Black" BorderThickness="1" ToolTip.Tip="Stack"> | ||
|
||
</Border> | ||
</UserControl> |
13 changes: 13 additions & 0 deletions
13
src/MimaSim/MimaSim/Controls/MimaComponents/StackControl.axaml.cs
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,13 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace MimaSim.Controls.MimaComponents; | ||
|
||
public partial class StackControl : UserControl | ||
{ | ||
public StackControl() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
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
12 changes: 12 additions & 0 deletions
12
src/MimaSim/MimaSim/Controls/MimaComponents/Wrappers/StackWrapper.axaml
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 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:mimaComponents="clr-namespace:MimaSim.Controls.MimaComponents" | ||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" | ||
x:Class="MimaSim.Controls.MimaComponents.Wrappers.StackWrapper"> | ||
<StackPanel Spacing="5" Orientation="Vertical"> | ||
<TextBlock Text="Stack" TextAlignment="Center" VerticalAlignment="Center" /> | ||
<mimaComponents:StackControl Width="70" Height="140" /> | ||
</StackPanel> | ||
</UserControl> |
13 changes: 13 additions & 0 deletions
13
src/MimaSim/MimaSim/Controls/MimaComponents/Wrappers/StackWrapper.axaml.cs
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,13 @@ | ||
using Avalonia; | ||
using Avalonia.Controls; | ||
using Avalonia.Markup.Xaml; | ||
|
||
namespace MimaSim.Controls.MimaComponents.Wrappers; | ||
|
||
public partial class StackWrapper : UserControl | ||
{ | ||
public StackWrapper() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} |
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,28 @@ | ||
namespace MimaSim.MIMA.Components; | ||
|
||
public class Stack(CPU cpu) | ||
{ | ||
public short[] Data = new short[50]; | ||
|
||
public void Push() | ||
{ | ||
var sp = cpu.ControlUnit.SP.GetValue(); | ||
var value = cpu.Accumulator.GetValue(); | ||
|
||
Data[sp] = value; | ||
sp--; | ||
|
||
cpu.ControlUnit.SP.SetValue(sp); | ||
} | ||
|
||
public void Pop() | ||
{ | ||
var sp = cpu.ControlUnit.SP.GetValue(); | ||
var value = Data[sp]; | ||
|
||
cpu.Accumulator.SetValue(value); | ||
|
||
sp++; | ||
cpu.ControlUnit.SP.SetValue(sp); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/MimaSim/MimaSim/MIMA/Instructions/Stack/PopInstruction.cs
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,21 @@ | ||
using System.Text; | ||
using MimaSim.Core; | ||
using MimaSim.MIMA.Components; | ||
|
||
namespace MimaSim.MIMA.Instructions.Stack; | ||
|
||
public class PopInstruction : IInstruction, IDisassemblyInstruction | ||
{ | ||
public OpCodes OpCode => OpCodes.POP; | ||
|
||
public bool Invoke(CPU cpu) | ||
{ | ||
cpu.Stack.Pop(); | ||
return true; | ||
} | ||
|
||
public void Dissassemble(StringBuilder builder, Disassembler disassembler) | ||
{ | ||
builder.AppendLine("pop"); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
src/MimaSim/MimaSim/MIMA/Instructions/Stack/PushInstruction.cs
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,21 @@ | ||
using System.Text; | ||
using MimaSim.Core; | ||
using MimaSim.MIMA.Components; | ||
|
||
namespace MimaSim.MIMA.Instructions.Stack; | ||
|
||
public class PushInstruction : IInstruction, IDisassemblyInstruction | ||
{ | ||
public OpCodes OpCode => OpCodes.PUSH; | ||
|
||
public bool Invoke(CPU cpu) | ||
{ | ||
cpu.Stack.Push(); | ||
return true; | ||
} | ||
|
||
public void Dissassemble(StringBuilder builder, Disassembler disassembler) | ||
{ | ||
builder.AppendLine("push"); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,4 +12,6 @@ public enum Mnemnonics | |
CMPGT, | ||
ADD, | ||
SUB, | ||
PUSH, | ||
POP | ||
} |
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 |
---|---|---|
|
@@ -46,4 +46,7 @@ public enum OpCodes | |
MOV_MEM_REG = 0x41, | ||
MOV_REG_MEM = 0x42, | ||
MOV_MEM_MEM = 0x43, | ||
|
||
PUSH = 0x44, | ||
POP = 0x45, | ||
} |
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
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