public void TestEncodings() { var stringAsm = new PseudoAssembler(s => false, s => false); var line = new SourceLine(); var teststring = "\"hello, world\""; var ascbytes = Encoding.ASCII.GetBytes(teststring.TrimOnce('"')); var petbytes = Encoding.ASCII.GetBytes(teststring.TrimOnce('"').ToUpper()); var cbmscreenbytes = petbytes.Select(b => { if (b >= '@' && b <= 'Z') { b -= 0x40; } return(b); }); var atascreenbytes = ascbytes.Select(b => { if (b < 96) { return(Convert.ToByte(b - 32)); } return(b); }); line.Instruction = ".encoding"; line.Operand = "petscii"; stringAsm.AssembleLine(line); line.Instruction = ".string"; line.Operand = teststring; TestInstruction(line, stringAsm, petbytes.Count(), petbytes.Count(), petbytes); line.Instruction = ".byte"; line.Operand = "'└'"; TestInstruction(line, stringAsm, 0x0001, 1, new byte[] { 0xad }); line.Instruction = ".encoding"; line.Operand = "atascreen"; stringAsm.AssembleLine(line); line.Instruction = ".string"; line.Operand = teststring; TestInstruction(line, stringAsm, atascreenbytes.Count(), atascreenbytes.Count(), atascreenbytes.ToArray()); line.Instruction = ".encoding"; line.Operand = "cbmscreen"; stringAsm.AssembleLine(line); line.Instruction = ".string"; line.Operand = teststring.ToUpper(); TestInstruction(line, stringAsm, cbmscreenbytes.Count(), cbmscreenbytes.Count(), cbmscreenbytes.ToArray()); }
public void TestEor() { var pseudoAsm = new PseudoAssembler(Controller, m => false); var line = new SourceLine { Instruction = ".eor", Operand = "$ff" }; LineAssembler.AssembleLine(line); Assert.IsFalse(Controller.Log.HasErrors); line.Instruction = ".byte"; line.Operand = "$00"; TestInstruction(line, pseudoAsm, 0x0001, 0x0001, new byte[] { 0xff }); line.Instruction = ".eor"; line.Operand = "-129"; TestForFailure <OverflowException>(line); line.Operand = "256"; TestForFailure <OverflowException>(line); }
public NUnitTestPseudoAssembler() { Controller = new TestController(); LineAssembler = new PseudoAssembler(Controller, s => false); }
public NUnitTestPseudoAssembler() { LineAssembler = new PseudoAssembler(s => false, s => false); }