public void Rem(int rd, IEnumerable <byte> rs1Coding, IEnumerable <byte> rs2Coding) { var rs1 = new BigInteger(rs1Coding.ToArray()); var rs2 = new BigInteger(rs2Coding.ToArray()); var result = BigInteger.Remainder(rs1, rs2); ExtensionHelper.WriteToRegister(rd, result, defaultBufferSize, register); Logger.Debug("Rem: {rs1} * {rs2} = {result}", rs1.ToString(), rs2.ToString(), result.ToString()); }
public void Divw(int rd, IEnumerable <byte> rs1Coding, IEnumerable <byte> rs2Coding) { var rs1 = new BigInteger(rs1Coding.ToArray()); var rs2 = new BigInteger(rs2Coding.ToArray()); var result = BigInteger.Divide(rs1, rs2); ExtensionHelper.WriteToRegister(rd, result, 4, register); Logger.Debug("Div: {rs1} * {rs2} = {result}", rs1.ToString(), rs2.ToString(), result.ToString()); }
/// <summary> /// Implements the mul operation /// </summary> /// <param name="rd">the target register</param> /// <param name="rs1Coding">the little endian coding of the rs1</param> /// <param name="rs2Coding">the little endian coding of the rs2</param> public void ExecuteMul(int rd, IEnumerable <byte> rs1Coding, IEnumerable <byte> rs2Coding) { // Compute the result using the BigInteger type var rs1 = new BigInteger(rs1Coding.ToArray()); var rs2 = new BigInteger(rs2Coding.ToArray()); var result = BigInteger.Multiply(rs1, rs2); Logger.Debug("Mul: {rs1} * {rs2} = {result}", rs1.ToString(), rs2.ToString(), result.ToString()); ExtensionHelper.WriteToRegister(rd, result, defaultBufferSize, register); }
/// <summary> /// Implements the Mulh implementation /// </summary> /// <param name="rd"></param> /// <param name="rs1Coding"></param> /// <param name="rs2Coding"></param> public void ExecuteMulh(int rd, IEnumerable <byte> rs1Coding, IEnumerable <byte> rs2Coding) { // Compute the result using the BigInteger type var rs1 = new BigInteger(rs1Coding.ToArray()); var rs2 = new BigInteger(rs2Coding.ToArray()); var result = rs1 * rs2; // Shift the lower part to the right result >>= boundary; Logger.Debug("Mulh: {rs1} * {rs2} = {result} (shifted) ", rs1.ToString(), rs2.ToString(), result.ToString()); ExtensionHelper.WriteToRegister(rd, result, defaultBufferSize, register); }