Testing WebAssembly Studio online tool.

You can test your WebAssembly skills by using the WebAssembly Studio online tool.
First, JavaScript doesn’t support int64 yet, a signature with int64 in wasm can’t be exported to JS.
This means I will use only 32 support with JavaScript.
If you open this online tool will see this:

  1. this area will start the project;
  2. this area will store all project files;
  3. this area is for logs;
  4. this area will come with all tool (like Build, Run, Build & Run);
  5. in this area you can follow the result;

Using one Empty Wat Project will create all files to start using the WebAssembly project.
This project will come with these files: main.html, main.js, main.wat, and main.wasm.
All this file will create an output for a function add.
This function will return the result into id named container.
Anyway, I will show you how to make changes into this source code file to create another id and add a different function named sub.
Let’s see the source code for these files:
First, main.html will have two ids and this source code:

The next file is main.js and will come with this source code:

The result of this function: add and sub,  will be put into div_add and div_sub.
The next source code is main.wat:

The wat file type will solve the functions: add and sub.
One good documentation about these files can be found here.
The last source code is main.wasm:

Use Build and Run buttons to run the example:
The result will show you: 10 8.
The WebAssembly is more complex that in this example, but can be used.
The syntax of WebAssembly’s tree is flat, mostly consisting of lists of instructions…

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.