News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Anybody here has some experience with WebAssembly?

Started by UniverseIsASimulation, September 04, 2020, 04:44:44 AM

Previous topic - Next topic

UniverseIsASimulation

Does anybody here have some experience with WebAssembly? If so, what do you think about it?
I have made a compiler for my programming language targeting WebAssembly, and ported some programs in my programming language to web using it: https://flatassembler.github.io/analogClock.html
One of the weirdest problems I've faced with when targeting WebAssembly is that WebAssembly doesn't allow you to call a function that returns something and simply do nothing with the result. x86 assembly (and I think most assembly languages) allows you to do stuff like that without problems, and it was hard for me to figure out what was going on.
Author of the AEC programming language:
https://flatassembler.github.io/compiler.html

hutch--

Are you trying to read "eax" in 32 bit or "rax" in 64 bit as the return value ? Another common method is to pass the address of a variable or structure and write to it within the procedure you are calling.

HSE

Quote from: hutch-- on September 04, 2020, 05:14:02 AM
Another common method is to pass the address of a variable or structure and write to it within the procedure you are calling.

And, because all the thing is C++ based, that address is the first function argument.
Equations in Assembly: SmplMath

UniverseIsASimulation

Quote from: hutch-- on September 04, 2020, 05:14:02 AM
Are you trying to read "eax" in 32 bit or "rax" in 64 bit as the return value ? Another common method is to pass the address of a variable or structure and write to it within the procedure you are calling.
I mean, one of the biggest (and most confusing) differences between x86 Assembly and WebAssembly is that, in x86 Assembly, if you, immediately after calling one function that returns something in eax, call another function, x86 Assembly doesn't complain. WebAssembly, on the other hand, complains you didn't check the result in eax before calling that other function.
Author of the AEC programming language:
https://flatassembler.github.io/compiler.html

hutch--

Then WebAssembly needs to adapt to how the processor hardware works. You can routinely call procedures that don't return any value at all and if it returns something in eax, it can routinely be ignored if you don't need the result.