// 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 Foobar. If not, see . // // Copyright (c) 2012 Ian Cowburn // using System; namespace Noddybox.Emulation.EightBit.Z80 { public partial class Z80Cpu { /// /// Decode and execute an ED-shifted opcode. /// /// The opcode. private void DecodeED(byte opcode) { ushort addr; byte b; switch(opcode) { case 0x40: // IN B,(C) clock.Add(12); BC.high = device.Read(BC.reg); F = Z80Flags.Carry | PSZtable[BC.high] | H35table[BC.high]; break; case 0x41: // OUT (C),B clock.Add(12); device.Write(BC.reg, BC.high); break; case 0x42: // SBC HL,BC clock.Add(15); SBC(ref HL.reg, BC.reg); break; case 0x43: // LD (nnnn),BC clock.Add(20); addr = FetchWord(); memory.Write(addr++, BC.low); memory.Write(addr, BC.high); break; case 0x44: // NEG clock.Add(8); b = A; A = 0; SUB8(b); break; case 0x45: // RETN clock.Add(14); IFF1 = IFF2; PC = POP(); break; case 0x46: // IM 0 clock.Add(8); IM = 0; break; case 0x47: // LD I,A clock.Add(9); I = A; break; case 0x48: // IN C,(C) clock.Add(12); BC.low = device.Read(BC.reg); F = Z80Flags.Carry | PSZtable[BC.low] | H35table[BC.low]; break; case 0x49: // OUT (C),C clock.Add(12); device.Write(BC.reg, BC.low); break; case 0x4a: // ADC HL, BC clock.Add(15); ADC16(ref HL.reg, BC.reg); break; case 0x4b: // LD BC,(nnnn) clock.Add(20); addr = FetchWord(); BC.low = memory.Read(addr++); BC.high = memory.Read(addr); break; case 0x4c: // NEG clock.Add(8); b = A; A = 0; SUB8(b); break; case 0x4d: // RETI clock.Add(14); IFF1 = IFF2; PC = POP(); break; case 0x4e: // IM 0/1 clock.Add(8); IM = 0; break; case 0x4f: // LD R,A clock.Add(9); R = A; break; case 0x50: // IN D,(C) clock.Add(12); DE.high = device.Read(BC.reg); F = Z80Flags.Carry | PSZtable[DE.high] | H35table[DE.high]; break; case 0x51: // OUT (C),D clock.Add(12); device.Write(BC.reg, DE.high); break; default: break; } } } }