// This file is part of the Noddybox.Emulation C# suite. // // Noddybox.Emulation is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // Noddybox.Emulation is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with Noddybox.Emulation. If not, see . // // Copyright (c) 2012 Ian Cowburn // using System; namespace Noddybox.Emulation.EightBit.Z80 { public partial class Z80Cpu { /// /// Decode and execute a IX/IY CB-shifted opcode. /// /// The opcode. /// The address to use for indirection. private void DecodeShiftedCB(byte opcode, ushort addr) { byte result = 0; switch(opcode) { case 0x00: // RLC (ix+d) -> B result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x01: // RLC (ix+d) -> C result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x02: // RLC (ix+d) -> D result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x03: // RLC (ix+d) -> E result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x04: // RLC (ix+d) -> H result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x05: // RLC (ix+d) -> L result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x06: // RLC (ix+d) result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x07: // RLC (ix+d) -> A result = memory.Read(addr); RLC(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x08: // RRC (ix+d) -> B result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x09: // RRC (ix+d) -> C result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x0a: // RRC (ix+d) -> D result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x0b: // RRC (ix+d) -> E result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x0c: // RRC (ix+d) -> H result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x0d: // RRC (ix+d) -> L result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x0e: // RRC (ix+d) result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x0f: // RRC (ix+d) -> A result = memory.Read(addr); RRC(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x10: // RL (ix+d) -> B result = memory.Read(addr); RL(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x11: // RL (ix+d) -> C result = memory.Read(addr); RL(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x12: // RL (ix+d) -> D result = memory.Read(addr); RL(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x13: // RL (ix+d) -> E result = memory.Read(addr); RL(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x14: // RL (ix+d) -> H result = memory.Read(addr); RL(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x15: // RL (ix+d) -> L result = memory.Read(addr); RL(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x16: // RL (ix+d) result = memory.Read(addr); RL(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x17: // RL (ix+d) -> A result = memory.Read(addr); RL(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x18: // RR (ix+d) -> B result = memory.Read(addr); RR(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x19: // RR (ix+d) -> C result = memory.Read(addr); RR(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x1a: // RR (ix+d) -> D result = memory.Read(addr); RR(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x1b: // RR (ix+d) -> E result = memory.Read(addr); RR(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x1c: // RR (ix+d) -> H result = memory.Read(addr); RR(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x1d: // RR (ix+d) -> L result = memory.Read(addr); RR(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x1e: // RR (ix+d) result = memory.Read(addr); RR(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x1f: // RR (ix+d) -> A result = memory.Read(addr); RR(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x20: // SLA (ix+d) -> B result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x21: // SLA (ix+d) -> C result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x22: // SLA (ix+d) -> D result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x23: // SLA (ix+d) -> E result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x24: // SLA (ix+d) -> H result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x25: // SLA (ix+d) -> L result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x26: // SLA (ix+d) result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x27: // SLA (ix+d) -> A result = memory.Read(addr); SLA(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x28: // SRA (ix+d) -> B result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x29: // SRA (ix+d) -> C result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x2a: // SRA (ix+d) -> D result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x2b: // SRA (ix+d) -> E result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x2c: // SRA (ix+d) -> H result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x2d: // SRA (ix+d) -> L result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x2e: // SRA (ix+d) result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x2f: // SRA (ix+d) -> A result = memory.Read(addr); SRA(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x30: // SLL (ix+d) -> B result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x31: // SLL (ix+d) -> C result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x32: // SLL (ix+d) -> D result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x33: // SLL (ix+d) -> E result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x34: // SLL (ix+d) -> H result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x35: // SLL (ix+d) -> L result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x36: // SLL (ix+d) result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x37: // SLL (ix+d) -> A result = memory.Read(addr); SLL(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x38: // SRL (ix+d) -> B result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x39: // SRL (ix+d) -> C result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x3a: // SRL (ix+d) -> D result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x3b: // SRL (ix+d) -> E result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x3c: // SRL (ix+d) -> H result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x3d: // SRL (ix+d) -> L result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x3e: // SRL (ix+d) result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); clock.Add(11); break; case 0x3f: // SRL (ix+d) -> A result = memory.Read(addr); SRL(ref result); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x40: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x41: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x42: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x43: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x44: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x45: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x46: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x47: // BIT 0,(ix+d) result = memory.Read(addr); BIT(ref result, 0, addr); clock.Add(8); break; case 0x48: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x49: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x4a: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x4b: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x4c: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x4d: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x4e: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x4f: // BIT 1,(ix+d) result = memory.Read(addr); BIT(ref result, 1, addr); clock.Add(8); break; case 0x50: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x51: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x52: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x53: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x54: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x55: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x56: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x57: // BIT 2,(ix+d) result = memory.Read(addr); BIT(ref result, 2, addr); clock.Add(8); break; case 0x58: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x59: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x5a: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x5b: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x5c: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x5d: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x5e: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x5f: // BIT 3,(ix+d) result = memory.Read(addr); BIT(ref result, 3, addr); clock.Add(8); break; case 0x60: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x61: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x62: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x63: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x64: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x65: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x66: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x67: // BIT 4,(ix+d) result = memory.Read(addr); BIT(ref result, 4, addr); clock.Add(8); break; case 0x68: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x69: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x6a: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x6b: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x6c: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x6d: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x6e: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x6f: // BIT 5,(ix+d) result = memory.Read(addr); BIT(ref result, 5, addr); clock.Add(8); break; case 0x70: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x71: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x72: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x73: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x74: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x75: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x76: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x77: // BIT 6,(ix+d) result = memory.Read(addr); BIT(ref result, 6, addr); clock.Add(8); break; case 0x78: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x79: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x7a: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x7b: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x7c: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x7d: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x7e: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x7f: // BIT 7,(ix+d) result = memory.Read(addr); BIT(ref result, 7, addr); clock.Add(8); break; case 0x80: // RES 0,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x81: // RES 0,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x82: // RES 0,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x83: // RES 0,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x84: // RES 0,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x85: // RES 0,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x86: // RES 0,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); clock.Add(11); break; case 0x87: // RES 0,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 0); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x88: // RES 1,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x89: // RES 1,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x8a: // RES 1,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x8b: // RES 1,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x8c: // RES 1,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x8d: // RES 1,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x8e: // RES 1,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); clock.Add(11); break; case 0x8f: // RES 1,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 1); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x90: // RES 2,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x91: // RES 2,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x92: // RES 2,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x93: // RES 2,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x94: // RES 2,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x95: // RES 2,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x96: // RES 2,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); clock.Add(11); break; case 0x97: // RES 2,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 2); memory.Write(addr, result); A = result; clock.Add(11); break; case 0x98: // RES 3,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0x99: // RES 3,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0x9a: // RES 3,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0x9b: // RES 3,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0x9c: // RES 3,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0x9d: // RES 3,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0x9e: // RES 3,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); clock.Add(11); break; case 0x9f: // RES 3,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 3); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xa0: // RES 4,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xa1: // RES 4,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xa2: // RES 4,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xa3: // RES 4,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xa4: // RES 4,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xa5: // RES 4,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xa6: // RES 4,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); clock.Add(11); break; case 0xa7: // RES 4,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 4); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xa8: // RES 5,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xa9: // RES 5,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xaa: // RES 5,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xab: // RES 5,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xac: // RES 5,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xad: // RES 5,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xae: // RES 5,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); clock.Add(11); break; case 0xaf: // RES 5,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 5); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xb0: // RES 6,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xb1: // RES 6,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xb2: // RES 6,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xb3: // RES 6,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xb4: // RES 6,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xb5: // RES 6,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xb6: // RES 6,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); clock.Add(11); break; case 0xb7: // RES 6,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 6); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xb8: // RES 7,(ix+d) -> B result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xb9: // RES 7,(ix+d) -> C result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xba: // RES 7,(ix+d) -> D result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xbb: // RES 7,(ix+d) -> E result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xbc: // RES 7,(ix+d) -> H result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xbd: // RES 7,(ix+d) -> L result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xbe: // RES 7,(ix+d) result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); clock.Add(11); break; case 0xbf: // RES 7,(ix+d) -> A result = memory.Read(addr); BIT_RES(ref result, 7); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xc0: // SET 0,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xc1: // SET 0,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xc2: // SET 0,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xc3: // SET 0,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xc4: // SET 0,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xc5: // SET 0,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xc6: // SET 0,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); clock.Add(11); break; case 0xc7: // SET 0,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 0); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xc8: // SET 1,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xc9: // SET 1,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xca: // SET 1,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xcb: // SET 1,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xcc: // SET 1,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xcd: // SET 1,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xce: // SET 1,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); clock.Add(11); break; case 0xcf: // SET 1,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 1); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xd0: // SET 2,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xd1: // SET 2,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xd2: // SET 2,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xd3: // SET 2,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xd4: // SET 2,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xd5: // SET 2,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xd6: // SET 2,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); clock.Add(11); break; case 0xd7: // SET 2,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 2); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xd8: // SET 3,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xd9: // SET 3,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xda: // SET 3,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xdb: // SET 3,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xdc: // SET 3,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xdd: // SET 3,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xde: // SET 3,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); clock.Add(11); break; case 0xdf: // SET 3,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 3); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xe0: // SET 4,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xe1: // SET 4,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xe2: // SET 4,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xe3: // SET 4,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xe4: // SET 4,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xe5: // SET 4,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xe6: // SET 4,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); clock.Add(11); break; case 0xe7: // SET 4,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 4); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xe8: // SET 5,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xe9: // SET 5,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xea: // SET 5,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xeb: // SET 5,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xec: // SET 5,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xed: // SET 5,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xee: // SET 5,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); clock.Add(11); break; case 0xef: // SET 5,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 5); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xf0: // SET 6,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xf1: // SET 6,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xf2: // SET 6,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xf3: // SET 6,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xf4: // SET 6,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xf5: // SET 6,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xf6: // SET 6,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); clock.Add(11); break; case 0xf7: // SET 6,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 6); memory.Write(addr, result); A = result; clock.Add(11); break; case 0xf8: // SET 7,(ix+d) -> B result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); BC.high = result; clock.Add(11); break; case 0xf9: // SET 7,(ix+d) -> C result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); BC.low = result; clock.Add(11); break; case 0xfa: // SET 7,(ix+d) -> D result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); DE.high = result; clock.Add(11); break; case 0xfb: // SET 7,(ix+d) -> E result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); DE.low = result; clock.Add(11); break; case 0xfc: // SET 7,(ix+d) -> H result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); HL.high = result; clock.Add(11); break; case 0xfd: // SET 7,(ix+d) -> L result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); HL.low = result; clock.Add(11); break; case 0xfe: // SET 7,(ix+d) result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); clock.Add(11); break; case 0xff: // SET 7,(ix+d) -> A result = memory.Read(addr); BIT_SET(ref result, 7); memory.Write(addr, result); A = result; clock.Add(11); break; } } } }