call

call calls a function. call_indirect calls a function in a table.

Syntax

call $greet

Full working example

Wasm file

(module
  (import "env" "greet" (func $greet))

  (func
    ;; call the greet function
    call $greet
  )

  (start 1) ;; run the first function automatically
)

JavaScript file

WebAssembly.instantiateStreaming(
  fetch("../out/main.wasm"),
  {
    env: {
      greet: function() {
        console.log("Hello");
      }
    }
  }
);
Opcodes
call 0x10
call_indirect 0x11