diff --git a/prototypes/supervm-asm/App.config b/prototypes/supervm-asm/App.config
deleted file mode 100644
index d740e88..0000000
--- a/prototypes/supervm-asm/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/prototypes/supervm-asm/Makefile b/prototypes/supervm-asm/Makefile
new file mode 100644
index 0000000..adf2346
--- /dev/null
+++ b/prototypes/supervm-asm/Makefile
@@ -0,0 +1,7 @@
+
+CSC = mcs
+
+all: assembler.exe
+
+assembler.exe: assembler.cs
+ $(CSC) -out:$@ -target:exe $^
\ No newline at end of file
diff --git a/prototypes/supervm-asm/Properties/AssemblyInfo.cs b/prototypes/supervm-asm/Properties/AssemblyInfo.cs
deleted file mode 100644
index 547f0fb..0000000
--- a/prototypes/supervm-asm/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// Allgemeine Informationen über eine Assembly werden über die folgenden
-// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
-// die einer Assembly zugeordnet sind.
-[assembly: AssemblyTitle("supervm-asm")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("supervm-asm")]
-[assembly: AssemblyCopyright("Copyright © 2016")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
-// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
-// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
-[assembly: ComVisible(false)]
-
-// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
-[assembly: Guid("7b2cb53a-d2ef-4aef-b354-fcf28c581280")]
-
-// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
-//
-// Hauptversion
-// Nebenversion
-// Buildnummer
-// Revision
-//
-// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
-// übernehmen, indem Sie "*" eingeben:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/prototypes/supervm-asm/assembler b/prototypes/supervm-asm/assembler
new file mode 100644
index 0000000..adbf642
--- /dev/null
+++ b/prototypes/supervm-asm/assembler
@@ -0,0 +1 @@
+#!/usr/bin/mono assembler.exe
\ No newline at end of file
diff --git a/prototypes/supervm-asm/Program.cs b/prototypes/supervm-asm/assembler.cs
similarity index 88%
rename from prototypes/supervm-asm/Program.cs
rename to prototypes/supervm-asm/assembler.cs
index 1f94262..6fe8b3f 100644
--- a/prototypes/supervm-asm/Program.cs
+++ b/prototypes/supervm-asm/assembler.cs
@@ -16,15 +16,57 @@ namespace supervm_asm
{
// MnemonicParser.GenerateFromDocumentation(@"D:\felix\projects\DasOS\prototypes\supervm\instructions.md");
- var code = Assembler.Assemble(File.ReadAllText("testcode.asm"));
-
- for (int i = 0; i < code.Length; i++)
+ foreach(var file in args.Where(a => !a.StartsWith("-") && Path.GetExtension(a) == ".asm"))
{
- Console.Write("; {0:X3} ", i);
- Console.Write(Convert.ToString((long)code[i], 2).PadLeft(64, '0'));
- Console.WriteLine();
+ var output = Path.ChangeExtension(file, ".bin");
+ var code = Assembler.Assemble(File.ReadAllText("testcode.asm"));
+
+ Console.WriteLine("{0}:", output);
+ for (int i = 0; i < code.Length; i++)
+ {
+ Console.Write("; {0:X3} ", i);
+ PrintInstruction(code[i]);
+ }
+ using(var fs = File.Open(output, FileMode.Create, FileAccess.Write))
+ {
+ for(int i = 0; i < code.Length; i++)
+ {
+ var bits = BitConverter.GetBytes(code[i]);
+ if(BitConverter.IsLittleEndian)
+ {
+ bits = bits.Reverse().ToArray();
+ }
+ fs.Write(bits, 0, bits.Length);
+ }
+ }
}
}
+
+ static void PrintInstruction(ulong instr)
+ {
+ var str = Convert.ToString((long)instr, 2).PadLeft(64, '0');
+
+ var portions = new []
+ {
+ new { Start = 0, Length = 32, Color = ConsoleColor.Red },
+ new { Start = 32, Length = 2, Color = ConsoleColor.Blue },
+ new { Start = 34, Length = 1, Color = ConsoleColor.Green },
+ new { Start = 35, Length = 16, Color = ConsoleColor.Magenta },
+ new { Start = 51, Length = 8, Color = ConsoleColor.Yellow },
+ new { Start = 59, Length = 1, Color = ConsoleColor.DarkCyan },
+ new { Start = 60, Length = 2, Color = ConsoleColor.Cyan },
+ new { Start = 62, Length = 2, Color = ConsoleColor.DarkBlue },
+ };
+
+ var fg = Console.ForegroundColor;
+ foreach(var portion in portions)
+ {
+ Console.ForegroundColor = portion.Color;
+ Console.Write("{0} ", str.Substring(portion.Start, portion.Length));
+ }
+ Console.ForegroundColor = fg;
+ Console.WriteLine();
+ }
}
public static class Assembler
@@ -123,10 +165,10 @@ namespace supervm_asm
switch (annotation)
{
case "f:yes":
- instruction.ModifyFlags = false;
+ instruction.ModifyFlags = true;
break;
case "f:no":
- instruction.ModifyFlags = true;
+ instruction.ModifyFlags = false;
break;
case "r:discard":
instruction.Output = OutputType.Discard;
diff --git a/prototypes/supervm-asm/supervm-asm.csproj b/prototypes/supervm-asm/supervm-asm.csproj
deleted file mode 100644
index a538903..0000000
--- a/prototypes/supervm-asm/supervm-asm.csproj
+++ /dev/null
@@ -1,65 +0,0 @@
-
-
-
-
- Debug
- AnyCPU
- {7B2CB53A-D2EF-4AEF-B354-FCF28C581280}
- Exe
- Properties
- supervm_asm
- supervm-asm
- v4.5.2
- 512
- true
-
-
- AnyCPU
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- AnyCPU
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
-
-
-
\ No newline at end of file