private void NEG(ushort operand)
{
ushort value;
RegGeneral destination;
try {
BitPatternALU(operand, out value, out destination);
if (value == 0x8000) {
// negated value of -32768 doesn't fit in 16-bits.
R[(int)destination] = 0x8000;
FL_N = true;
FL_Z = false;
// C [Carry] Not effected.
FL_V = true;
}
else {
int result = 0 - value;
R[(int)destination] = (ushort)(result & 0x0000FFFF);
FL_N = (result & 0x8000) != 0;
FL_Z = result == 0x0000;
// C [Carry] Not effected.
FL_V = false;
}
}
catch (SegFaultException e) {
Interrupt_SegFault(e.SegmentType, operand, e.Address);
}
}