public void Compute() { //int iX = InputX.Get2sComplement(), iY = InputY.Get2sComplement(); int iX = InputX.GetValue(), iY = InputY.GetValue(); if (ZeroX.Value == 1) { iX = 0; } if (ZeroY.Value == 1) { iY = 0; } if (NotX.Value == 1) { iX = ~iX; } if (NotY.Value == 1) { iY = ~iY; } int iResult = 0; if (F.Value == 0) { iResult = iX & iY; } else { iResult = iX + iY; } if (NotOutput.Value == 1) { iResult = ~iResult; } Output.SetValue(iResult); //Output.Set2sComplement(iResult); if (iResult == 0) { Zero.Value = 1; } else { Zero.Value = 0; } if (Output.GetValue() < 0) { Negative.Value = 1; } else { Negative.Value = 0; } //Console.WriteLine("ALU state: " + ToString()); }