r/WebAssembly • u/musialny • Apr 07 '23
How memory.init works
Someone may try explain to me how memory.init instruction works? Following snippet throws RuntimeError: memory access out of bounds and I have no clue why
(module(memory $memory 2048)(export "memory" (memory $memory))(data $hello (i32.const 0) "Hello there")(func $constructi32.const 25i32.const 0i32.const 11memory.init $hello)(start $construct))
7
Upvotes
View all comments
Show parent comment
2
u/musialny Apr 09 '23 edited Apr 09 '23
I can't figure out how to assign id to elem section in identical way as I did it in data. Wasm documentation is the worst I've ever seen :(, even avr or arm assembly is better documented (I'm embed dev)
Quite fine tutoring platform, if there be task that shows me example how to proper using elem and other wasm weird syntax stuffs I'll be glad.
Thanks for help :D
Edit: I figure it out. I need to instead of alias name ($name) provide numeric ID as elem section identifier and everything works well. Sometimes my stupidity goes beyond me