Guest User

Untitled

a guest
Oct 21st, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <stdint.h>
  2.  
  3. uint8_t buff[10][100];
  4.  
  5. uint64_t addr(int buffer_index){
  6. return (uint64_t)&buff[buffer_index];
  7. }
  8.  
  9. emcc project.c -Os -s WASM=1 -s SIDE_MODULE=1 -o project.wasm
  10.  
  11. <script>
  12. var importObject = {
  13. env: {
  14. memoryBase: 0,
  15. tableBase: 0,
  16. setTempRet0:(x)=>{},
  17. memory: new WebAssembly.Memory({ initial:256 }),
  18. table: new WebAssembly.Table({ initial:0, element:'anyfunc' })
  19. }
  20. };
  21.  
  22. fetch('http://localhost:9000/assets/wasm/project.wasm').then(
  23. response => response.arrayBuffer()
  24. ).then(
  25. bytes => WebAssembly.instantiate(bytes, importObject)
  26. ).then(
  27. results => {
  28. let module=results.instance
  29. let exports=module.exports
  30. let addr=exports._addr
  31. console.log(addr(0))
  32. console.log(addr(1))
  33. console.log(addr(2))
  34. }
  35. )
  36. </script>
  37.  
  38. project.html:21 5242880
  39. project.html:22 5242980
  40. project.html:23 5243080
Add Comment
Please, Sign In to add comment