• Thanks @Wilberforce the up arrow in left pane more than once did the trick.

    @Gordon in a previous post suggested this example:

    var adder = E.asm("int(int)",
    "movs r1, #3",
    "adds r0, r0, r1", // add two 32 bit values
    "bx lr"); // return
    
    

    Gives var adder = E.nativeCall(1, "int(int)", atob("AyFAGHBH"))
    and you can just use atob("AyFAGHBH"):

    The "AyFAGHBH" is the 64 bit encoded version of the code.
    The atob function converts it to a flat string with escaped characters.
    The btoa function creates a 64 bit encoded string.

    Some confusion about where to poke the string.
    @Gordon suggested before the stack end address

    var data = atob("AyFAGHBH");
    var addr = process.memory().stackEndAddress-data.length;
    poke8(addr
    
    

    The assembler page suggests after the stack end address.
    http://www.espruino.com/Assembler

    var ASM_BASE=process.memory().stackEndAddress;
    var ASM_BASE1=ASM_BASE+1/*thumb*/;
    [0x4a02,0xf44f,0x4360,0x6013,0x6053,0x4770,0x0810,0x4001].forEach(function(v) { poke16((ASM_BASE+=2)-2,v); }); 
    var pulse = E.nativeCall(ASM_BASE1, "void()")
    
    

    So I’ve tried it both ways and both crash.

    var data = atob("AyFAGHBH");
    //var addr = process.memory().stackEndAddress-data.length;
    var addr = process.memory().stackEndAddress+1;
    for(var i=0;i<data.length;i++){
    poke8(addr+i,data.charCodeAt(i));
    console.log((addr+i).toString(16)+","+peek8(addr+i).toString(16));
    }
    
    var adder = E.nativeCall(1, "int(int)", atob("AyFAGHBH"));
    //var adder= E.nativeCall(addr, "int(int)");
    
    console.log(adder(2));
    
    

    Which displays

    >echo(0);
    20009b3d,3
    20009b3e,21
    20009b3f,40
    20009b40,18
    20009b41,70
    20009b42,47
    5
    =undefined
    >
    
    
About