You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Is now a reality! (As of 1v60, or git commit a92ea2e529588c6f86cf268ff227438167052843­)

    addr = process.memory().stackEndAddress;
    
    [0xb480,0xb083,0xaf00,0x6078,
     0x687b,0xf103,0x0302,0x4618,
     0xf107,0x070c,0x46bd,0xbc80,
     0x4770,0xbf00].forEach(function(v,a) { poke16(addr+a*2,v); });
    a = E.nativeCall(addr+1, "long (long)");
    

    The code above is just copy/pasted out of an object file generated by GCC. It takes a 64 bit int and adds 2 to it.

    The function a that got created can be used just like any normal function:

    >a(0) 
    =2
    >[1,2,3,4].map(a)
    =[3,4,5,6]
    

    So who wants to make a Thumb assembler written in JavaScript? :) Could be a fun project...

    I actually got TCC (the Tiny C compiler) compiled into JavaScript with Emscriptem (so it could have run on the Web IDE), but unfortunately I can't get the code it produces to run on the Cortex M3.

About

Avatar for Gordon @Gordon started