Home | Notifications | New Note | Local | Federated | Search | Logout
Note Detail
Reply to @mcc@mastodon.social
mcc@mcc@mastodon.social (2025-06-04 08:51:44)
Due to the byte nonsense, and it turning out there's no cross-compatible way to do a "print" statement that works in both WASI and browser WASM, I sought an impractical but effective solution: I wrote a Wasm preprocessor.
https://github.com/mcclure/aoc2024/blob/6f8ca110b931558a42826f8257996e53010e555f/11-01-stones/tools/prep.py
Or rather I wrote a very simple, C-like preprocessor that uses ;; wasm comment indicators instead of #, in 200 lines of python, which I expect I can usefully adapt to other asms someday later. It knows how to do the wasm byte string packing.
---Attachments---
image: https://files.mastodon.social/media_attachments/files/114/622/114/011/359/671/original/c9a725cbf782847f.png
---Reply---
mcc@mcc@mastodon.social (2025-06-04 08:57:44)
So now I can like… actually start on this part of the project. What I'm running into immediately is some confusion over the nature of memory. Okay, so what's been repeatedly claimed to me is "memory" to a wasm program is a single linear space that can be grown but not shrunk. But then I've got a stack. Is the stack in linear memory? Can I take pointers to it? Then there's (memory), which I think refers to buffers shared with FFI languages. Is this in the linear memory? Can I take pointers to it?
Reply
---Replies---
mcc@mcc@mastodon.social (2025-06-04 08:59:18)
I imagine the above would be explained if I read the spec rather than just blog-style summaries of the spec, but there is a problem with that, which is that the spec is on my laptop, and writing these posts while trying to power my phone which is providing the internet via USB on this bus has drained my laptop battery, to the point where I probably have to s