Difference between revisions of "WebAssembly"

From Lazarus wiki
m (See Also)
m
Line 3: Line 3:
 
The expected format is a slightly different between those two:
 
The expected format is a slightly different between those two:
  
'''wat2wasm''' (Wabt)
+
===wat2wasm (Wabt)===
 +
Example:
 
  (module
 
  (module
 
   (func $add (param $lhs i32) (param $rhs i32) (result i32)
 
   (func $add (param $lhs i32) (param $rhs i32) (result i32)
Line 12: Line 13:
 
   (export "add" (func $add))
 
   (export "add" (func $add))
 
  )
 
  )
 +
According to the official site "Wabt" is using it's own format of the Wasm.
 +
It's slightly different from the official documentation. The most current version of Wabt matches the specs.
  
'''wasm-as''' (emscripten)  
+
Online studio, that's using the older version of wabt syntax. https://webassembly.studio/
 +
 
 +
For example. instead of
 +
memory.size
 +
it's ussing
 +
current_memory
 +
 
 +
===wasm-as (emscripten)===
 +
The assembler is recommended for the use in a compiler by the WebAssembly.org
 
  (module
 
  (module
 
   (func $add (param $lhs i32) (param $rhs i32) (result i32)
 
   (func $add (param $lhs i32) (param $rhs i32) (result i32)

Revision as of 22:03, 30 August 2019

Assemblers

There are different assemblers available, from Wabt and emscripten.org. The expected format is a slightly different between those two:

wat2wasm (Wabt)

Example:

(module
  (func $add (param $lhs i32) (param $rhs i32) (result i32)
    local.get $lhs
    local.get $rhs
    i32.add
  )
  (export "add" (func $add))
)

According to the official site "Wabt" is using it's own format of the Wasm. It's slightly different from the official documentation. The most current version of Wabt matches the specs.

Online studio, that's using the older version of wabt syntax. https://webassembly.studio/

For example. instead of

memory.size

it's ussing

current_memory

wasm-as (emscripten)

The assembler is recommended for the use in a compiler by the WebAssembly.org

(module
  (func $add (param $lhs i32) (param $rhs i32) (result i32)
    (
    local.get $lhs
    local.get $rhs
    i32.add
    )
  )
  (export "add" (func $add))
)

See Also