-
-
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.
- Loading branch information
Showing
16 changed files
with
630 additions
and
162 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
using SAP1EMU.Lib; | ||
|
||
namespace SAP1EMU.Assembler | ||
{ | ||
public class InstructionValidator | ||
{ | ||
public static bool IsValidInstruction(string instruction, InstructionSet iset) | ||
{ | ||
if(instruction.ToLower() == "nop") | ||
{ | ||
return true; | ||
} | ||
try | ||
{ | ||
return !string.IsNullOrEmpty(iset.instructions.Find(x => x.OpCode.ToLower().Equals(instruction.ToLower())).OpCode); | ||
} | ||
catch(NullReferenceException) | ||
{ | ||
return false; | ||
} | ||
} | ||
public static string GetUpperNibble(string instruction, InstructionSet iset) | ||
{ | ||
if (instruction.ToLower() == "nop") | ||
{ | ||
return "0000"; | ||
} | ||
return iset.instructions.Find(x => x.OpCode.ToLower().Equals(instruction.ToLower())).BinCode; | ||
} | ||
} | ||
} |
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,180 @@ | ||
[ | ||
{ | ||
"SetName": "SAP1Emu", | ||
"SetDescription": "The full intruction set for the SAP1Emu Project.", | ||
"instructions": [ | ||
{ | ||
"OpCode": "LDA", | ||
"BinCode": "0000", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00011010001111", | ||
"00101100001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "ADD", | ||
"BinCode": "0001", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00011010001111", | ||
"00101110000111", | ||
"00111100011111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "SUB", | ||
"BinCode": "0010", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00011010001111", | ||
"00101110000111", | ||
"00111100111111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "STA", | ||
"BinCode": "0011", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00011010001111", | ||
"00111111001101", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "JMP", | ||
"BinCode": "0100", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00111010001100", | ||
"00111110001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "JEQ", | ||
"BinCode": "0101", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00111010001100", | ||
"00111110001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "JIC", | ||
"BinCode": "1001", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00111010001100", | ||
"00111110001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "OUT", | ||
"BinCode": "1110", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00111111001011", | ||
"00111110001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "HLT", | ||
"BinCode": "1111", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00111110001111", | ||
"00111110001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "NOP", | ||
"BinCode": "0000", | ||
"MicroCode": [ | ||
"00111110001111", | ||
"00111110001111", | ||
"00111110001111", | ||
"00111110001111", | ||
"00111110001111", | ||
"00111110001111" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"SetName": "Malvino", | ||
"SetDescription": "The instruction set outlined in Digital Computer Electronics by Malvino & Brown.\nThe SAP1EMU Set is a superset of the Malvino Set.", | ||
"instructions": [ | ||
{ | ||
"OpCode": "LDA", | ||
"BinCode": "0000", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00011010001111", | ||
"00101100001111", | ||
"00111110001111" | ||
] | ||
}, | ||
{ | ||
"OpCode": "ADD", | ||
"BinCode": "0001", | ||
"MicroCode": [ | ||
"01011110001111", | ||
"10111110001111", | ||
"00100110001111", | ||
"00011010001111", | ||
"00101110000111", | ||
"00111100011111" | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"SetName": "BenEater", | ||
"SetDescription": "The instruction set outlined by Ben Eater.", | ||
"instructions": [ | ||
{ | ||
"OpCode": "ADD", | ||
"BinCode": "1111", | ||
"MicroCode": [ | ||
"10101", | ||
"00011" | ||
] | ||
}, | ||
{ | ||
"OpCode": "LDA", | ||
"BinCode": "0000", | ||
"MicroCode": [ | ||
"01010", | ||
"11111" | ||
] | ||
} | ||
] | ||
} | ||
] |
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.