mul_wide_u: Wasm numeric instruction

The mul_wide_u numeric instruction multiplies two unsigned 64-bit integers to produce an unsigned 128-bit result represented by two 64-bit integers.

Try it

(module
  (import "console" "log" (func $log (param i64)))
  (func $main

    i64.const 123456789012345
    i64.const 123456789070
    i64.mul_wide_u
    call $log ;; log high 64 bits
    call $log ;; log low 64 bits
  )
  (start $main)
)
const url = "{%wasm-url%}";
await WebAssembly.instantiateStreaming(fetch(url), { console });

WAT syntax

i64.mul_wide_u
i64.mul_wide_u

The i64.mul_wide_u instruction.

Immediates

None.

Operand stack

[input1:i64 input2:i64] -> [low_output:i64 high_output:i64]
input1

The first i64 input.

input2

The second i64 input.

low_output

An i64 representing the low 64 bits of the result.

high_output

An i64 representing the high 64 bits of the result.

Binary encoding

Instruction Binary format Example text => binary
i64.mul_wide_u 0xfc 22:u32 i64.mul_wide_u => 0xfc 0x16

Description

The mul_wide_u instruction multiplies two unsigned i64 values together to produce an unsigned 128-bit result represented by a pair of i64 values.

This is one of the wide arithmetic operations, which are useful in situations where larger-than-64-bit numbers are being used in source languages with Wasm as a compile target. One such example is cryptographic algorithms.

These methods allow engines to generate more performant machine code for these operations than is possible with i64 arithmetic operations.

Specifications

Specification
Unknown specification
# :~:text=i64%2Emul%5Fwide%5Fu

Browser compatibility

See also