memory.init
Copy data from a passive (data...) object into memory. You can have any number of passive data blocks that contain constant data. The data they contain can be copied into memory when required and to any location.

Syntax

memory.init $passiveData

Parameters

$passiveData
This points to a passive (data...) object where the data is to be copied from.

Stack In

i32 The offset in memory to copy the data to.
i32 The offset in the passive data to copy the data from.
i32 The number of bytes to copy.

Stack Out

NONE

Example

;; Create memory
(memory 1)

;; Create passive data
(data $passiveData "Hello World")

;; Create function
(func $copyPassiveData
  ;; Set the offset within memory to copy the data to
  i32.const 1024

  ;; Set the offset within the passive data to copy the data from
  i32.const 0

  ;; Set the number of bytes to copy
  i32.const 11

  ;; Copy the passive data into memory
  memory.init $passiveData

  ;; Memory now contains the "Hello World" text
)