Home | Notifications | New Note | Local | Federated | Search | Logout

Note Detail


Reply to @mcc@mastodon.social
mcc@mcc@mastodon.social (2026-10-02 03:05:07)
Hey wasm question. I understand the stack in wasm is not there because they wanted to write a stack language, it's there because someone at Sun found a very good register allocation algorithm that works best if your bytecode targets a stack machine.

But are there… ANY stack ops? Like access to a DUP would be *so* helpful right now.

I see "local.tee" but that's about it. I'm looking at the Mozilla reference tho (it's… a LOT easier to navigate than the html spec) which I'm not sure is complete.
---Reply--- mcc@mcc@mastodon.social (2026-10-02 12:13:35) Alright! That… wasn't so hard!

https://github.com/mcclure/aoc2024/blob/7f6e479c88bcb251bf8fbb7b716da0660c787be2/11-01-stones/src/puzzle.wast

Friendlier than a lot of ASMs, and everything *un*friendly stems from tool ugliness (lack of step debugger; I wound up not using any of the neat LISP argument nesting or parens-optional features bc they broke too easily). After 16 months of being stuck on building WAST at all I wrote the whole "part 1" program in one day.

It doesn't work on the actual puzzle input because I wrote it around u32s and the assigned input needs u64s. FRICKING
Reply

---Replies---
mcc@mcc@mastodon.social (2026-10-02 12:18:29)
Behold my angonies. I guess at least it's a good thing I anticipated overflow might happen and checked for it, instead of just letting it happen and generating an incorrect result?
---Attachments---
image: https://files.mastodon.social/media_attachments/files/117/369/146/272/749/516/original/61427b5ab565df97.png