public void ramlabels()
        {
            //NB ramstart will only take effect on a reset()
             //and will be reset by each call to parse
             //so to test ramlabels you need to feed in all the data in one go
             //as if it is read from a file
             z80assembler z = new z80assembler();
             z.loadcommands();
             z.ramstart = 0x4000;
             z.reset();

             string lines = " .DATA \ntest: .db \ntest2: .db \n .CODE \n .ORG 0000\n ld hl,test \n ld hl,(test2)";

             z.parse(lines, "");
             z.link();
             z.finallink();

             Assert.AreEqual(0x21,z.bytes[0]);
             Assert.AreEqual(0x00,z.bytes[1]);
             Assert.AreEqual(0x40,z.bytes[2]);

             Assert.AreEqual(0x2A, z.bytes[3]);
             Assert.AreEqual(0x01, z.bytes[4]);
             Assert.AreEqual(0x40, z.bytes[5]);
        }
        public void labelmath2()
        {
            z80assembler z = new z80assembler();
             z.loadcommands();
             z.ramstart = 0x4000;
             z.reset();

             var wasCalled = false;
             z.DoErr += delegate(string file, int line, string description) { wasCalled = true; };

             string lines = " .global test\n nop\n nop\ntest: .db 10,20,30";

             z.parse(lines, "");
             Assert.IsFalse(wasCalled);

             z.link();
             Assert.IsFalse(wasCalled);

             lines = " .extern test\n nop\n nop\n ld a,(test+1)";

             z.partialreset();
             z.parse(lines, "");
             Assert.IsFalse(wasCalled);

             z.link();
             Assert.IsFalse(wasCalled);

             z.finallink();
             Assert.IsFalse(wasCalled);
        }
        public void labelmath3()
        {
            z80assembler z = new z80assembler();
             z.loadcommands();
             z.ramstart = 0x4000;
             z.reset();

             var wasCalled = false;
             z.DoErr += delegate(string file, int line, string description) { wasCalled = true; };

             string lines = "CHLEVS:         .ds     5\n ld DE,CHLEVS+1";
             z.parse(lines, "");
             Assert.IsFalse(wasCalled);

             z.link();
             Assert.IsFalse(wasCalled);

             z.finallink();
             Assert.IsFalse(wasCalled);
        }
        public void globals2()
        {
            z80assembler z = new z80assembler();
             z.loadcommands();
             z.ramstart = 0x4000;
             z.reset();

             var wasCalled = false;
             z.DoErr += delegate(string file, int line, string description) { wasCalled = true; };

             string lines = " nop\n nop\n nop\ntest: ld hl,test \n nop\n";
             z.parse(lines, "");
             z.link();
             z.partialreset();

             Assert.IsFalse(wasCalled);

             lines = " .extern test \n nop\n nop\n nop\n ld hl,(test) \n nop\n";
             z.parse(lines, "");

             z.link();

             Assert.IsFalse(wasCalled);

             z.finallink();

             Assert.IsTrue(wasCalled);
        }