#ifndef LOADER_H #define LOADER_H // Version 2004/09/30 // DO NOT MODIFY THIS FILE class Loader { public: void Load (); // load program and initialize PC }; // Test harness by Catalin Patulea . // Please see http://vv.carleton.ca/~cat/code/a2th/. #include "UseGlobals.h" #include #include #define VERIFICATIONS class Verifications { public: static void Add(unsigned int pc, unsigned int line, const Registers& mask, const Registers& value) { _p[pc] = new struct art(_p[pc], line, mask, value); } static void Check() { const struct art *ps = _p[sIASreg.PC - 1]; while (ps) { #undef CHECK #define CHECK(f) do { \ if ((sIASreg.f & ps->mask.f) != (ps->value.f & ps->mask.f)) { \ printf("\nVerification failed: The register " #f " had an unexpected value at\n" \ " PC = 0x%04x (loader.cpp:%u) IR = 0x%04x\n" \ " Expected: " #f " = 0x%04x\n" \ " Actual: " #f " = 0x%04x\n", \ sIASreg.PC - 1, ps->line, sIASreg.IR, ps->value.f, sIASreg.f); \ if (ps->mask.f != 0xFFFF) { \ printf(" Mask: " #f " = 0x%04x\n", ps->mask.f); \ } \ putchar('\n'); \ exit(1); \ } \ } while (0) CHECK(AC); CHECK(PC); CHECK(IR); CHECK(MAR); CHECK(MBR); #undef CHECK ps = ps->next; } } protected: static struct art { struct art *next; unsigned int line; Registers mask; Registers value; art(struct art *next, unsigned int line, const Registers& mask, const Registers& value) : next(next), line(line), mask(mask), value(value) { } } *_p[0x1000]; }; #endif