Newer
Older
minerva / Base / res / html / misc / wasm.html
@minerva minerva on 13 Jul 973 bytes Initial commit
<html>
    <body>
        <script>
            const bytes = new Uint8Array([
                0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x06, 0x01, 0x60,
                0x01, 0x7f, 0x01, 0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x07, 0x01, 0x03,
                0x66, 0x69, 0x62, 0x00, 0x00, 0x0a, 0x29, 0x01, 0x27, 0x00, 0x20, 0x00,
                0x41, 0x00, 0x4c, 0x04, 0x40, 0x41, 0x00, 0x0f, 0x0b, 0x20, 0x00, 0x41,
                0x01, 0x46, 0x04, 0x40, 0x41, 0x01, 0x0f, 0x0b, 0x20, 0x00, 0x41, 0x02,
                0x6b, 0x10, 0x00, 0x20, 0x00, 0x41, 0x01, 0x6b, 0x10, 0x00, 0x6a, 0x0b
            ]);
            WebAssembly.compile(bytes)
                .then(module => WebAssembly.instantiate(module))
                .then(instance => instance.exports.fib(10))
                .then(value => console.log("Calculated fib(10) with wasm and got " + value))
                .catch(err => console.log(err.message));
        </script>
    </body>
</html>