Skip to content

Instantly share code, notes, and snippets.

@kripken
Last active December 3, 2015 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kripken/910bfe8524bdaeb7df9a to your computer and use it in GitHub Desktop.
Save kripken/910bfe8524bdaeb7df9a to your computer and use it in GitHub Desktop.
extern void some_external_JS(int);
int main() {
some_external_JS(42);
}
global.Module = {};
global.print = console.log;
require('./a.asm.js'); // evals the script
var asm = global.Module['asm'](global, {
_some_external_JS: function(x) {
print('hello, some_external_JS was called with ' + x);
},
}, new ArrayBuffer(1024*1024));
asm._main();
emcc main.c -o a.html --separate-asm -s NO_FILESYSTEM=1 -Oz -profiling
# ignore html and js, look at just the a.asm.js
# run main.js
# remove -profiling to reduce code size, but asm is harder to read
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment