public static void LoadAAT(String filename) { assembler = new Assembler(); lineExpectations = new Dictionary<int, GBTestExpections>(); lineEvents = new Dictionary<int, GBTestEvent>(); System.IO.StreamReader file = new System.IO.StreamReader(filename); int lno = 0; while (!file.EndOfStream) { String line = file.ReadLine(); String [] parts = line.Split(';'); if ((parts.Length == 2) && parts[1].StartsWith("EXPECT:")) { lineExpectations[lno] = new GBTestExpections(parts[1].Substring(8)); } if ((parts.Length == 2) && parts[1].StartsWith("EVENTS:")) { lineEvents[lno] = new GBTestEvent(parts[1].Substring(8)); } ++lno; } file = new System.IO.StreamReader(filename); rom = assembler.AssembleString(file.ReadToEnd()); sys = new GBLib(); sys.SetRom(rom); sys.Start(); }
public void Init() { window = new AssemblerProgress(); assembler = new Assembler(); assembler.MessagePrinted += ConsoleOutput; assembler.ProgressUpdated += UpdateProgress; assembler.AssemblerError += ConsoleOutput; window.Show(); }
public void AssemblerSections() { Assembler assembler = new Assembler(); assembler.MessagePrinted += PrintTrace; //Test a section List<Byte> rom = assembler.AssembleString("SECTION \"ENTRY\",HOME[$100]\nDB 0x01"); Assert.AreEqual("0x01", assembler.GetByteString(1)); for(int i = 0; i < 0x100; ++i) { Assert.AreEqual(0, rom[i]); } Assert.AreEqual(1, rom[0x100]); }
public void AssemblerSectionsSequence() { Assembler assembler = new Assembler(); assembler.MessagePrinted += PrintTrace; List<Byte> rom = assembler.AssembleString("SECTION \"ENTRY\",HOME[$100]\nDB 0x01\nSECTION \"SECOND\",HOME[$200]\nDB 0x02"); Assert.AreEqual("0x01", assembler.GetByteString(1)); Assert.AreEqual("0x02", assembler.GetByteString(3)); Assert.AreEqual(1, rom[0x100]); Assert.AreEqual(2, rom[0x200]); }
public void AssemblerRept() { Assembler assembler = new Assembler(); assembler.MessagePrinted += PrintTrace; //REPT blocks assembler.AssembleString("rept 0x05\nDB 0x01\nendr\nNOP"); for (int n = 0; n < 5; ++n) { Assert.AreEqual("0x01", assembler.GetByteString(n)); } Assert.AreEqual("0x00", assembler.GetByteString(5)); }
public void AssemblerNumberFormats() { Assembler assembler = new Assembler(); assembler.AssembleString("LD C,0x10\nLD C,10h\nLD C,$10\nLD C,10"); Assert.AreEqual("0x0E 0x10", assembler.GetByteString(0)); Assert.AreEqual("0x0E 0x10", assembler.GetByteString(1)); Assert.AreEqual("0x0E 0x10", assembler.GetByteString(2)); Assert.AreEqual("0x0E 0x0A", assembler.GetByteString(3)); assembler.AssembleString("JP 0x1\nJP 0x10\nJP 0x100\nJP 0x1000"); Assert.AreEqual("0xC3 0x01 0x00", assembler.GetByteString(0)); Assert.AreEqual("0xC3 0x10 0x00", assembler.GetByteString(1)); Assert.AreEqual("0xC3 0x00 0x01", assembler.GetByteString(2)); Assert.AreEqual("0xC3 0x00 0x10", assembler.GetByteString(3)); assembler.AssembleString("JR -1\nJR -0x1\nJR -$2A\nJR-127"); Assert.AreEqual("0x18 0xFF", assembler.GetByteString(0)); Assert.AreEqual("0x18 0xFF", assembler.GetByteString(1)); Assert.AreEqual("0x18 0xD6", assembler.GetByteString(2)); Assert.AreEqual("0x18 0x81", assembler.GetByteString(3)); }
public void AssemblerLabels() { Assembler assembler = new Assembler(); assembler.MessagePrinted += PrintTrace; //Absolute labels assembler.AssembleString("ZERO: JP ZERO"); Assert.AreEqual("0xC3 0x00 0x00", assembler.GetByteString(0)); assembler.AssembleString("JP NINE\nNOP\nNOP\nNOP\nNOP\nNOP\nNOP\nNINE:NOP"); Assert.AreEqual("0xC3 0x09 0x00", assembler.GetByteString(0)); for(int i = 1; i < 8; ++i) { Assert.AreEqual("0x00", assembler.GetByteString(i)); } //Relative labels assembler.AssembleString("JR X\nNOP\nNOP\nNOP\nNOP\nNOP\nNOP\nX: NOP"); Assert.AreEqual("0x18 0x08", assembler.GetByteString(0)); assembler.AssembleString("ZERO: NOP\nNOP\nNOP\nNOP\nNOP\nNOP\nNOP\nJR ZERO"); for (int i = 0; i < 7; ++i) { Assert.AreEqual("0x00", assembler.GetByteString(i)); } Assert.AreEqual("0x18 0xF9", assembler.GetByteString(7)); }
public void AssemblerData() { Assembler assembler = new Assembler(); assembler.MessagePrinted += PrintTrace; //DB commands assembler.AssembleString("DB 0x44"); Assert.AreEqual("0x44", assembler.GetByteString(0)); assembler.AssembleString("DB \"TEST\""); Assert.AreEqual("0x54 0x45 0x53 0x54", assembler.GetByteString(0)); assembler.AssembleString("DB 0x44,\"TEST\""); Assert.AreEqual("0x44 0x54 0x45 0x53 0x54", assembler.GetByteString(0)); }
public void AssemblerAllOpcodes() { Assembler assembler = new Assembler(); //assembler.MessagePrinted += PrintTrace; foreach(String input in all_ops.Keys) { System.Diagnostics.Trace.WriteLine(input); assembler.AssembleString(input); String result = assembler.GetByteString(0); Assert.AreEqual(all_ops[input], result); } }