memory.fill
Fill a section of memory with a given byte value. You use an i32 value but only the first 8 bits are used.

Syntax

memory.fill

Stack In

i32 The offset within memory to start filling.
i32 The value to fill the memory with. Only the first 8 bits are used.
i32 The number of bytes to fill.

Stack Out

NONE

Example

;; Create memory 1 page in size and can grow to 2 pages
(memory 1 2)
  
;; Create function
(func $resetMemory
  ;; Set the offset within memory to start filling
  i32.const 0

  ;; Set the value to fill memory with
  i32.const 0x00

  ;; Set the number of bytes to fill
  i32.const 256

  ;; Fill the memory with the data
  memory.fill

  ;; The first 256 bytes of memory are set to 0x00
)