new public string ToString() { byte[] data = new byte[2]; data[0] = upperByte; data[1] = lowerByte; return(ASM.ByteArrayToString(data)); }
private static void Main(string[] args) { string inputPath = "disassembler_test.rom"; if (args.Length >= 1) { if (File.Exists(args[0]) && Path.GetExtension(args[0]) == ".rom") { inputPath = args[0]; Console.WriteLine(inputPath); } } if (File.Exists(inputPath)) { ASM Disassembler = new ASM(); BinaryReader reader = new BinaryReader(File.Open(inputPath, FileMode.Open)); List<byte> bytesList = new List<byte>(); bool reading = true; while (reading) { try { bytesList.Add(reader.ReadByte()); } catch { reading = false; } } string code = Disassembler.Disassemble(bytesList.ToArray()); File.WriteAllText(Path.GetFileNameWithoutExtension(inputPath) + ".asm", code); } else { if (inputPath != "") { Console.WriteLine("Could not find file:"); Console.WriteLine(inputPath); } else { Console.WriteLine("SG16 Disassembler"); Console.WriteLine("Usage: Disassembler.exe <input file>.rom"); Console.WriteLine("Drag-and-drop is also supported."); } Console.ReadLine(); } }
private static void Main(string[] args) { string inputPath = "assembler_test.asm"; if (args.Length >= 1) { if (File.Exists(args[0]) && Path.GetExtension(args[0]) == ".asm") { inputPath = args[0]; Console.WriteLine(inputPath); } } if (File.Exists(inputPath)) { ASM Assembler = new ASM(); string input = System.IO.File.ReadAllText(inputPath); Console.WriteLine(input); byte[] program = Assembler.Assemble(input); using (BinaryWriter writer = new BinaryWriter(File.Open(Path.GetFileNameWithoutExtension(inputPath) + ".rom", FileMode.Create))) { foreach (byte b in program) { writer.Write(b); } } } else { if (inputPath != "") { Console.WriteLine("Could not find file:"); Console.WriteLine(inputPath); } else { Console.WriteLine("SG16 Assembler"); Console.WriteLine("Usage: Assembler.exe <input file>.asm"); Console.WriteLine("Drag-and-drop is also supported."); } Console.ReadLine(); } }