public ConstValue(string opRand) { if (opRand[0] != '$') { throw new Exception("Wrong argument"); } bool isNegative = false; string tarToken = opRand.Substring(1); if (tarToken[0] == '-') { tarToken = tarToken.Substring(1); isNegative = true; } var absValue = new BitValue(ProcessorModel.BIT_LENGTH, Convert.ToInt32(tarToken, 16)); if (isNegative) { absValue.Negate(); } this.Value = absValue; }
private void MakeNegation() { RegisterName destReg = ((AssemblerCommand.RegName)currentOpRands[0]).Value; BitValue value = new BitValue(Parent.registers[destReg].GetValue()); value.Negate(); Parent.registers[destReg].SetValue(value); ((StatusRegister)Parent.registers[RegisterName.PS]).SetValue(value.IsNegative); }
public int ToInt() { var cpy = new BitValue(this); bool negative = cpy.IsNegative; if (negative) { cpy.Negate(); } int result = 0; for (int i = cpy.value.Length - 1; i >= 0; i--) { result *= 2; result += (cpy.value[i]) ? 1 : 0; } return(result * ((negative) ? -1 : 1)); }