public void NOP()
{
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLCA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRCA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// Parity unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void DJNZ_e(byte[] parameters)
{
unchecked
{
_state[Register.B]--;
if (_state[Register.B] > 0)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.Q = 0;
_state.SetMCycles(5, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(5, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_e(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 5);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DAA()
{
unchecked
{
var adjust = 0;
if (_state[Flag.HalfCarry] || (_state[Register.A] & 0x0F) > 0x09)
{
adjust++;
}
if (_state[Flag.Carry] || _state[Register.A] > 0x99)
{
adjust += 2;
_state[Flag.Carry] = true;
}
if (_state[Flag.AddSubtract] && ! _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = false;
}
else
{
if (_state[Flag.AddSubtract] && _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) < 0x06;
}
else
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) >= 0x0A;
}
}
switch (adjust)
{
case 1:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xFA : 0x06);
break;
case 2:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xA0 : 0x60);
break;
case 3:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0x9A : 0x66);
break;
}
// Flags
// Carry adjusted by operation
// AddSubtract adjusted by operation
_state[Flag.ParityOverflow] = _state[Register.A].IsEvenParity();
_state[Flag.X1] = (_state[Register.A] & 0x08) > 0;
// HalfCary adjusted by operation
_state[Flag.X2] = (_state[Register.A] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.A] == 0;
_state[Flag.Sign] = (_state[Register.A] & 0x80) > 0;
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CPL()
{
unchecked
{
var result = _state[Register.A] ^ 0xFF;
_state[Register.A] = (byte) result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_R(byte[] parameters, Register source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) ((((parameters[1] << 8) | parameters[0] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_aRR(RegisterPair registers)
{
unchecked
{
var address = _state[registers];
var value = _interface.ReadFromMemory(address);
var result = (byte) (value + 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3);
}
public void DEC_aRR(RegisterPair registers)
{
unchecked
{
var address = _state[registers];
var value = _interface.ReadFromMemory(address);
var result = (byte) (value - 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3);
}
public void LD_aRR_n(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, parameters[0]);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void SCF()
{
unchecked
{
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = true;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_ann(Register target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CCF()
{
unchecked
{
var value = _state[Flag.Carry];
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = ! value;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = value;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void HALT()
{
_state.Halted = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var result = _state[target] & right;
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 3);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_nn(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void ADD_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void RET()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void CALL_nn(byte[] parameters)
{
unchecked
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
}
_state.SetMCycles(4, 3, 4, 3, 3);
}
public void ADC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void OUT_an_R(byte[] parameters, Register register)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
_interface.WriteToPort(address, _state[register]);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void SUB_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[register] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void EXX()
{
unchecked
{
(_state[RegisterPair.BC], _state[RegisterPair.BC_]) = (_state[RegisterPair.BC_], _state[RegisterPair.BC]);
(_state[RegisterPair.DE], _state[RegisterPair.DE_]) = (_state[RegisterPair.DE_], _state[RegisterPair.DE]);
(_state[RegisterPair.HL], _state[RegisterPair.HL_]) = (_state[RegisterPair.HL_], _state[RegisterPair.HL]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void IN_R_n(Register register, byte[] parameters)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
var data = _interface.ReadFromPort(address);
_state[register] = data;
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void SBC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_aRR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
var value = _state[right];
var data = (ushort) (_interface.ReadFromMemory((ushort) (_state[left] + 1)) << 8);
data |= _interface.ReadFromMemory(_state[left]);
_state[right] = data;
_interface.WriteToMemory((ushort) (_state[left] + 1), (byte) ((value & 0xFF00) >> 8));
_interface.WriteToMemory(_state[left], (byte) (value & 0x00FF));
_state.MemPtr = _state[right];
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4, 3, 5);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void AND_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = _state[register] & parameters[0];
_state[register] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void JP_aRR(RegisterPair registers)
{
unchecked
{
_state.ProgramCounter = _state[registers];
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void XOR_R_n(Register target, byte[] parameters)
{
unchecked
{
var result = (byte) (parameters[0] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void DI()
{
_state.InterruptFlipFlop1 = false;
_state.InterruptFlipFlop2 = false;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void OR_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = (byte) (_state[register] | parameters[0]);
_state[register] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void LD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
_state[target] = _state[source];
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EI()
{
_state.InterruptFlipFlop1 = true;
_state.InterruptFlipFlop2 = true;
_state.IgnoreNextInterrupt = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CP_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RLC_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RLC_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RRC_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RRC_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RL_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLA_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SLA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRA_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SRA_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SLL_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SLL_R(Register register)
{
unchecked
{
var data = _state[register];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_state[register] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void SRL_aRR(RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SRL_R(Register register)
{
unchecked
{
var data = _state[register];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_state[register] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = bit == 0x80 && result != 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data & ~bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void SET_b_aRR(byte bit, RegisterPair source)
{
unchecked
{
var address = _state[source];
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4, 3);
}
public void SET_b_R(byte bit, Register source)
{
unchecked
{
var data = _state[source];
var result = (byte) (data | bit);
_state[source] = result;
_state.Q = 0;
}
_state.SetMCycles(4, 4);
}
public void NOP()
{
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLCA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRCA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// Parity unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void DJNZ_e(byte[] parameters)
{
unchecked
{
_state[Register.B]--;
if (_state[Register.B] > 0)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.Q = 0;
_state.SetMCycles(5, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(5, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_e(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 5);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DAA()
{
unchecked
{
var adjust = 0;
if (_state[Flag.HalfCarry] || (_state[Register.A] & 0x0F) > 0x09)
{
adjust++;
}
if (_state[Flag.Carry] || _state[Register.A] > 0x99)
{
adjust += 2;
_state[Flag.Carry] = true;
}
if (_state[Flag.AddSubtract] && ! _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = false;
}
else
{
if (_state[Flag.AddSubtract] && _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) < 0x06;
}
else
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) >= 0x0A;
}
}
switch (adjust)
{
case 1:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xFA : 0x06);
break;
case 2:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xA0 : 0x60);
break;
case 3:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0x9A : 0x66);
break;
}
// Flags
// Carry adjusted by operation
// AddSubtract adjusted by operation
_state[Flag.ParityOverflow] = _state[Register.A].IsEvenParity();
_state[Flag.X1] = (_state[Register.A] & 0x08) > 0;
// HalfCary adjusted by operation
_state[Flag.X2] = (_state[Register.A] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.A] == 0;
_state[Flag.Sign] = (_state[Register.A] & 0x80) > 0;
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CPL()
{
unchecked
{
var result = _state[Register.A] ^ 0xFF;
_state[Register.A] = (byte) result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_R(byte[] parameters, Register source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) ((((parameters[1] << 8) | parameters[0] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_aRRd(RegisterPair registers, byte[] parameters)
{
unchecked
{
var address = _state[registers];
address = (ushort) (address + (sbyte) parameters[0]);
var value = _interface.ReadFromMemory(address);
var result = (byte) (value + 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void DEC_aRRd(RegisterPair registers, byte[] parameters)
{
unchecked
{
var address = _state[registers];
address = (ushort) (address + (sbyte) parameters[0]);
var value = _interface.ReadFromMemory(address);
var result = (byte) (value - 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void LD_aRRd_n(RegisterPair register, byte[] parameters)
{
unchecked
{
var address = _state[register];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, parameters[1]);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SCF()
{
unchecked
{
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = true;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_ann(Register target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CCF()
{
unchecked
{
var value = _state[Flag.Carry];
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = ! value;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = value;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void HALT()
{
_state.Halted = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = _state[target] & right;
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_nn(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void ADD_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void RET()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void CALL_nn(byte[] parameters)
{
unchecked
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
}
_state.SetMCycles(4, 3, 4, 3, 3);
}
public void ADC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void OUT_an_R(byte[] parameters, Register register)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
_interface.WriteToPort(address, _state[register]);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void SUB_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[register] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void EXX()
{
unchecked
{
(_state[RegisterPair.BC], _state[RegisterPair.BC_]) = (_state[RegisterPair.BC_], _state[RegisterPair.BC]);
(_state[RegisterPair.DE], _state[RegisterPair.DE_]) = (_state[RegisterPair.DE_], _state[RegisterPair.DE]);
(_state[RegisterPair.HL], _state[RegisterPair.HL_]) = (_state[RegisterPair.HL_], _state[RegisterPair.HL]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void IN_R_n(Register register, byte[] parameters)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
var data = _interface.ReadFromPort(address);
_state[register] = data;
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void SBC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_aRR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
var value = _state[right];
var data = (ushort) (_interface.ReadFromMemory((ushort) (_state[left] + 1)) << 8);
data |= _interface.ReadFromMemory(_state[left]);
_state[right] = data;
_interface.WriteToMemory((ushort) (_state[left] + 1), (byte) ((value & 0xFF00) >> 8));
_interface.WriteToMemory(_state[left], (byte) (value & 0x00FF));
_state.MemPtr = _state[right];
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4, 3, 5);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void AND_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = _state[register] & parameters[0];
_state[register] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void JP_aRR(RegisterPair registers)
{
unchecked
{
_state.ProgramCounter = _state[registers];
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void XOR_R_n(Register target, byte[] parameters)
{
unchecked
{
var result = (byte) (parameters[0] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void DI()
{
_state.InterruptFlipFlop1 = false;
_state.InterruptFlipFlop2 = false;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void OR_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = (byte) (_state[register] | parameters[0]);
_state[register] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void LD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
_state[target] = _state[source];
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EI()
{
_state.InterruptFlipFlop1 = true;
_state.InterruptFlipFlop2 = true;
_state.IgnoreNextInterrupt = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CP_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void NOP()
{
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLCA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRCA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// Parity unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void DJNZ_e(byte[] parameters)
{
unchecked
{
_state[Register.B]--;
if (_state[Register.B] > 0)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.Q = 0;
_state.SetMCycles(5, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(5, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_e(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 5);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DAA()
{
unchecked
{
var adjust = 0;
if (_state[Flag.HalfCarry] || (_state[Register.A] & 0x0F) > 0x09)
{
adjust++;
}
if (_state[Flag.Carry] || _state[Register.A] > 0x99)
{
adjust += 2;
_state[Flag.Carry] = true;
}
if (_state[Flag.AddSubtract] && ! _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = false;
}
else
{
if (_state[Flag.AddSubtract] && _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) < 0x06;
}
else
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) >= 0x0A;
}
}
switch (adjust)
{
case 1:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xFA : 0x06);
break;
case 2:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xA0 : 0x60);
break;
case 3:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0x9A : 0x66);
break;
}
// Flags
// Carry adjusted by operation
// AddSubtract adjusted by operation
_state[Flag.ParityOverflow] = _state[Register.A].IsEvenParity();
_state[Flag.X1] = (_state[Register.A] & 0x08) > 0;
// HalfCary adjusted by operation
_state[Flag.X2] = (_state[Register.A] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.A] == 0;
_state[Flag.Sign] = (_state[Register.A] & 0x80) > 0;
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CPL()
{
unchecked
{
var result = _state[Register.A] ^ 0xFF;
_state[Register.A] = (byte) result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_R(byte[] parameters, Register source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) ((((parameters[1] << 8) | parameters[0] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_aRR(RegisterPair registers)
{
unchecked
{
var address = _state[registers];
var value = _interface.ReadFromMemory(address);
var result = (byte) (value + 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3);
}
public void DEC_aRR(RegisterPair registers)
{
unchecked
{
var address = _state[registers];
var value = _interface.ReadFromMemory(address);
var result = (byte) (value - 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3);
}
public void LD_aRR_n(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, parameters[0]);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void SCF()
{
unchecked
{
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = true;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_ann(Register target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CCF()
{
unchecked
{
var value = _state[Flag.Carry];
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = ! value;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = value;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void SBC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ (right + carry)) & 0x8000) != 0 && (((right + carry) ^ (ushort) result) & 0x8000) == 0;
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = ((left & 0x0FFF) - (right & 0x0FFF) - carry & 0x1000) != 0;
_state[Flag.X2] = (result & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void ADC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETI()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void SBC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ (right + carry)) & 0x8000) != 0 && (((right + carry) ^ (ushort) result) & 0x8000) == 0;
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = ((left & 0x0FFF) - (right & 0x0FFF) - carry & 0x1000) != 0;
_state[Flag.X2] = (result & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void ADC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void SBC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ (right + carry)) & 0x8000) != 0 && (((right + carry) ^ (ushort) result) & 0x8000) == 0;
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = ((left & 0x0FFF) - (right & 0x0FFF) - carry & 0x1000) != 0;
_state[Flag.X2] = (result & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void RRD()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
var al = (byte) (_state[Register.A] & 0x0F);
var ah = (byte) (_state[Register.A] & 0xF0);
var vl = (byte) (value & 0x0F);
var vh = (byte) (value & 0xF0);
_state[Register.A] = (byte) (ah | vl);
value = (byte) ((al << 4) | (vh >> 4));
_interface.WriteToMemory(_state[RegisterPair.HL], value);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state[Register.A].IsEvenParity();
_state[Flag.X1] = (_state[Register.A] & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (_state[Register.A] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.A] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.A] < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.HL] + 1);
}
_state.SetMCycles(4, 4, 3, 4, 3);
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void ADC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void RLD()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
var al = (byte) (_state[Register.A] & 0x0F);
var ah = (byte) (_state[Register.A] & 0xF0);
var vl = (byte) (value & 0x0F);
var vh = (byte) (value & 0xF0);
_state[Register.A] = (byte) (ah | vh >> 4);
value = (byte) ((vl << 4) | al);
_interface.WriteToMemory(_state[RegisterPair.HL], value);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state[Register.A].IsEvenParity();
_state[Flag.X1] = (_state[Register.A] & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (_state[Register.A] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.A] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.A] < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.HL] + 1);
}
_state.SetMCycles(4, 4, 3, 4, 3);
}
public void IN_C()
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_b(byte data)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], data);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void SBC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ (right + carry)) & 0x8000) != 0 && (((right + carry) ^ (ushort) result) & 0x8000) == 0;
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = ((left & 0x0FFF) - (right & 0x0FFF) - carry & 0x1000) != 0;
_state[Flag.X2] = (result & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void HALT()
{
_state.Halted = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void NOP()
{
_state.Q = 0;
_state.SetMCycles(4);
}
public void IN_R_C(Register register)
{
unchecked
{
var data = _interface.ReadFromPort(_state[RegisterPair.BC]);
_state[register] = data;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = data.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = data == 0;
_state[Flag.Sign] = (sbyte) data < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
}
_state.SetMCycles(4, 4, 4);
}
public void OUT_C_R(Register register)
{
unchecked
{
_interface.WriteToPort(_state[RegisterPair.BC], _state[register]);
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 4, 4);
}
public void ADC_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = (left & 0x8000) == ((right + carry) & 0x8000) && (left & 0x8000) != (result & 0x8000);
_state[Flag.X1] = ((result >> 11) & 1) > 0;
_state[Flag.HalfCarry] = (((left & 0x0FFF) + (right & 0x0FFF) + carry) & 0x1000) > 0;
_state[Flag.X2] = ((result >> 13) & 1) > 0;
_state[Flag.Zero] = (result & 0xFFFF) == 0;
_state[Flag.Sign] = (short) result < 0;
_state.MemPtr = (ushort) (_state[target] + 1);
}
_state.SetMCycles(4, 4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void NEG_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) ~value;
result++;
_state[Register.A] = result;
_state[Flag.Carry] = value != 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + (result & 0x0F) > 0x0F;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (result & 0x80) > 0;
}
_state.SetMCycles(4, 4);
}
public void RETN()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.InterruptFlipFlop1 = _state.InterruptFlipFlop2;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 3);
}
public void IM(InterruptMode mode)
{
_state.InterruptMode = mode;
_state.Q = 0;
_state.SetMCycles(4, 4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LDI()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
_interface.WriteToMemory(_state[RegisterPair.DE], value);
_state[RegisterPair.HL]++;
_state[RegisterPair.DE]++;
_state[RegisterPair.BC]--;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = ((value + _state[Register.A]) & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = ((value + _state[Register.A]) & 0x02) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4, 4, 3, 5);
}
public void CPI()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
var difference = _state[Register.A] - value;
_state[RegisterPair.HL]++;
_state[RegisterPair.BC]--;
var x = difference - (_state[Flag.HalfCarry] ? 1 : 0);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = (0x10 & ((_state[Register.A] & 0x0F) - (value & 0x0F))) > 0;
_state[Flag.X2] = (x & 0x02) > 0;
_state[Flag.Zero] = difference == 0;
_state[Flag.Sign] = ((byte) difference & 0x80) > 0;
_state.MemPtr++;
}
_state.SetMCycles(4, 4, 3, 5);
}
public void INI()
{
unchecked
{
var port = _state[RegisterPair.BC];
var data = _interface.ReadFromPort(port);
_interface.WriteToMemory(_state[RegisterPair.HL], data);
_state[RegisterPair.HL]++;
_state[Register.B]--;
_state[Flag.Carry] = data + ((_state[Register.C] + 1) & 0xFF) > 0xFF;
_state[Flag.AddSubtract] = (data & 0x80) > 0;
_state[Flag.ParityOverflow] = ((ushort) (((data + ((_state[Register.C] + 1) & 0xFF)) & 0x07) ^ _state[Register.B])).IsEvenParity();
_state[Flag.X1] = (_state[Register.B] & 0x08) > 0;
_state[Flag.HalfCarry] = data + ((_state[Register.C] + 1) & 0xFF) > 0xFF;
_state[Flag.X2] = (_state[Register.B] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (port + 1);
}
_state.SetMCycles(4, 5, 3, 4);
}
public void OUTI()
{
unchecked
{
var address = _state[RegisterPair.HL];
var data = _interface.ReadFromMemory(address);
_state[Register.B]--;
var port = _state[RegisterPair.BC];
_interface.WriteToPort(port, data);
_state[RegisterPair.HL]++;
_state[Flag.Carry] = data + _state[Register.L] > 0xFF;
_state[Flag.AddSubtract] = (data & 0x80) > 0;
_state[Flag.ParityOverflow] = ((byte) ((data + _state[Register.L] & 7) ^ _state[Register.B])).IsEvenParity();
_state[Flag.X1] = (_state[Register.B] & 0x08) > 0;
_state[Flag.HalfCarry] = data + _state[Register.L] > 0xFF;
_state[Flag.X2] = (_state[Register.B] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
_state.Q = 1;
}
_state.SetMCycles(4, 5, 3, 4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var result = _state[target] & right;
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LDD()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
_interface.WriteToMemory(_state[RegisterPair.DE], value);
_state[RegisterPair.HL]--;
_state[RegisterPair.DE]--;
_state[RegisterPair.BC]--;
value += _state[Register.A];
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0; // TODO: 0x02?
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4, 4, 3, 5);
}
public void CPD()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
var difference = (sbyte) (_state[Register.A] - value);
_state[RegisterPair.HL]--;
_state[RegisterPair.BC]--;
var x = difference - (_state[Flag.Carry] ? 1 : 0);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = (((_state[Register.A] & 0x0F) - (value & 0x0F)) & 0x10) > 0;
_state[Flag.X2] = (x & 0x02) > 0;
_state[Flag.Zero] = difference == 0;
_state[Flag.Sign] = (byte) difference > 0x7F;
_state.MemPtr++;
}
_state.SetMCycles(4, 4, 3, 5);
}
public void IND()
{
unchecked
{
var port = _state[RegisterPair.BC];
var data = _interface.ReadFromPort(port);
_interface.WriteToMemory(_state[RegisterPair.HL], data);
_state[RegisterPair.HL]--;
_state[Register.B]--;
var flagTemp1 = data + ((_state[Register.C] - 1) & 255);
var flagTemp2 = (ushort) ((flagTemp1 & 7) ^ _state[Register.B]);
_state[Flag.Carry] = flagTemp1 > 0xFF;
_state[Flag.AddSubtract] = (data & 0x80) > 0;
_state[Flag.ParityOverflow] = flagTemp2.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = flagTemp1 > 0xFF;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (port + 1);
}
_state.SetMCycles(4, 5, 3, 4);
}
public void OUTD()
{
unchecked
{
var address = _state[RegisterPair.HL];
var data = _interface.ReadFromMemory(address);
_state[RegisterPair.HL]--;
_state[Register.B]--;
_interface.WriteToPort(_state[RegisterPair.BC], data);
_state[Flag.Carry] = data + _state[Register.L] > 255;
_state[Flag.AddSubtract] = (data & 0b1000_0000) > 0;
_state[Flag.ParityOverflow] = ((byte) (((data + _state[Register.L]) & 0x07) ^ _state[Register.B])).IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = data + _state[Register.L] > 255;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] - 1);
}
_state.SetMCycles(4, 5, 3, 4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LDIR()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
_interface.WriteToMemory(_state[RegisterPair.DE], value);
_state[RegisterPair.HL]++;
_state[RegisterPair.DE]++;
_state[RegisterPair.BC]--;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = ((value + _state[Register.A]) & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = ((value + _state[Register.A]) & 0x02) > 0;
// Zero unaffected
// Sign unaffected
if (_state[RegisterPair.BC] != 1)
{
_state.MemPtr = (ushort) (_state.ProgramCounter + 1);
}
if (_state[RegisterPair.BC] != 0)
{
_state.ProgramCounter -= 2;
//_state[Flag.X1] = (_state.ProgramCounter & 0x0800) > 0;
//_state[Flag.X2] = (_state.ProgramCounter & 0x2000) > 0;
_state.SetMCycles(4, 4, 3, 5, 5);
return;
}
}
_state.SetMCycles(4, 4, 3, 5);
}
public void CPIR()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
var difference = _state[Register.A] - value;
_state[RegisterPair.HL]++;
_state[RegisterPair.BC]--;
var x = difference - (_state[Flag.HalfCarry] ? 1 : 0);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = (0x10 & ((_state[Register.A] & 0x0F) - (value & 0x0F))) > 0;
_state[Flag.X2] = (x & 0x02) > 0;
_state[Flag.Zero] = difference == 0;
_state[Flag.Sign] = ((byte) difference & 0x80) > 0;
if (_state[RegisterPair.BC] == 1 || difference == 0)
{
_state.MemPtr++;
}
else
{
_state.MemPtr = (ushort) (_state.ProgramCounter + 1);
}
if (_state[RegisterPair.BC] != 0 && difference != 0)
{
_state.ProgramCounter -= 2;
_state.SetMCycles(4, 4, 3, 5, 5);
return;
}
}
_state.SetMCycles(4, 4, 3, 5);
}
public void INIR()
{
unchecked
{
var port = _state[RegisterPair.BC];
var data = _interface.ReadFromPort(port);
_interface.WriteToMemory(_state[RegisterPair.HL], data);
_state[RegisterPair.HL]++;
_state[Register.B]--;
_state[Flag.Carry] = data + ((_state[Register.C] + 1) & 0xFF) > 0xFF;
_state[Flag.AddSubtract] = (data & 0x80) > 0;
_state[Flag.ParityOverflow] = ((ushort) (((data + ((_state[Register.C] + 1) & 0xFF)) & 0x07) ^ _state[Register.B])).IsEvenParity();
_state[Flag.X1] = (_state[Register.B] & 0x08) > 0;
_state[Flag.HalfCarry] = data + ((_state[Register.C] + 1) & 0xFF) > 0xFF;
_state[Flag.X2] = (_state[Register.B] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (port + 1);
if (_state[Register.B] != 0)
{
_state.ProgramCounter -= 2;
_state.SetMCycles(4, 5, 3, 4, 5);
return;
}
}
_state.SetMCycles(4, 5, 3, 4);
}
public void OTIR()
{
unchecked
{
var address = _state[RegisterPair.HL];
var data = _interface.ReadFromMemory(address);
_state[Register.B]--;
var port = _state[RegisterPair.BC];
_interface.WriteToPort(port, data);
_state[RegisterPair.HL]++;
_state[Flag.Carry] = data + _state[Register.L] > 0xFF;
_state[Flag.AddSubtract] = (data & 0x80) > 0;
_state[Flag.ParityOverflow] = ((byte) ((data + _state[Register.L] & 7) ^ _state[Register.B])).IsEvenParity();
_state[Flag.X1] = (_state[Register.B] & 0x08) > 0;
_state[Flag.HalfCarry] = data + _state[Register.L] > 0xFF;
_state[Flag.X2] = (_state[Register.B] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] + 1);
if (_state[Register.B] != 0)
{
_state.ProgramCounter -= 2;
_state[Flag.X1] = (_state.ProgramCounter & 0x0800) > 0;
_state[Flag.X2] = (_state.ProgramCounter & 0x2000) > 0;
if (_state[Flag.Carry])
{
_state[Flag.HalfCarry] = (((_state[Flag.Sign] ? -1 : 1) ^ _state[Register.B]) & 0x16) > 0;
}
_state.SetMCycles(4, 5, 3, 4, 5);
return;
}
}
_state.SetMCycles(4, 5, 3, 4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LDDR()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
_interface.WriteToMemory(_state[RegisterPair.DE], value);
_state[RegisterPair.HL]--;
_state[RegisterPair.DE]--;
_state[RegisterPair.BC]--;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = (_state.ProgramCounter & 0x0800) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (_state.ProgramCounter & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
if (_state[RegisterPair.BC] != 1)
{
_state.MemPtr = (ushort) (_state.ProgramCounter + 1);
}
if (_state[RegisterPair.BC] != 0)
{
_state.ProgramCounter -= 2;
_state.SetMCycles(4, 4, 3, 5, 5);
return;
}
}
_state.SetMCycles(4, 4, 3, 5);
}
public void CPDR()
{
unchecked
{
var value = _interface.ReadFromMemory(_state[RegisterPair.HL]);
var difference = (sbyte) (_state[Register.A] - value);
_state[RegisterPair.HL]--;
_state[RegisterPair.BC]--;
var x = _state[Register.A] - (_state[Flag.Carry] ? 1 : 0);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = _state[RegisterPair.BC] != 0;
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) < (value & 0x0F);
_state[Flag.X2] = (x & 0x20) > 0; // TODO: 0x02?
_state[Flag.Zero] = difference == 0;
_state[Flag.Sign] = (byte) difference > 0x7F;
if (_state[RegisterPair.BC] == 1 || difference == 0)
{
_state.MemPtr++;
}
else
{
_state.MemPtr = (ushort) (_state.ProgramCounter + 1);
}
if (_state[RegisterPair.BC] != 0 && difference != 0)
{
_state[Flag.X1] = (_state.ProgramCounter & 0x0800) > 0;
_state[Flag.X2] = (_state.ProgramCounter & 0x2000) > 0;
_state.ProgramCounter -= 2;
_state.SetMCycles(4, 4, 3, 5, 5);
return;
}
}
_state.SetMCycles(4, 4, 3, 5);
}
public void INDR()
{
unchecked
{
var port = _state[RegisterPair.BC];
var data = _interface.ReadFromPort(port);
_interface.WriteToMemory(_state[RegisterPair.HL], data);
_state[RegisterPair.HL]--;
_state[Register.B]--;
var flagTemp1 = data + ((_state[Register.C] - 1) & 255);
var flagTemp2 = (ushort) ((flagTemp1 & 7) ^ _state[Register.B]);
_state[Flag.Carry] = flagTemp1 > 0xFF;
_state[Flag.AddSubtract] = (data & 0x80) > 0;
_state[Flag.ParityOverflow] = flagTemp2.IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = flagTemp1 > 0xFF;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (port + 1);
if (_state[Register.B] != 0)
{
_state.ProgramCounter -= 2;
_state.SetMCycles(4, 5, 3, 4, 5);
return;
}
}
_state.SetMCycles(4, 5, 3, 4);
}
public void OTDR()
{
unchecked
{
var address = _state[RegisterPair.HL];
var data = _interface.ReadFromMemory(address);
_state[RegisterPair.HL]--;
_state[Register.B]--;
_interface.WriteToPort(_state[RegisterPair.BC], data);
_state[Flag.Carry] = data + _state[Register.L] > 255;
_state[Flag.AddSubtract] = (data & 0b1000_0000) > 0;
_state[Flag.ParityOverflow] = ((byte) (((data + _state[Register.L]) & 0x07) ^ _state[Register.B])).IsEvenParity();
_state[Flag.X1] = (data & 0x08) > 0;
_state[Flag.HalfCarry] = data + _state[Register.L] > 255;
_state[Flag.X2] = (data & 0x20) > 0;
_state[Flag.Zero] = _state[Register.B] == 0;
_state[Flag.Sign] = (sbyte) _state[Register.B] < 0;
_state.MemPtr = (ushort) (_state[RegisterPair.BC] - 1);
if (_state[Register.B] != 0)
{
_state.ProgramCounter -= 2;
_state.SetMCycles(4, 5, 3, 4, 5);
return;
}
}
_state.SetMCycles(4, 5, 3, 4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var address = _state[source];
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 3);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_nn(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void ADD_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void RET()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void CALL_nn(byte[] parameters)
{
unchecked
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
}
_state.SetMCycles(4, 3, 4, 3, 3);
}
public void ADC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void OUT_an_R(byte[] parameters, Register register)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
_interface.WriteToPort(address, _state[register]);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void SUB_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[register] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void EXX()
{
unchecked
{
(_state[RegisterPair.BC], _state[RegisterPair.BC_]) = (_state[RegisterPair.BC_], _state[RegisterPair.BC]);
(_state[RegisterPair.DE], _state[RegisterPair.DE_]) = (_state[RegisterPair.DE_], _state[RegisterPair.DE]);
(_state[RegisterPair.HL], _state[RegisterPair.HL_]) = (_state[RegisterPair.HL_], _state[RegisterPair.HL]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void IN_R_n(Register register, byte[] parameters)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
var data = _interface.ReadFromPort(address);
_state[register] = data;
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void SBC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_aRR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
var value = _state[right];
var data = (ushort) (_interface.ReadFromMemory((ushort) (_state[left] + 1)) << 8);
data |= _interface.ReadFromMemory(_state[left]);
_state[right] = data;
_interface.WriteToMemory((ushort) (_state[left] + 1), (byte) ((value & 0xFF00) >> 8));
_interface.WriteToMemory(_state[left], (byte) (value & 0x00FF));
_state.MemPtr = _state[right];
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4, 3, 5);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void AND_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = _state[register] & parameters[0];
_state[register] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void JP_aRR(RegisterPair registers)
{
unchecked
{
_state.ProgramCounter = _state[registers];
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void XOR_R_n(Register target, byte[] parameters)
{
unchecked
{
var result = (byte) (parameters[0] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void DI()
{
_state.InterruptFlipFlop1 = false;
_state.InterruptFlipFlop2 = false;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void OR_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = (byte) (_state[register] | parameters[0]);
_state[register] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void LD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
_state[target] = _state[source];
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EI()
{
_state.InterruptFlipFlop1 = true;
_state.InterruptFlipFlop2 = true;
_state.IgnoreNextInterrupt = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CP_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void NOP()
{
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLCA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRCA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// Parity unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void DJNZ_e(byte[] parameters)
{
unchecked
{
_state[Register.B]--;
if (_state[Register.B] > 0)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.Q = 0;
_state.SetMCycles(5, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(5, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_aRR_R(RegisterPair target, Register source)
{
unchecked
{
var address = _state[target];
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RLA()
{
unchecked
{
var data = _state[Register.A];
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_e(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 5);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_aRR(Register target, RegisterPair source)
{
unchecked
{
var address = _state[source];
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (_state[source] + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void RRA()
{
unchecked
{
var data = _state[Register.A];
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_state[Register.A] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_RR(byte[] parameters, RegisterPair source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, (byte) (_state[source] & 0xFF));
_interface.WriteToMemory((ushort) (address + 1), (byte) ((_state[source] & 0xFF00) >> 8));
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void DAA()
{
unchecked
{
var adjust = 0;
if (_state[Flag.HalfCarry] || (_state[Register.A] & 0x0F) > 0x09)
{
adjust++;
}
if (_state[Flag.Carry] || _state[Register.A] > 0x99)
{
adjust += 2;
_state[Flag.Carry] = true;
}
if (_state[Flag.AddSubtract] && ! _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = false;
}
else
{
if (_state[Flag.AddSubtract] && _state[Flag.HalfCarry])
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) < 0x06;
}
else
{
_state[Flag.HalfCarry] = (_state[Register.A] & 0x0F) >= 0x0A;
}
}
switch (adjust)
{
case 1:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xFA : 0x06);
break;
case 2:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0xA0 : 0x60);
break;
case 3:
_state[Register.A] += (byte) (_state[Flag.AddSubtract] ? 0x9A : 0x66);
break;
}
// Flags
// Carry adjusted by operation
// AddSubtract adjusted by operation
_state[Flag.ParityOverflow] = _state[Register.A].IsEvenParity();
_state[Flag.X1] = (_state[Register.A] & 0x08) > 0;
// HalfCary adjusted by operation
_state[Flag.X2] = (_state[Register.A] & 0x20) > 0;
_state[Flag.Zero] = _state[Register.A] == 0;
_state[Flag.Sign] = (_state[Register.A] & 0x80) > 0;
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_RR_ann(RegisterPair target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
var value = (ushort) _interface.ReadFromMemory(address);
value |= (ushort) (_interface.ReadFromMemory((ushort) (address + 1)) << 8);
_state[target] = value;
_state.MemPtr = (ushort) ((parameters[1] << 8 | parameters[0]) + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CPL()
{
unchecked
{
var result = _state[Register.A] ^ 0xFF;
_state[Register.A] = (byte) result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void LD_RR_nn(RegisterPair target, byte[] parameters)
{
unchecked
{
_state.LoadRegisterPair(target, parameters);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void LD_ann_R(byte[] parameters, Register source)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) ((((parameters[1] << 8) | parameters[0] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void INC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value + 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_aRRd(RegisterPair registers, byte[] parameters)
{
unchecked
{
var address = _state[registers];
address = (ushort) (address + (sbyte) parameters[0]);
var value = _interface.ReadFromMemory(address);
var result = (byte) (value + 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void DEC_aRRd(RegisterPair registers, byte[] parameters)
{
unchecked
{
var address = _state[registers];
address = (ushort) (address + (sbyte) parameters[0]);
var value = _interface.ReadFromMemory(address);
var result = (byte) (value - 1);
_interface.WriteToMemory(address, result);
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void LD_aRRd_n(RegisterPair register, byte[] parameters)
{
unchecked
{
var address = _state[register];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, parameters[1]);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SCF()
{
unchecked
{
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = true;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void JR_F_e(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = (ushort) (_state.ProgramCounter + (sbyte) parameters[0]);
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(4, 3, 5);
return;
}
}
_state.Q = 0;
_state.SetMCycles(4, 3);
}
public void ADD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (ushort) result;
_state[Flag.Carry] = result > 0xFFFF;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (result & 0x0800) > 0;
_state[Flag.HalfCarry] = (right & 0x0FFF) + (left & 0x0FFF) > 0x0FFF;
_state[Flag.X2] = (result & 0x2000) > 0;
// Zero unaffected
// Sign unaffected
_state.MemPtr = (ushort) (left + 1);
}
_state.SetMCycles(4, 4, 3);
}
public void LD_R_ann(Register target, byte[] parameters)
{
unchecked
{
var address = parameters.ReadLittleEndian();
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3, 3);
}
public void DEC_RR(RegisterPair registers)
{
unchecked
{
var value = _state[registers];
var result = (ushort) (value - 1);
_state[registers] = result;
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void INC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value + 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = value == 0x7F;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) + 1 > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void DEC_R(Register register)
{
unchecked
{
var value = _state[register];
var result = (byte) (value - 1);
_state[register] = result;
// Carry unaffected
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = value == 0x80;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (value & 0x0F) == 0;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void LD_R_n(Register target, byte[] parameters)
{
unchecked
{
_state[target] = parameters[0];
_state.Q = 0;
}
_state.SetMCycles(4, 3);
}
public void CCF()
{
unchecked
{
var value = _state[Flag.Carry];
var x = (byte) ((_state.Q ^ _state[Register.F]) | _state[Register.A]);
_state[Flag.Carry] = ! value;
_state[Flag.AddSubtract] = false;
// ParityOverflow unaffected
_state[Flag.X1] = (x & 0x08) > 0;
_state[Flag.HalfCarry] = value;
_state[Flag.X2] = (x & 0x20) > 0;
// Zero unaffected
// Sign unaffected
}
_state.SetMCycles(4);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void HALT()
{
_state.Halted = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void LD_aRRd_R(RegisterPair target, byte[] parameters, Register source)
{
unchecked
{
var address = _state[target];
address = (ushort) (address + (sbyte) parameters[0]);
_interface.WriteToMemory(address, _state[source]);
_state.MemPtr = (ushort) (((_state[target] + 1) & 0xFF) | (_state[source] << 8));
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void LD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
_state[target] = _interface.ReadFromMemory(address);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void LD_R_R(Register target, Register source)
{
unchecked
{
var value = _state[source];
_state[target] = value;
if (target == Register.A && (source == Register.I || source == Register.R))
{
// Flags
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = _state.InterruptFlipFlop2;
_state[Flag.X1] = (value & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (value & 0x20) > 0;
_state[Flag.Zero] = value == 0;
_state[Flag.Sign] = (sbyte) value < 0;
}
else
{
_state.Q = 0;
}
}
if (target == Register.I || target == Register.R || source == Register.I || source == Register.R)
{
_state.SetMCycles(4, 5);
}
else
{
_state.SetMCycles(4);
}
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADD_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void ADD_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void ADC_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void ADC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SUB_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SUB_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void SBC_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void SBC_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void AND_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = _state[target] & right;
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void AND_R_R(Register target, Register source)
{
unchecked
{
var result = _state[target] & _state[source];
_state[target] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void XOR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void XOR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void OR_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void OR_R_R(Register target, Register source)
{
unchecked
{
var result = (byte) (_state[source] | _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void CP_R_aRRd(Register target, RegisterPair source, byte[] parameters)
{
unchecked
{
var left = _state[target];
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var right = _interface.ReadFromMemory(address);
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 4, 3, 5, 3);
}
public void CP_R_R(Register target, Register source)
{
unchecked
{
var left = _state[target];
var right = _state[source];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_nn(byte[] parameters)
{
unchecked
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void ADD_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var result = left + right;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void RET()
{
unchecked
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void CALL_nn(byte[] parameters)
{
unchecked
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
}
_state.SetMCycles(4, 3, 4, 3, 3);
}
public void ADC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left + right + carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result > 0xFF;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) == 0 && ((left ^ result) & 0x80) != 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) + (right & 0x0F) + carry > 0xF;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void OUT_an_R(byte[] parameters, Register register)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
_interface.WriteToPort(address, _state[register]);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void SUB_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[register] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ result) & 0x80) == 0;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void EXX()
{
unchecked
{
(_state[RegisterPair.BC], _state[RegisterPair.BC_]) = (_state[RegisterPair.BC_], _state[RegisterPair.BC]);
(_state[RegisterPair.DE], _state[RegisterPair.DE_]) = (_state[RegisterPair.DE_], _state[RegisterPair.DE]);
(_state[RegisterPair.HL], _state[RegisterPair.HL_]) = (_state[RegisterPair.HL_], _state[RegisterPair.HL]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void IN_R_n(Register register, byte[] parameters)
{
unchecked
{
var address = (ushort) ((_state[register] << 8) | parameters[0]);
var data = _interface.ReadFromPort(address);
_state[register] = data;
_state.MemPtr = (ushort) (address + 1);
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void SBC_R_n(Register target, byte[] parameters)
{
unchecked
{
var left = _state[target];
var right = parameters[0];
var carry = (byte) (_state[Flag.Carry] ? 1 : 0);
var result = left - right - carry;
_state[target] = (byte) result;
_state[Flag.Carry] = result < 0;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = (sbyte) left - (sbyte) right - carry is < -128 or > 127;
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F) + carry;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = (byte) result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_aRR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
var value = _state[right];
var data = (ushort) (_interface.ReadFromMemory((ushort) (_state[left] + 1)) << 8);
data |= _interface.ReadFromMemory(_state[left]);
_state[right] = data;
_interface.WriteToMemory((ushort) (_state[left] + 1), (byte) ((value & 0xFF00) >> 8));
_interface.WriteToMemory(_state[left], (byte) (value & 0x00FF));
_state.MemPtr = _state[right];
_state.Q = 0;
}
_state.SetMCycles(4, 3, 4, 3, 5);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void AND_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = _state[register] & parameters[0];
_state[register] = (byte) result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = ((byte) result).IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void JP_aRR(RegisterPair registers)
{
unchecked
{
_state.ProgramCounter = _state[registers];
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EX_RR_RR(RegisterPair left, RegisterPair right)
{
unchecked
{
(_state[left], _state[right]) = (_state[right], _state[left]);
_state.Q = 0;
}
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void XOR_R_n(Register target, byte[] parameters)
{
unchecked
{
var result = (byte) (parameters[0] ^ _state[target]);
_state[target] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void POP_RR(RegisterPair registers)
{
unchecked
{
var data = (ushort) _interface.ReadFromMemory(_state.StackPointer);
_state.StackPointer++;
data |= (ushort) (_interface.ReadFromMemory(_state.StackPointer) << 8);
_state.StackPointer++;
_state[registers] = data;
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void DI()
{
_state.InterruptFlipFlop1 = false;
_state.InterruptFlipFlop2 = false;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PUSH_RR(RegisterPair registers)
{
unchecked
{
var data = _state[registers];
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((data & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (data & 0x00FF));
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void OR_R_n(Register register, byte[] parameters)
{
unchecked
{
var result = (byte) (_state[register] | parameters[0]);
_state[register] = result;
_state[Flag.Carry] = false;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RET_F(Flag flag, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
var data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = data;
_state.StackPointer++;
data = _interface.ReadFromMemory(_state.StackPointer);
_state.ProgramCounter = (ushort) ((_state.ProgramCounter & 0x00FF) | data << 8);
_state.StackPointer++;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
_state.SetMCycles(5, 3, 3);
return;
}
_state.Q = 0;
}
_state.SetMCycles(5);
}
public void LD_RR_RR(RegisterPair target, RegisterPair source)
{
unchecked
{
_state[target] = _state[source];
_state.Q = 0;
}
_state.SetMCycles(6);
}
public void JP_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.ProgramCounter = parameters.ReadLittleEndian();
_state.MemPtr = _state.ProgramCounter;
}
_state.Q = 0;
}
_state.SetMCycles(4, 3, 3);
}
public void EI()
{
_state.InterruptFlipFlop1 = true;
_state.InterruptFlipFlop2 = true;
_state.IgnoreNextInterrupt = true;
_state.Q = 0;
_state.SetMCycles(4);
}
public void CALL_F_nn(Flag flag, byte[] parameters, bool not = false)
{
unchecked
{
var condition = not ? ! _state[flag] : _state[flag];
if (condition)
{
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((_state.ProgramCounter & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (_state.ProgramCounter & 0x00FF));
_state.ProgramCounter = (ushort) ((parameters[1] << 8) | parameters[0]);
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 4, 3, 3);
return;
}
}
_state.MemPtr = (ushort) (parameters[1] << 8 | parameters[0]);
_state.Q = 0;
_state.SetMCycles(4, 3, 3);
}
public void PREFIX(ushort parameters)
{
_state.InstructionPrefix = parameters;
_state.ClearMCycles();
}
public void CP_R_n(Register register, byte[] parameters)
{
unchecked
{
var left = _state[register];
var right = parameters[0];
var result = left - right;
_state[Flag.Carry] = right > left;
_state[Flag.AddSubtract] = true;
_state[Flag.ParityOverflow] = ((left ^ right) & 0x80) != 0 && ((right ^ (byte) result) & 0x80) == 0;
_state[Flag.X1] = (right & 0x08) > 0;
_state[Flag.HalfCarry] = (left & 0x0F) < (right & 0x0F);
_state[Flag.X2] = (right & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (byte) result > 0x7F;
}
_state.SetMCycles(4, 3);
}
public void RST(byte address)
{
unchecked
{
var pc = _state.ProgramCounter;
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) ((pc & 0xFF00) >> 8));
_state.StackPointer--;
_interface.WriteToMemory(_state.StackPointer, (byte) (pc & 0x00FF));
_state.ProgramCounter = address;
_state.MemPtr = _state.ProgramCounter;
_state.Q = 0;
}
_state.SetMCycles(5, 3, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RLC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RRC_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (bottomBit << 7));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | (byte) (_state[Flag.Carry] ? 0x01 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RR_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | (byte) (_state[Flag.Carry] ? 0x80 : 0x00));
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) ((data << 1) & 0xFE);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRA_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) (data & 0x80);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) | topBit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SLL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var topBit = (byte) ((data & 0x80) >> 7);
var result = (byte) (((data << 1) & 0xFE) | 0x01);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = topBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd(RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SRL_aRRd_R(RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var bottomBit = (byte) (data & 0x01);
var result = (byte) ((data >> 1) & 0x7F);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state[Flag.Carry] = bottomBit == 1;
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result.IsEvenParity();
_state[Flag.X1] = (result & 0x08) > 0;
_state[Flag.HalfCarry] = false;
_state[Flag.X2] = (result & 0x20) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void BIT_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & bit);
// Carry unaffected
_state[Flag.AddSubtract] = false;
_state[Flag.ParityOverflow] = result == 0;
_state[Flag.X1] = (address & 0x0800) > 0;
_state[Flag.HalfCarry] = true;
_state[Flag.X2] = (address & 0x2000) > 0;
_state[Flag.Zero] = result == 0;
_state[Flag.Sign] = (sbyte) result < 0;
_state.MemPtr = address;
}
_state.SetMCycles(4, 4, 3, 5, 4);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void RES_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort) (address + (sbyte) parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte) (data & ~bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd(byte bit, RegisterPair source, byte[] parameters)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
public void SET_b_aRRd_R(byte bit, RegisterPair source, byte[] parameters, Register target)
{
unchecked
{
var address = _state[source];
address = (ushort)(address + (sbyte)parameters[0]);
var data = _interface.ReadFromMemory(address);
var result = (byte)(data | bit);
_interface.WriteToMemory(address, result);
_state[target] = result;
_state.MemPtr = address;
_state.Q = 0;
}
_state.SetMCycles(4, 4, 3, 5, 4, 3);
}
Base OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
NOP |
LD BC, nn |
LD (BC), A |
INC BC |
INC B |
DEC B |
LD B, n |
RLCA |
EX AF, AF' |
ADD HL, BC |
LD A, (BC) |
DEC BC |
INC C |
DEC C |
LD C, n |
RRCA |
1 |
DJNZ e |
LD DE, nn |
LD (DE), A |
INC DE |
INC D |
DEC D |
LD D, n |
RLA |
JR e |
ADD HL, DE |
LD A, (DE) |
DEC DE |
INC E |
DEC E |
LD E, n |
RRA |
2 |
JR NZ, e |
LD HL, nn |
LD (nn), HL |
INC HL |
INC H |
DEC H |
LD H, n |
DAA |
JR Z, e |
ADD HL, HL |
LD HL, (nn) |
DEC HL |
INC L |
DEC L |
LD L, n |
CPL |
3 |
JR NC, e |
LD SP, nn |
LD (nn), A |
INC SP |
INC (HL) |
DEC (HL) |
LD (HL), n |
SCF |
JR C, e |
ADD HL, SP |
LD A, (nn) |
DEC SP |
INC A |
DEC A |
LD A, n |
CCF |
4 |
LD B, B |
LD B, C |
LD B, D |
LD B, E |
LD B, H |
LD B, L |
LD B, (HL) |
LD B, A |
LD C, B |
LD C, C |
LD C, D |
LD C, E |
LD C, H |
LD C, L |
LD C, (HL) |
LD C, A |
5 |
LD D, B |
LD D, C |
LD D, D |
LD D, E |
LD D, H |
LD D, L |
LD D, (HL) |
LD D, A |
LD E, B |
LD E, C |
LD E, D |
LD E, E |
LD E, H |
LD E, L |
LD E, (HL) |
LD E, A |
6 |
LD H, B |
LD H, C |
LD H, D |
LD H, E |
LD H, H |
LD H, L |
LD H, (HL) |
LD H, A |
LD L, B |
LD L, C |
LD L, D |
LD L, E |
LD L, H |
LD L, L |
LD L, (HL) |
LD L, A |
7 |
LD (HL), B |
LD (HL), C |
LD (HL), D |
LD (HL), E |
LD (HL), H |
LD (HL), L |
HALT |
LD (HL), A |
LD A, B |
LD A, C |
LD A, D |
LD A, E |
LD A, H |
LD A, L |
LD A, (HL) |
LD A, A |
8 |
ADD A, B |
ADD A, C |
ADD A, D |
ADD A, E |
ADD A, H |
ADD A, L |
ADD A, (HL) |
ADD A, A |
ADC A, B |
ADC A, C |
ADC A, D |
ADC A, E |
ADC A, H |
ADC A, L |
ADC A, (HL) |
ADC A, A |
9 |
SUB A, B |
SUB A, C |
SUB A, D |
SUB A, E |
SUB A, H |
SUB A, L |
SUB A, (HL) |
SUB A, A |
SBC A, B |
SBC A, C |
SBC A, D |
SBC A, E |
SBC A, H |
SBC A, L |
SBC A, (HL) |
SBC A, A |
A |
AND A, B |
AND A, C |
AND A, D |
AND A, E |
AND A, H |
AND A, L |
AND A, (HL) |
AND A, A |
XOR A, B |
XOR A, C |
XOR A, D |
XOR A, E |
XOR A, H |
XOR A, L |
XOR A, (HL) |
XOR A, A |
B |
OR A, B |
OR A, C |
OR A, D |
OR A, E |
OR A, H |
OR A, L |
OR A, (HL) |
OR A, A |
CP A, B |
CP A, C |
CP A, D |
CP A, E |
CP A, H |
CP A, L |
CP A, (HL) |
CP A, A |
C |
RET NZ |
POP BC |
JP NZ, nn |
JP nn |
CALL NZ, nn |
PUSH BC |
ADD A, n |
RST 0x00 |
RET Z |
RET |
JP Z, nn |
PREFIX 0xCB |
CALL Z, nn |
CALL nn |
ADC A, n |
RST 0x08 |
D |
RET NC |
POP DE |
JP NC, nn |
OUT (n), A |
CALL NC, nn |
PUSH DE |
SUB A, n |
RST 0x10 |
RET C |
EXX |
JP C, nn |
IN A, n |
CALL C, nn |
PREFIX 0xDD |
SBC A, n |
RST 0x18 |
E |
RET PO |
POP HL |
JP PO, nn |
EX (SP), HL |
CALL PO, nn |
PUSH HL |
AND A, n |
RST 0x20 |
RET PE |
JP (HL) |
JP PE, nn |
EX DE, HL |
CALL PE, nn |
PREFIX 0xED |
XOR A, n |
RST 0x28 |
F |
RET NS |
POP AF |
JP NS, nn |
DI |
CALL NS, nn |
PUSH AF |
OR A, n |
RST 0x30 |
RET S |
LD SP, HL |
JP S, nn |
EI |
CALL S, nn |
PREFIX 0xFD |
CP A, n |
RST 0x38 |
CB OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
RLC B |
RLC C |
RLC D |
RLC E |
RLC H |
RLC L |
RLC (HL) |
RLC A |
RRC B |
RRC C |
RRC D |
RRC E |
RRC H |
RRC L |
RRC (HL) |
RRC A |
1 |
RL B |
RL C |
RL D |
RL E |
RL H |
RL L |
RL (HL) |
RL A |
RR B |
RR C |
RR D |
RR E |
RR H |
RR L |
RR (HL) |
RR A |
2 |
SLA B |
SLA C |
SLA D |
SLA E |
SLA H |
SLA L |
SLA (HL) |
SLA A |
SRA B |
SRA C |
SRA D |
SRA E |
SRA H |
SRA L |
SRA (HL) |
SRA A |
3 |
SLL B |
SLL C |
SLL D |
SLL E |
SLL H |
SLL L |
SLL (HL) |
SLL A |
SRL B |
SRL C |
SRL D |
SRL E |
SRL H |
SRL L |
SRL (HL) |
SRL A |
4 |
BIT 0, B |
BIT 0, C |
BIT 0, D |
BIT 0, E |
BIT 0, H |
BIT 0, L |
BIT 0, (HL) |
BIT 0, A |
BIT 1, B |
BIT 1, C |
BIT 1, D |
BIT 1, E |
BIT 1, H |
BIT 1, L |
BIT 1, (HL) |
BIT 1, A |
5 |
BIT 2, B |
BIT 2, C |
BIT 2, D |
BIT 2, E |
BIT 2, H |
BIT 2, L |
BIT 2, (HL) |
BIT 2, A |
BIT 3, B |
BIT 3, C |
BIT 3, D |
BIT 3, E |
BIT 3, H |
BIT 3, L |
BIT 3, (HL) |
BIT 3, A |
6 |
BIT 4, B |
BIT 4, C |
BIT 4, D |
BIT 4, E |
BIT 4, H |
BIT 4, L |
BIT 4, (HL) |
BIT 4, A |
BIT 5, B |
BIT 5, C |
BIT 5, D |
BIT 5, E |
BIT 5, H |
BIT 5, L |
BIT 5, (HL) |
BIT 5, A |
7 |
BIT 6, B |
BIT 6, C |
BIT 6, D |
BIT 6, E |
BIT 6, H |
BIT 6, L |
BIT 6, (HL) |
BIT 6, A |
BIT 7, B |
BIT 7, C |
BIT 7, D |
BIT 7, E |
BIT 7, H |
BIT 7, L |
BIT 7, (HL) |
BIT 7, A |
8 |
RES 0, B |
RES 0, C |
RES 0, D |
RES 0, E |
RES 0, H |
RES 0, L |
RES 0, (HL) |
RES 0, A |
RES 1, B |
RES 1, C |
RES 1, D |
RES 1, E |
RES 1, H |
RES 1, L |
RES 1, (HL) |
RES 1, A |
9 |
RES 2, B |
RES 2, C |
RES 2, D |
RES 2, E |
RES 2, H |
RES 2, L |
RES 2, (HL) |
RES 2, A |
RES 3, B |
RES 3, C |
RES 3, D |
RES 3, E |
RES 3, H |
RES 3, L |
RES 3, (HL) |
RES 3, A |
A |
RES 4, B |
RES 4, C |
RES 4, D |
RES 4, E |
RES 4, H |
RES 4, L |
RES 4, (HL) |
RES 4, A |
RES 5, B |
RES 5, C |
RES 5, D |
RES 5, E |
RES 5, H |
RES 5, L |
RES 5, (HL) |
RES 5, A |
B |
RES 6, B |
RES 6, C |
RES 6, D |
RES 6, E |
RES 6, H |
RES 6, L |
RES 6, (HL) |
RES 6, A |
RES 7, B |
RES 7, C |
RES 7, D |
RES 7, E |
RES 7, H |
RES 7, L |
RES 7, (HL) |
RES 7, A |
C |
SET 0, B |
SET 0, C |
SET 0, D |
SET 0, E |
SET 0, H |
SET 0, L |
SET 0, (HL) |
SET 0, A |
SET 1, B |
SET 1, C |
SET 1, D |
SET 1, E |
SET 1, H |
SET 1, L |
SET 1, (HL) |
SET 1, A |
D |
SET 2, B |
SET 2, C |
SET 2, D |
SET 2, E |
SET 2, H |
SET 2, L |
SET 2, (HL) |
SET 2, A |
SET 3, B |
SET 3, C |
SET 3, D |
SET 3, E |
SET 3, H |
SET 3, L |
SET 3, (HL) |
SET 3, A |
E |
SET 4, B |
SET 4, C |
SET 4, D |
SET 4, E |
SET 4, H |
SET 4, L |
SET 4, (HL) |
SET 4, A |
SET 5, B |
SET 5, C |
SET 5, D |
SET 5, E |
SET 5, H |
SET 5, L |
SET 5, (HL) |
SET 5, A |
F |
SET 6, B |
SET 6, C |
SET 6, D |
SET 6, E |
SET 6, H |
SET 6, L |
SET 6, (HL) |
SET 6, A |
SET 7, B |
SET 7, C |
SET 7, D |
SET 7, E |
SET 7, H |
SET 7, L |
SET 7, (HL) |
SET 7, A |
DD OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
NOP |
LD BC, nn |
LD (BC), A |
INC BC |
INC B |
DEC B |
LD B, n |
RLCA |
EX AF, AF' |
ADD IX, BC |
LD A, (BC) |
DEC BC |
INC C |
DEC C |
LD C, n |
RRCA |
1 |
DJNZ e |
LD DE, nn |
LD (DE), A |
INC DE |
INC D |
DEC D |
LD D, n |
RLA |
JR e |
ADD IX, DE |
LD A, (DE) |
DEC DE |
INC E |
DEC E |
LD E, n |
RRA |
2 |
JR NZ, e |
LD IX, nn |
LD (nn), IX |
INC IX |
INC IXh |
DEC IXh |
LD IXh, n |
DAA |
JR Z, e |
ADD IX, IX |
LD IX, (nn) |
DEC IX |
INC IXl |
DEC IXl |
LD IXl, n |
CPL |
3 |
JR NC, e |
LD SP, nn |
LD (nn), A |
INC SP |
INC (IX + d) |
DEC (IX + d) |
LD (IX + d), n |
SCF |
JR C, e |
ADD IX, SP |
LD A, (nn) |
DEC SP |
INC A |
DEC A |
LD A, n |
CCF |
4 |
LD B, B |
LD B, C |
LD B, D |
LD B, E |
LD B, IXh |
LD B, IXl |
LD B, (IX + d) |
LD B, A |
LD C, B |
LD C, C |
LD C, D |
LD C, E |
LD C, IXh |
LD C, IXl |
LD C, (IX + d) |
LD C, A |
5 |
LD D, B |
LD D, C |
LD D, D |
LD D, E |
LD D, IXh |
LD D, IXl |
LD D, (IX + d) |
LD D, A |
LD E, B |
LD E, C |
LD E, D |
LD E, E |
LD E, IXh |
LD E, IXl |
LD E, (IX + d) |
LD E, A |
6 |
LD IXh, B |
LD IXh, C |
LD IXh, D |
LD IXh, E |
LD IXh, IXh |
LD IXh, IXl |
LD H, (IX + d) |
LD IXh, A |
LD IXl, B |
LD IXl, C |
LD IXl, D |
LD IXl, E |
LD IXl, IXh |
LD IXl, IXl |
LD L, (IX + d) |
LD IXl, A |
7 |
LD (IX + d), B |
LD (IX + d), C |
LD (IX + d), D |
LD (IX + d), E |
LD (IX + d), H |
LD (IX + d), L |
HALT |
LD (IX + d), A |
LD A, B |
LD A, C |
LD A, D |
LD A, E |
LD A, IXh |
LD A, IXl |
LD A, (IX + d) |
LD A, A |
8 |
ADD A, B |
ADD A, C |
ADD A, D |
ADD A, E |
ADD A, IXh |
ADD A, IXl |
ADD A, (IX + d) |
ADD A, A |
ADC A, B |
ADC A, C |
ADC A, D |
ADC A, E |
ADC A, IXh |
ADC A, IXl |
ADC A, (IX + d) |
ADC A, A |
9 |
SUB A, B |
SUB A, C |
SUB A, D |
SUB A, E |
SUB A, IXh |
SUB A, IXl |
SUB A, (IX + d) |
SUB A, A |
SBC A, B |
SBC A, C |
SBC A, D |
SBC A, E |
SBC A, IXh |
SBC A, IXl |
SBC A, (IX + d) |
SBC A, A |
A |
AND A, B |
AND A, C |
AND A, D |
AND A, E |
AND A, IXh |
AND A, IXl |
AND A, (IX + d) |
AND A, A |
XOR A, B |
XOR A, C |
XOR A, D |
XOR A, E |
XOR A, IXh |
XOR A, IXl |
XOR A, (IX + d) |
XOR A, A |
B |
OR A, B |
OR A, C |
OR A, D |
OR A, E |
OR A, IXh |
OR A, IXl |
OR A, (IX + d) |
OR A, A |
CP A, B |
CP A, C |
CP A, D |
CP A, E |
CP A, IXh |
CP A, IXl |
CP A, (IX + d) |
CP A, A |
C |
RET NZ |
POP BC |
JP NZ, nn |
JP nn |
CALL NZ, nn |
PUSH BC |
ADD A, n |
RST 0x00 |
RET Z |
RET |
JP Z, nn |
PREFIX 0xDDCB |
CALL Z, nn |
CALL nn |
ADC A, n |
RST 0x08 |
D |
RET NC |
POP DE |
JP NC, nn |
OUT (n), A |
CALL NC, nn |
PUSH DE |
SUB A, n |
RST 0x10 |
RET C |
EXX |
JP C, nn |
IN A, n |
CALL C, nn |
PREFIX 0xDD |
SBC A, n |
RST 0x18 |
E |
RET PO |
POP IX |
JP PO, nn |
EX (SP), IX |
CALL PO, nn |
PUSH IX |
AND A, n |
RST 0x20 |
RET PE |
JP (IX) |
JP PE, nn |
EX DE, HL |
CALL PE, nn |
PREFIX 0xED |
XOR A, n |
RST 0x28 |
F |
RET NS |
POP AF |
JP NS, nn |
DI |
CALL NS, nn |
PUSH AF |
OR A, n |
RST 0x30 |
RET S |
LD SP, IX |
JP S, nn |
EI |
CALL S, nn |
PREFIX 0xFD |
CP A, n |
RST 0x38 |
DDCB OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
RLC (IX + d), B |
RLC (IX + d), C |
RLC (IX + d), D |
RLC (IX + d), E |
RLC (IX + d), H |
RLC (IX + d), L |
RLC (IX + d) |
RLC (IX + d), A |
RRC (IX + d), B |
RRC (IX + d), C |
RRC (IX + d), D |
RRC (IX + d), E |
RRC (IX + d), H |
RRC (IX + d), L |
RRC (IX + d) |
RRC (IX + d), A |
1 |
RL (IX + d), B |
RL (IX + d), C |
RL (IX + d), D |
RL (IX + d), E |
RL (IX + d), H |
RL (IX + d), L |
RL (IX + d) |
RL (IX + d), A |
RR (IX + d), B |
RR (IX + d), C |
RR (IX + d), D |
RR (IX + d), E |
RR (IX + d), H |
RR (IX + d), L |
RR (IX + d) |
RR (IX + d), A |
2 |
SLA (IX + d), B |
SLA (IX + d), C |
SLA (IX + d), D |
SLA (IX + d), E |
SLA (IX + d), H |
SLA (IX + d), L |
SLA (IX + d) |
SLA (IX + d), A |
SRA (IX + d), B |
SRA (IX + d), C |
SRA (IX + d), D |
SRA (IX + d), E |
SRA (IX + d), H |
SRA (IX + d), L |
SRA (IX + d) |
SRA (IX + d), A |
3 |
SLL (IX + d), B |
SLL (IX + d), C |
SLL (IX + d), D |
SLL (IX + d), E |
SLL (IX + d), H |
SLL (IX + d), L |
SLL (IX + d) |
SLL (IX + d), A |
SRL (IX + d), B |
SRL (IX + d), C |
SRL (IX + d), D |
SRL (IX + d), E |
SRL (IX + d), H |
SRL (IX + d), L |
SRL (IX + d) |
SRL (IX + d), A |
4 |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 0, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
BIT 1, (IX + d) |
5 |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 2, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
BIT 3, (IX + d) |
6 |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 4, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
BIT 5, (IX + d) |
7 |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 6, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
BIT 7, (IX + d) |
8 |
RES 0, (IX + d), B |
RES 0, (IX + d), C |
RES 0, (IX + d), D |
RES 0, (IX + d), E |
RES 0, (IX + d), H |
RES 0, (IX + d), L |
RES 0, (IX + d) |
RES 0, (IX + d), A |
RES 1, (IX + d), B |
RES 1, (IX + d), C |
RES 1, (IX + d), D |
RES 1, (IX + d), E |
RES 1, (IX + d), H |
RES 1, (IX + d), L |
RES 1, (IX + d) |
RES 1, (IX + d), A |
9 |
RES 2, (IX + d), B |
RES 2, (IX + d), C |
RES 2, (IX + d), D |
RES 2, (IX + d), E |
RES 2, (IX + d), H |
RES 2, (IX + d), L |
RES 2, (IX + d) |
RES 2, (IX + d), A |
RES 3, (IX + d), B |
RES 3, (IX + d), C |
RES 3, (IX + d), D |
RES 3, (IX + d), E |
RES 3, (IX + d), H |
RES 3, (IX + d), L |
RES 3, (IX + d) |
RES 3, (IX + d), A |
A |
RES 4, (IX + d), B |
RES 4, (IX + d), C |
RES 4, (IX + d), D |
RES 4, (IX + d), E |
RES 4, (IX + d), H |
RES 4, (IX + d), L |
RES 4, (IX + d) |
RES 4, (IX + d), A |
RES 5, (IX + d), B |
RES 5, (IX + d), C |
RES 5, (IX + d), D |
RES 5, (IX + d), E |
RES 5, (IX + d), H |
RES 5, (IX + d), L |
RES 5, (IX + d) |
RES 5, (IX + d), A |
B |
RES 6, (IX + d), B |
RES 6, (IX + d), C |
RES 6, (IX + d), D |
RES 6, (IX + d), E |
RES 6, (IX + d), H |
RES 6, (IX + d), L |
RES 6, (IX + d) |
RES 6, (IX + d), A |
RES 7, (IX + d), B |
RES 7, (IX + d), C |
RES 7, (IX + d), D |
RES 7, (IX + d), E |
RES 7, (IX + d), H |
RES 7, (IX + d), L |
RES 7, (IX + d) |
RES 7, (IX + d), A |
C |
SET 0, (IX + d), B |
SET 0, (IX + d), C |
SET 0, (IX + d), D |
SET 0, (IX + d), E |
SET 0, (IX + d), H |
SET 0, (IX + d), L |
SET 0, (IX + d) |
SET 0, (IX + d), A |
SET 1, (IX + d), B |
SET 1, (IX + d), C |
SET 1, (IX + d), D |
SET 1, (IX + d), E |
SET 1, (IX + d), H |
SET 1, (IX + d), L |
SET 1, (IX + d) |
SET 1, (IX + d), A |
D |
SET 2, (IX + d), B |
SET 2, (IX + d), C |
SET 2, (IX + d), D |
SET 2, (IX + d), E |
SET 2, (IX + d), H |
SET 2, (IX + d), L |
SET 2, (IX + d) |
SET 2, (IX + d), A |
SET 3, (IX + d), B |
SET 3, (IX + d), C |
SET 3, (IX + d), D |
SET 3, (IX + d), E |
SET 3, (IX + d), H |
SET 3, (IX + d), L |
SET 3, (IX + d) |
SET 3, (IX + d), A |
E |
SET 4, (IX + d), B |
SET 4, (IX + d), C |
SET 4, (IX + d), D |
SET 4, (IX + d), E |
SET 4, (IX + d), H |
SET 4, (IX + d), L |
SET 4, (IX + d) |
SET 4, (IX + d), A |
SET 5, (IX + d), B |
SET 5, (IX + d), C |
SET 5, (IX + d), D |
SET 5, (IX + d), E |
SET 5, (IX + d), H |
SET 5, (IX + d), L |
SET 5, (IX + d) |
SET 5, (IX + d), A |
F |
SET 6, (IX + d), B |
SET 6, (IX + d), C |
SET 6, (IX + d), D |
SET 6, (IX + d), E |
SET 6, (IX + d), H |
SET 6, (IX + d), L |
SET 6, (IX + d) |
SET 6, (IX + d), A |
SET 7, (IX + d), B |
SET 7, (IX + d), C |
SET 7, (IX + d), D |
SET 7, (IX + d), E |
SET 7, (IX + d), H |
SET 7, (IX + d), L |
SET 7, (IX + d) |
SET 7, (IX + d), A |
ED OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
NOP |
LD BC, nn |
LD (BC), A |
INC BC |
INC B |
DEC B |
LD B, n |
RLCA |
EX AF, AF' |
ADD HL, BC |
LD A, (BC) |
DEC BC |
INC C |
DEC C |
LD C, n |
RRCA |
1 |
DJNZ e |
LD DE, nn |
LD (DE), A |
INC DE |
INC D |
DEC D |
LD D, n |
RLA |
JR e |
ADD HL, DE |
LD A, (DE) |
DEC DE |
INC E |
DEC E |
LD E, n |
RRA |
2 |
JR NZ, e |
LD HL, nn |
LD (nn), HL |
INC HL |
INC H |
DEC H |
LD H, n |
DAA |
JR Z, e |
ADD HL, HL |
LD HL, (nn) |
DEC HL |
INC L |
DEC L |
LD L, n |
CPL |
3 |
JR NC, e |
LD SP, nn |
LD (nn), A |
INC SP |
INC (HL) |
DEC (HL) |
LD (HL), n |
SCF |
JR C, e |
ADD HL, SP |
LD A, (nn) |
DEC SP |
INC A |
DEC A |
LD A, n |
CCF |
4 |
IN B, (C) |
OUT (C), B |
SBC HL, BC |
LD (nn), BC |
NEG A |
RETN |
IM 0 |
LD I, A |
IN C, (C) |
OUT (C), C |
ADC HL, BC |
LD BC, (nn) |
NEG A |
RETI |
IM 0 |
LD R, A |
5 |
IN D, (C) |
OUT (C), D |
SBC HL, DE |
LD (nn), DE |
NEG A |
RETN |
IM 1 |
LD A, I |
IN E, (C) |
OUT (C), E |
ADC HL, DE |
LD DE, (nn) |
NEG A |
RETN |
IM 2 |
LD A, R |
6 |
IN H, (C) |
OUT (C), H |
SBC HL, HL |
LD (nn), HL |
NEG A |
RETN |
IM 0 |
RRD |
IN L, (C) |
OUT (C), L |
ADC HL, HL |
LD HL, (nn) |
NEG A |
RETN |
IM 0 |
RLD |
7 |
IN (C) |
OUT (C), 0 |
SBC HL, SP |
LD (nn), SP |
NEG A |
RETN |
HALT |
NOP |
IN A, (C) |
OUT (C), A |
ADC HL, SP |
LD SP, (nn) |
NEG A |
RETN |
IM 2 |
LD A, A |
8 |
ADD A, B |
ADD A, C |
ADD A, D |
ADD A, E |
ADD A, H |
ADD A, L |
ADD A, (HL) |
ADD A, A |
ADC A, B |
ADC A, C |
ADC A, D |
ADC A, E |
ADC A, H |
ADC A, L |
ADC A, (HL) |
ADC A, A |
9 |
SUB A, B |
SUB A, C |
SUB A, D |
SUB A, E |
SUB A, H |
SUB A, L |
SUB A, (HL) |
SUB A, A |
SBC A, B |
SBC A, C |
SBC A, D |
SBC A, E |
SBC A, H |
SBC A, L |
SBC A, (HL) |
SBC A, A |
A |
LDI |
CPI |
INI |
OUTI |
AND A, H |
AND A, L |
AND A, (HL) |
AND A, A |
LDD |
CPD |
IND |
OUTD |
XOR A, H |
XOR A, L |
XOR A, (HL) |
XOR A, A |
B |
LDIR |
CPIR |
INIR |
OTIR |
OR A, H |
OR A, L |
OR A, (HL) |
OR A, A |
LDDR |
CPDR |
INDR |
OTDR |
CP A, H |
CP A, L |
CP A, (HL) |
CP A, A |
C |
RET NZ |
POP BC |
JP NZ, nn |
JP nn |
CALL NZ, nn |
PUSH BC |
ADD A, n |
RST 0x00 |
RET Z |
RET |
JP Z, nn |
PREFIX 0xCB |
CALL Z, nn |
CALL nn |
ADC A, n |
RST 0x08 |
D |
RET NC |
POP DE |
JP NC, nn |
OUT (n), A |
CALL NC, nn |
PUSH DE |
SUB A, n |
RST 0x10 |
RET C |
EXX |
JP C, nn |
IN A, n |
CALL C, nn |
PREFIX 0xDD |
SBC A, n |
RST 0x18 |
E |
RET PO |
POP HL |
JP PO, nn |
EX (SP), HL |
CALL PO, nn |
PUSH HL |
AND A, n |
RST 0x20 |
RET PE |
JP (HL) |
JP PE, nn |
EX DE, HL |
CALL PE, nn |
PREFIX 0xED |
XOR A, n |
RST 0x28 |
F |
RET NS |
POP AF |
JP NS, nn |
DI |
CALL NS, nn |
PUSH AF |
OR A, n |
RST 0x30 |
RET S |
LD SP, HL |
JP S, nn |
EI |
CALL S, nn |
PREFIX 0xFD |
CP A, n |
RST 0x38 |
FD OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
NOP |
LD BC, nn |
LD (BC), A |
INC BC |
INC B |
DEC B |
LD B, n |
RLCA |
EX AF, AF' |
ADD IY, BC |
LD A, (BC) |
DEC BC |
INC C |
DEC C |
LD C, n |
RRCA |
1 |
DJNZ e |
LD DE, nn |
LD (DE), A |
INC DE |
INC D |
DEC D |
LD D, n |
RLA |
JR e |
ADD IY, DE |
LD A, (DE) |
DEC DE |
INC E |
DEC E |
LD E, n |
RRA |
2 |
JR NZ, e |
LD IY, nn |
LD (nn), IY |
INC IY |
INC IYh |
DEC IYh |
LD IYh, n |
DAA |
JR Z, e |
ADD IY, IY |
LD IY, (nn) |
DEC IY |
INC IYl |
DEC IYl |
LD IYl, n |
CPL |
3 |
JR NC, e |
LD SP, nn |
LD (nn), A |
INC SP |
INC (IY + d) |
DEC (IY + d) |
LD (IY + d), n |
SCF |
JR C, e |
ADD IY, SP |
LD A, (nn) |
DEC SP |
INC A |
DEC A |
LD A, n |
CCF |
4 |
LD B, B |
LD B, C |
LD B, D |
LD B, E |
LD B, IYh |
LD B, IYl |
LD B, (IY + d) |
LD B, A |
LD C, B |
LD C, C |
LD C, D |
LD C, E |
LD C, IYh |
LD C, IYl |
LD C, (IY + d) |
LD C, A |
5 |
LD D, B |
LD D, C |
LD D, D |
LD D, E |
LD D, IYh |
LD D, IYl |
LD D, (IY + d) |
LD D, A |
LD E, B |
LD E, C |
LD E, D |
LD E, E |
LD E, IYh |
LD E, IYl |
LD E, (IY + d) |
LD E, A |
6 |
LD IYh, B |
LD IYh, C |
LD IYh, D |
LD IYh, E |
LD IYh, IYh |
LD IYh, IYl |
LD H, (IY + d) |
LD IYh, A |
LD IYl, B |
LD IYl, C |
LD IYl, D |
LD IYl, E |
LD IYl, IYh |
LD IYl, IYl |
LD L, (IY + d) |
LD IYl, A |
7 |
LD (IY + d), B |
LD (IY + d), C |
LD (IY + d), D |
LD (IY + d), E |
LD (IY + d), H |
LD (IY + d), L |
HALT |
LD (IY + d), A |
LD A, B |
LD A, C |
LD A, D |
LD A, E |
LD A, IYh |
LD A, IYl |
LD A, (IY + d) |
LD A, A |
8 |
ADD A, B |
ADD A, C |
ADD A, D |
ADD A, E |
ADD A, IYh |
ADD A, IYl |
ADD A, (IY + d) |
ADD A, A |
ADC A, B |
ADC A, C |
ADC A, D |
ADC A, E |
ADC A, IYh |
ADC A, IYl |
ADC A, (IY + d) |
ADC A, A |
9 |
SUB A, B |
SUB A, C |
SUB A, D |
SUB A, E |
SUB A, IYh |
SUB A, IYl |
SUB A, (IY + d) |
SUB A, A |
SBC A, B |
SBC A, C |
SBC A, D |
SBC A, E |
SBC A, IYh |
SBC A, IYl |
SBC A, (IY + d) |
SBC A, A |
A |
AND A, B |
AND A, C |
AND A, D |
AND A, E |
AND A, IYh |
AND A, IYl |
AND A, (IY + d) |
AND A, A |
XOR A, B |
XOR A, C |
XOR A, D |
XOR A, E |
XOR A, IYh |
XOR A, IYl |
XOR A, (IY + d) |
XOR A, A |
B |
OR A, B |
OR A, C |
OR A, D |
OR A, E |
OR A, IYh |
OR A, IYl |
OR A, (IY + d) |
OR A, A |
CP A, B |
CP A, C |
CP A, D |
CP A, E |
CP A, IYh |
CP A, IYl |
CP A, (IY + d) |
CP A, A |
C |
RET NZ |
POP BC |
JP NZ, nn |
JP nn |
CALL NZ, nn |
PUSH BC |
ADD A, n |
RST 0x00 |
RET Z |
RET |
JP Z, nn |
PREFIX 0xFDCB |
CALL Z, nn |
CALL nn |
ADC A, n |
RST 0x08 |
D |
RET NC |
POP DE |
JP NC, nn |
OUT (n), A |
CALL NC, nn |
PUSH DE |
SUB A, n |
RST 0x10 |
RET C |
EXX |
JP C, nn |
IN A, n |
CALL C, nn |
PREFIX 0xDD |
SBC A, n |
RST 0x18 |
E |
RET PO |
POP IY |
JP PO, nn |
EX (SP), IY |
CALL PO, nn |
PUSH IY |
AND A, n |
RST 0x20 |
RET PE |
JP (IY) |
JP PE, nn |
EX DE, HL |
CALL PE, nn |
PREFIX 0xED |
XOR A, n |
RST 0x28 |
F |
RET NS |
POP AF |
JP NS, nn |
DI |
CALL NS, nn |
PUSH AF |
OR A, n |
RST 0x30 |
RET S |
LD SP, IY |
JP S, nn |
EI |
CALL S, nn |
PREFIX 0xFD |
CP A, n |
RST 0x38 |
FDCB OpCodes
|
0 |
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
A |
B |
C |
D |
E |
F |
0 |
RLC (IY + d), B |
RLC (IY + d), C |
RLC (IY + d), D |
RLC (IY + d), E |
RLC (IY + d), H |
RLC (IY + d), L |
RLC (IY + d) |
RLC (IY + d), A |
RRC (IY + d), B |
RRC (IY + d), C |
RRC (IY + d), D |
RRC (IY + d), E |
RRC (IY + d), H |
RRC (IY + d), L |
RRC (IY + d) |
RRC (IY + d), A |
1 |
RL (IY + d), B |
RL (IY + d), C |
RL (IY + d), D |
RL (IY + d), E |
RL (IY + d), H |
RL (IY + d), L |
RL (IY + d) |
RL (IY + d), A |
RR (IY + d), B |
RR (IY + d), C |
RR (IY + d), D |
RR (IY + d), E |
RR (IY + d), H |
RR (IY + d), L |
RR (IY + d) |
RR (IY + d), A |
2 |
SLA (IY + d), B |
SLA (IY + d), C |
SLA (IY + d), D |
SLA (IY + d), E |
SLA (IY + d), H |
SLA (IY + d), L |
SLA (IY + d) |
SLA (IY + d), A |
SRA (IY + d), B |
SRA (IY + d), C |
SRA (IY + d), D |
SRA (IY + d), E |
SRA (IY + d), H |
SRA (IY + d), L |
SRA (IY + d) |
SRA (IY + d), A |
3 |
SLL (IY + d), B |
SLL (IY + d), C |
SLL (IY + d), D |
SLL (IY + d), E |
SLL (IY + d), H |
SLL (IY + d), L |
SLL (IY + d) |
SLL (IY + d), A |
SRL (IY + d), B |
SRL (IY + d), C |
SRL (IY + d), D |
SRL (IY + d), E |
SRL (IY + d), H |
SRL (IY + d), L |
SRL (IY + d) |
SRL (IY + d), A |
4 |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 0, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
BIT 1, (IY + d) |
5 |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 2, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
BIT 3, (IY + d) |
6 |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 4, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
BIT 5, (IY + d) |
7 |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 6, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
BIT 7, (IY + d) |
8 |
RES 0, (IY + d), B |
RES 0, (IY + d), C |
RES 0, (IY + d), D |
RES 0, (IY + d), E |
RES 0, (IY + d), H |
RES 0, (IY + d), L |
RES 0, (IY + d) |
RES 0, (IY + d), A |
RES 1, (IY + d), B |
RES 1, (IY + d), C |
RES 1, (IY + d), D |
RES 1, (IY + d), E |
RES 1, (IY + d), H |
RES 1, (IY + d), L |
RES 1, (IY + d) |
RES 1, (IY + d), A |
9 |
RES 2, (IY + d), B |
RES 2, (IY + d), C |
RES 2, (IY + d), D |
RES 2, (IY + d), E |
RES 2, (IY + d), H |
RES 2, (IY + d), L |
RES 2, (IY + d) |
RES 2, (IY + d), A |
RES 3, (IY + d), B |
RES 3, (IY + d), C |
RES 3, (IY + d), D |
RES 3, (IY + d), E |
RES 3, (IY + d), H |
RES 3, (IY + d), L |
RES 3, (IY + d) |
RES 3, (IY + d), A |
A |
RES 4, (IY + d), B |
RES 4, (IY + d), C |
RES 4, (IY + d), D |
RES 4, (IY + d), E |
RES 4, (IY + d), H |
RES 4, (IY + d), L |
RES 4, (IY + d) |
RES 4, (IY + d), A |
RES 5, (IY + d), B |
RES 5, (IY + d), C |
RES 5, (IY + d), D |
RES 5, (IY + d), E |
RES 5, (IY + d), H |
RES 5, (IY + d), L |
RES 5, (IY + d) |
RES 5, (IY + d), A |
B |
RES 6, (IY + d), B |
RES 6, (IY + d), C |
RES 6, (IY + d), D |
RES 6, (IY + d), E |
RES 6, (IY + d), H |
RES 6, (IY + d), L |
RES 6, (IY + d) |
RES 6, (IY + d), A |
RES 7, (IY + d), B |
RES 7, (IY + d), C |
RES 7, (IY + d), D |
RES 7, (IY + d), E |
RES 7, (IY + d), H |
RES 7, (IY + d), L |
RES 7, (IY + d) |
RES 7, (IY + d), A |
C |
SET 0, (IY + d), B |
SET 0, (IY + d), C |
SET 0, (IY + d), D |
SET 0, (IY + d), E |
SET 0, (IY + d), H |
SET 0, (IY + d), L |
SET 0, (IY + d) |
SET 0, (IY + d), A |
SET 1, (IY + d), B |
SET 1, (IY + d), C |
SET 1, (IY + d), D |
SET 1, (IY + d), E |
SET 1, (IY + d), H |
SET 1, (IY + d), L |
SET 1, (IY + d) |
SET 1, (IY + d), A |
D |
SET 2, (IY + d), B |
SET 2, (IY + d), C |
SET 2, (IY + d), D |
SET 2, (IY + d), E |
SET 2, (IY + d), H |
SET 2, (IY + d), L |
SET 2, (IY + d) |
SET 2, (IY + d), A |
SET 3, (IY + d), B |
SET 3, (IY + d), C |
SET 3, (IY + d), D |
SET 3, (IY + d), E |
SET 3, (IY + d), H |
SET 3, (IY + d), L |
SET 3, (IY + d) |
SET 3, (IY + d), A |
E |
SET 4, (IY + d), B |
SET 4, (IY + d), C |
SET 4, (IY + d), D |
SET 4, (IY + d), E |
SET 4, (IY + d), H |
SET 4, (IY + d), L |
SET 4, (IY + d) |
SET 4, (IY + d), A |
SET 5, (IY + d), B |
SET 5, (IY + d), C |
SET 5, (IY + d), D |
SET 5, (IY + d), E |
SET 5, (IY + d), H |
SET 5, (IY + d), L |
SET 5, (IY + d) |
SET 5, (IY + d), A |
F |
SET 6, (IY + d), B |
SET 6, (IY + d), C |
SET 6, (IY + d), D |
SET 6, (IY + d), E |
SET 6, (IY + d), H |
SET 6, (IY + d), L |
SET 6, (IY + d) |
SET 6, (IY + d), A |
SET 7, (IY + d), B |
SET 7, (IY + d), C |
SET 7, (IY + d), D |
SET 7, (IY + d), E |
SET 7, (IY + d), H |
SET 7, (IY + d), L |
SET 7, (IY + d) |
SET 7, (IY + d), A |