Skip to content

Instantly share code, notes, and snippets.

@gabrielschulhof
Created April 25, 2017 07:58
Show Gist options
  • Save gabrielschulhof/a4dc3dfd17b2df55c1129634ff2febbc to your computer and use it in GitHub Desktop.
Save gabrielschulhof/a4dc3dfd17b2df55c1129634ff2febbc to your computer and use it in GitHub Desktop.
if ( process.argv.length < 3 ) {
console.error( "Need an argument" );
process.exit( 1 );
}
var the_string = process.argv[ 2 ];
var index;
console.log(
"set $the_string = (char *)jmem_heap_alloc_block(" + ( the_string.length + 1 ) + ")" );
console.log( "call memset($the_string, 0, " + ( the_string.length + 1 ) + ")" );
for (index = 0; index < the_string.length; index++) {
console.log( "set $the_string[" + index + "] = '" + the_string[index] + "'" );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment