3.2.4 Multiplication and Division
CAVA defines integer multiplication in general-purpose registers
to be precision preserving, meaning that multiplying two
32-bit numbers results in a product containing only the lower
32-bits. This behavior is unlike most other microprocessors, but
is in fact the appropriate behavior for most programming languages.
CAVA has separate instructions for integer division and integer modulo,
as opposed to the more usual arrangement of producing both the quotient
and remainder simultaneously in special registers. Special registers
are very awkward for out-of-order implementations, and producing
more than one result per instruction is really terrible.
An aggressive implementation can always dynamically detect that
the operands of adjacent div and mod are identical
to optimize execution.
Integer Multiplication
| Mnemonic |
Format |
Unit |
Semantics |
Description |
| mul |
bR |
im |
x.j *= y.j |
Multiply |
| mulw |
bR |
im |
x.i *= y.i sex |
Multiply Word |
Integer Division and Modulo
| Mnemonic |
Format |
Unit |
Semantics |
Description |
| div |
bR |
id |
x.j = y.j ? x.j / y.j : 0 |
Divide |
| divw |
bR |
id |
x.i = y.i ? x.i / y.i : 0 sex |
Divide Word |
| divu |
bR |
id |
x.n = y.n ? x.n / y.n : 0 |
Divide Unsigned |
| divuw |
bR |
id |
x.m = y.m ? x.m / y.m : 0 sex |
Divide Unsigned Word |
| mod |
bR |
id |
x.j = y.j ? x.j % y.j : 0 |
Modulo |
| modw |
bR |
id |
x.i = y.i ? x.i % y.i : 0 sex |
Modulo Word |
| modu |
bR |
id |
x.n = y.n ? x.n % y.n : 0 |
Modulo Unsigned |
| moduw |
bR |
id |
x.m = y.m ? x.m % y.m : 0 sex |
Modulo Unsigned Word |