Skip to content

Krumuvecis-tests/wastest

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Web assembly test

Abstract

Testing web assembly

Usage

Due to some security concerns, modern browsers don't allow running WebAssembly files directly from local directories. If you do try to run them this way, it'll result in CORS or MIME errors.

Some sort of HTTP server has to be set up. There are many possible options, but I'm using PHP on Windows 10:

  1. Install PHP:
    1. Download PHP here (version 5.4 or later);
    2. Set Environment Path variable (restart not needed);
    3. Run cmd.exe and verify success with php -v.
  2. Run cmd.exe and navigate to the desired directory (wastest for this project);
  3. Start the server by php -S localhost:8000;
    • change localhost to a preferred IP, if needed;
    • change 8000 to a preferred port number, if needed;
    • stop the server with Ctrl+C, when done.
  4. Open your favorite browser and go to localhost:8000.

Development

General order: wat -> wabt -> wasm

WebAssembly text format (.wat) converted to WebAssembly binary format (.wasm) using WebAssembly Binary Toolkit.

For now, I'm using an online demo. There is a button Download on upper-left panel for downloading the binary .wasm file.

Don't just copy-paste resulting binary data to a text file - it won't work (firstly, the magic number won't match).

You can check the binary with a binary/hex editor. I'm using a free open-sorce hex editor Frhed (portable - doesn't need to be installed).

Notes

Free to use and modify for whatever purposes. No copyrights apply.

Work in progress, expect changes...