Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can now enter codes into the conclude and the hash value will be printed out #8

Closed
wants to merge 3 commits into from
Closed
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
47 changes: 37 additions & 10 deletions AuraAssembler/AuraAssembler/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,33 +13,35 @@ class Program
static void Main(string[] args)
{
Init();

Parse("JMP start");

//string str = Console.ReadLine();
//Parse(str);
test();
Console.WriteLine("Press any key to exit");
Console.ReadKey();
}

static void Init()
{
labels = new List<Label>();
instruction = new Hashtable();
//System
instruction.Add("HALT", 0); //
instruction.Add("SYS0", 16); // <reg>
instruction.Add("SYS1", 17); // <val>

//Logic
instruction.Add("AND0", 32); // <reg>, <reg>
instruction.Add("AND1", 33); // <reg>, <val>
instruction.Add("OR0", 34); // <reg>, <reg>
instruction.Add("OR1", 35); // <reg>, <val>
instruction.Add("XOR0", 36); // <reg>, <reg>
instruction.Add("XOR1", 37); // <reg>, <val>
instruction.Add("NOT", 38); // <reg>

//Math
instruction.Add("ADD", 40); // <reg>, <reg>
instruction.Add("SUB", 41); // <reg>, <reg>
instruction.Add("MUL", 42); // <reg>, <reg>
instruction.Add("DIV", 43); // <reg>, <reg>

//Location
instruction.Add("MOV0", 48); // <reg>, <reg>
instruction.Add("MOV1", 49); // <reg>, <val>
instruction.Add("INC", 50); // <reg>
Expand All @@ -58,7 +60,7 @@ static void Init()
instruction.Add("W32", 69); // <reg>, <mem>
instruction.Add("PUSH", 70); // <reg>
instruction.Add("POP", 71); // <reg>

//Tests
instruction.Add("TEST0", 80); // <reg> = <reg>
instruction.Add("TEST1", 81); // <reg> = <val>
instruction.Add("TEST2", 82); // <reg> < <reg>
Expand All @@ -69,7 +71,7 @@ static void Init()
instruction.Add("TEST7", 87); // <reg> <= <val>
instruction.Add("TEST8", 88); // <reg> >= <reg>
instruction.Add("TEST9", 89); // <reg> >= <val>

//Ip jump direction
instruction.Add("JMP0", 100); // <reg>
instruction.Add("JMP1", 101); // <mem>
instruction.Add("JMP2", 102); // <val>
Expand All @@ -79,7 +81,7 @@ static void Init()
instruction.Add("JF0", 106); // <reg>
instruction.Add("JF1", 107); // <mem>
instruction.Add("JF2", 108); // <val>

//Ip direction
instruction.Add("RET", 128); //
instruction.Add("CALL0", 129); // <reg>
instruction.Add("CALL1", 130); // <mem>
Expand All @@ -96,9 +98,34 @@ static void Parse(string line)

foreach (string token in tokens)
{
Console.WriteLine($"'{token}'");
Console.WriteLine($"'"+instruction[token] +"'");
}
}
}

static bool test()
{
string ss = "";

bool rc=true;
int count=0;
for (int s=0; s< instruction.Count; s++) {

//ss ="."+instruction[s];

if (ss != "."+ instruction[s])
{
rc = false;
Console.WriteLine("Error for " + ss + "Check code");
}
else {
count++;

}
}
Console.WriteLine(count +"/55 Test Passed");

return rc;
}
}
}