Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ riderModule.iml
YODA_Python/venv/
YODA_TypeScript/node_modules/
YODA_Python/__pycache__/
.idea/
10 changes: 5 additions & 5 deletions YODA/OpCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ public static class OpCode
{
// Misc (opcodes without operands)
public const byte Halt = 0b0000_0000; // 00
public const byte Wait = 0b0000_0001; // 00
public const byte Ret = 0b0000_0011; // 02
public const byte Nop = 0b0000_0100; // 03
public const byte Sif = 0b0000_0101; // 04
public const byte Cif = 0b0000_0110; // 05
public const byte Wait = 0b0000_0001; // 01
public const byte Ret = 0b0000_0010; // 02
public const byte Nop = 0b0000_0011; // 03
public const byte Sif = 0b0000_0100; // 04
public const byte Cif = 0b0000_0101; // 05

public const byte SaveToFileMMM = 0b0001_0000; //16
public const byte SaveToFileMMI = 0b0001_0001; //17
Expand Down
18 changes: 17 additions & 1 deletion YODA/VirtualMachine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ public async Task Run(string folderPath)
Add(opCode);
continue;
case Mask.Sub:
throw new Exception("Due to lack of time this method has not been implemented");
// throw new Exception("Due to lack of time this method has not been implemented");
Sub(opCode);
continue;
case Mask.Inc:
Inc(opCode);
continue;
Expand Down Expand Up @@ -405,4 +407,18 @@ private byte Read(int location,int opCode, int mask)

return _memory[reference];
}

/// <summary>
/// Sub LHS RHS Total
/// </summary>
private void Sub(int opCode)
{
var lhs = Read(_instructionPointer + 1, opCode, 2);
var rhs = Read(_instructionPointer + 2, opCode, 1);
var location = Read(_instructionPointer + 3, opCode, 0);

if (Debug) Console.WriteLine($"{_instructionPointer:x4} Sub:: {lhs} - {rhs} = {lhs - rhs} ==> {location:x2}");
_memory[location] = (byte)(lhs - rhs); // Can overflow
_instructionPointer += 4;
}
}
56 changes: 56 additions & 0 deletions mark-csharp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.0.31903.59
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "mark-csharp", "mark-csharp", "{5C3CA1F0-BEFB-913A-467C-9BC8E8763114}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YodaExercises", "mark-csharp\YodaExercises\YodaExercises.csproj", "{8D8C9463-C990-4962-996E-1EEE84C8441E}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "YODA", "YODA", "{53427892-8E56-C6A7-C67E-0E35C96E3AED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleInstructionMachine", "YODA\SimpleInstructionMachine.csproj", "{7B6C7992-E188-49CD-AC66-6B959606752F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Debug|x64.ActiveCfg = Debug|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Debug|x64.Build.0 = Debug|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Debug|x86.ActiveCfg = Debug|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Debug|x86.Build.0 = Debug|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Release|Any CPU.Build.0 = Release|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Release|x64.ActiveCfg = Release|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Release|x64.Build.0 = Release|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Release|x86.ActiveCfg = Release|Any CPU
{8D8C9463-C990-4962-996E-1EEE84C8441E}.Release|x86.Build.0 = Release|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Debug|x64.ActiveCfg = Debug|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Debug|x64.Build.0 = Debug|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Debug|x86.ActiveCfg = Debug|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Debug|x86.Build.0 = Debug|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Release|Any CPU.Build.0 = Release|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Release|x64.ActiveCfg = Release|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Release|x64.Build.0 = Release|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Release|x86.ActiveCfg = Release|Any CPU
{7B6C7992-E188-49CD-AC66-6B959606752F}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{8D8C9463-C990-4962-996E-1EEE84C8441E} = {5C3CA1F0-BEFB-913A-467C-9BC8E8763114}
{7B6C7992-E188-49CD-AC66-6B959606752F} = {53427892-8E56-C6A7-C67E-0E35C96E3AED}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions mark-csharp/Files/0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions mark-csharp/Files/1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z
1 change: 1 addition & 0 deletions mark-csharp/Files/2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions mark-csharp/Files/9.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5 4 3 2 1 LIFTOFF
Binary file added mark-csharp/Files/ex1
Binary file not shown.
Binary file added mark-csharp/Files/ex2
Binary file not shown.
Binary file added mark-csharp/Files/ex3
Binary file not shown.
Binary file added mark-csharp/Files/ex4
Binary file not shown.
Binary file added mark-csharp/Files/ex5
Binary file not shown.
Binary file added mark-csharp/Files/ex6
Binary file not shown.
Binary file added mark-csharp/Files/ex8
Binary file not shown.
Binary file added mark-csharp/Files/refuelFile1
Binary file not shown.
Loading