inline ModEvent SetVarImp::intersectI(Space& home, I& iterator) { if (assigned()) { BndSetRanges lbi(glb); Iter::Ranges::Diff<BndSetRanges,I> probe(lbi,iterator); if (probe()) return ME_SET_FAILED; return ME_SET_NONE; } if (!iterator()) { if (cardMin() > 0) return ME_SET_FAILED; lub.card(0); SetDelta d(1, 0, lub.min(), lub.max()); lub.excludeAll(home); return notify(home, ME_SET_VAL, d); } int mi=iterator.min(); int ma=iterator.max(); ++iterator; if (iterator()) return intersectI_full(home, mi, ma, iterator); else return intersect(home, mi, ma); }
template<class I> forceinline ModEvent SetVarImp::includeI(Space& home, I& iterator) { if (!iterator()) { return ME_SET_NONE; } if (assigned()) { BndSetRanges lbi(glb); Iter::Ranges::Diff<I,BndSetRanges> probe(iterator,lbi); return probe() ? ME_SET_FAILED : ME_SET_NONE; } int mi=iterator.min(); int ma=iterator.max(); ++iterator; if (iterator()) return includeI_full(home, mi, ma, iterator); else return include(home, mi, ma); }
void execute_one_byte() { unsigned char temp; switch (cur_inst) { case 0x00: // CLRA A = 0; break; case 0x01: // SKMBZ 0 skmbz(0x0); break; case 0x02: // XOR A = (A ^ copram[Br][Bd]) & 0xf; break; case 0x03: // SKMBZ 2 skmbz(0x2); break; case 0x04: // XIS 0 xis(0x0); break; case 0x05: // LD 0 ld(0x0); break; case 0x06: // X 0 x(0x0); break; case 0x07: // XDS 0 xds(0x0); break; case 0x08: // LBI 0,9 lbi(0, 9); break; case 0x09: // LBI 0,10 lbi(0, 10); break; case 0x0a: // LBI 0,11 lbi(0, 11); break; case 0x0b: // LBI 0,12 lbi(0, 12); break; case 0x0c: // LBI 0,13 lbi(0, 13); break; case 0x0d: // LBI 0,14 lbi(0, 14); break; case 0x0e: // LBI 0,15 lbi(0, 15); break; case 0x0f: // LBI 0,0 lbi(0, 0); break; case 0x10: // CASC A = ((~A & 0x0f) + copram[Br][Bd] + C); C = (A & 0xF0)?1:0; A &= 0x0F; if (C) { g_skip = 1; } break; case 0x11: // SKMBZ 1 skmbz(0x1); break; case 0x12: // XABR temp = A; A = Br; Br = temp & 0x3; break; case 0x13: // SKMBZ 3 skmbz(0x3); break; case 0x14: // XIS 1 xis(0x1); break; case 0x15: // LD 1 ld(0x1); break; case 0x16: // X 1 x(0x1); break; case 0x17: // XDS 1 xds(0x1); break; case 0x18: // LBI 1,9 lbi(1, 9); break; case 0x19: // LBI 1,10 lbi(1, 10); break; case 0x1a: // LBI 1,11 lbi(1, 11); break; case 0x1b: // LBI 1,12 lbi(1, 12); break; case 0x1c: // LBI 1,13 lbi(1, 13); break; case 0x1d: // LBI 1,14 lbi(1, 14); break; case 0x1e: // LBI 1,15 lbi(1, 15); break; case 0x1f: // LBI 1,0 lbi(1, 0); break; case 0x20: // SKC if (C) { g_skip = 1; } break; case 0x21: // SKE if (A == copram[Br][Bd]) { g_skip = 1; } break; case 0x22: // SC C = 1; break; case 0x24: // XIS 2 xis(0x2); break; case 0x25: // LD 2 ld(0x2); break; case 0x26: // X 2 x(0x2); break; case 0x27: // XDS 2 xds(0x2); break; case 0x28: // LBI 2,9 lbi(2, 9); break; case 0x29: // LBI 2,10 lbi(2, 10); break; case 0x2a: // LBI 2,11 lbi(2, 11); break; case 0x2b: // LBI 2,12 lbi(2, 12); break; case 0x2c: // LBI 2,13 lbi(2, 13); break; case 0x2d: // LBI 2,14 lbi(2, 14); break; case 0x2e: // LBI 2,15 lbi(2, 15); break; case 0x2f: // LBI 2,0 lbi(2, 0); break; case 0x30: // ASC A = (A + copram[Br][Bd] + C); C = (A & 0xF0)?1:0; A = A & 0x0F; if (C) { g_skip = 1; } break; case 0x31: // ADD A = (A + copram[Br][Bd]) & 0x0F; break; case 0x32: // RC C = 0; break; case 0x34: // XIS 3 xis(0x3); break; case 0x35: // LD 3 ld(0x3); break; case 0x36: // X 3 x(0x3); break; case 0x37: // XDS 3 xds(0x3); break; case 0x38: // LBI 3,9 lbi(3, 9); break; case 0x39: // LBI 3,10 lbi(3, 10); break; case 0x3a: // LBI 3,11 lbi(3, 11); break; case 0x3b: // LBI 3,12 lbi(3, 12); break; case 0x3c: // LBI 3,13 lbi(3, 13); break; case 0x3d: // LBI 3,14 lbi(3, 14); break; case 0x3e: // LBI 3,15 lbi(3, 15); break; case 0x3f: // LBI 3,0 lbi(3, 0); break; case 0x40: // COMP A = (~A) & 0xf; break; case 0x41: // SKT if (COUNT_CARRY) { g_skip = 1; COUNT_CARRY = 0; } break; case 0x42: // RMB 2 rmb(2); break; case 0x43: // RMB 3 rmb(3); break; case 0x44: // NOP break; case 0x45: // RMB 1 rmb(1); break; case 0x46: // SMB 2 smb(2); break; case 0x47: // SMB 1 smb(1); break; case 0x48: // RET pop_stack(); break; case 0x49: // RETSK pop_stack(); g_skip = 1; break; case 0x4a: // ADT A = (A + 10) & 0xf; break; case 0x4b: // SMB 3 smb(3); break; case 0x4c: // RMB 0 rmb(0); break; case 0x4d: // SMB 0 smb(0); break; case 0x4e: // CBA A = Bd; break; case 0x4f: // XAS temp = A; A = SIO; SIO = temp; break; case 0x50: // CAB Bd = A; break; case 0x51: // AISC case 0x52: case 0x53: case 0x54: case 0x55: case 0x56: case 0x57: case 0x58: case 0x59: case 0x5a: case 0x5b: case 0x5c: case 0x5d: case 0x5e: case 0x5f: A = A + (cur_inst & 0xf); if (A & 0xf0) { g_skip = 1; } A &= 0xf; break; case 0x70: // STII case 0x71: case 0x72: case 0x73: case 0x74: case 0x75: case 0x76: case 0x77: case 0x78: case 0x79: case 0x7a: case 0x7b: case 0x7c: case 0x7d: case 0x7e: case 0x7f: copram[Br][Bd] = cur_inst & 0x0f; Bd++; if (Bd > 0xf) { Bd = 0; } break; case 0xbf: // LQID Q = coprom[(PC & 0x300) | ((A << 4) & 0xf0) | (copram[Br][Bd] & 0xf)]; SC = SB; break; case 0xff: // JID PC = coprom[(PC & 0x300) | ((A << 4) & 0xf0) | (copram[Br][Bd] & 0xf)]; break; default: if (cur_inst >= 0x80 && cur_inst < 0xbf) { if (PC >= 0x080 && PC < 0x100) // JP within SRP { PC = (PC & 0x380) | (cur_inst & 0x7f); } else // JSRP { push_stack(); PC = 0x080 | (cur_inst & 0x3f); } } else if (cur_inst >= 0xc0 && cur_inst < 0xff) { PC = (PC & 0x3c0) | (cur_inst & 0x3f); } else { // MATT : commented this stuff out for reasons explained at top of file // cout.setf(ios::hex); // cout.setf(ios::right, ios::adjustfield); // cout << "Invalid Instruction: " << setw(2) << setfill( '0' ) << static_cast<int>(cur_inst) << " at PC: " << setw(3) << setfill( '0' ) << static_cast<int>(inst_pc) << endl; break; } } }