Author Topic: Anybody here has some experience with WebAssembly?  (Read 222 times)

UniverseIsASimulation

  • Regular Member
  • *
  • Posts: 29
    • Teo Samaržija's Homepage
Anybody here has some experience with WebAssembly?
« on: September 04, 2020, 04:44:44 AM »
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--

  • Administrator
  • Member
  • ******
  • Posts: 7608
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Anybody here has some experience with WebAssembly?
« Reply #1 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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

HSE

  • Member
  • *****
  • Posts: 1404
  • <AMD>< 7-32>
Re: Anybody here has some experience with WebAssembly?
« Reply #2 on: September 04, 2020, 07:02:52 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.

UniverseIsASimulation

  • Regular Member
  • *
  • Posts: 29
    • Teo Samaržija's Homepage
Re: Anybody here has some experience with WebAssembly?
« Reply #3 on: September 05, 2020, 12:32:54 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--

  • Administrator
  • Member
  • ******
  • Posts: 7608
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Anybody here has some experience with WebAssembly?
« Reply #4 on: September 05, 2020, 12:40:01 AM »
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.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

TouEnMasm

  • Member
  • *****
  • Posts: 1395
    • EditMasm
Re: Anybody here has some experience with WebAssembly?
« Reply #5 on: September 05, 2020, 03:22:58 AM »
Fa is a musical note to play with CL