1
$\begingroup$

Imagine a machine that can only hold N-bit values (N-bit uint).

The machine can also calculate the 2N-bit result of two operations: mult, exp. The 2N-bit result is stored across 2 N-bit values (high/low bits).

How could we then code the mult (or exp) of 2 2N-bit values that would result in a 4N-bit value? The 2 2N-bit inputs would be stored across 4 N-bit values and the 4N-bit result would be stored across 4 N-bit values as well.

Is there somewhere I can read about the kind mathematical breakdown to code this? Needed for a real world assembly coding.

thx

$\endgroup$
1

1 Answer 1

1
$\begingroup$

For product, here is the idea: $$(2^NA + B)(2^NC + D) = 2^{2N}AC + 2^N(AD+BC) + BD.$$ Exponentiation isn't a primitive operation in integer arithmetic.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.