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

Note Detail


Reply to @mcc@mastodon.social
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

---Reply--- mcc@mcc@mastodon.social (2026-10-02 12:24:59) Maybe I can still get this working tonight, I think. I find-replace all "4"s with "8s" and find-replace all "i32"s with "i64"s.

This doesn't work. Of course it doesn't work! Pointers are 32 bit in wasm32! That's why they call it wasm32! I can't just promiscuously use one integer type for both pointers and values, I'm gonna have to actually think out not only the type of every variable but the type of every arithmetic operation!

I guess this is why people stopped writing assembly language!! ---Attachments--- image: https://files.mastodon.social/media_attachments/files/117/369/174/718/684/710/original/3ec73b8630e7bd45.png
Reply

---Replies---
mcc@mcc@mastodon.social (2026-10-02 21:43:34)
So upthread, I complain that the only integer types in wasm are i32 and i64— no i8, i16 or i1. If you want to store a boolean, you use an i32.

What I didn't realize until just now is bools can *only* be i32. The test operations don't work with i64s—(if) tests if the value on top of the stack is nonzero, but that number must be an i32. If you want to test if an i64 is nonzero you have to toss in an explicit (i64.const 0) (i64.ne). Which I guess makes sense or else you'd need i32.if/i64.if but :|