• Wow, thanks for this - that's an awesome bit of work!

    As far as I know you're the first person that's used E.asm for serious work. Just wondering:

    • Which instructions did you try that weren't there - strh/ldrh? any others I should add?
    • Now there's support for multiline 'templated' strings, I could support that in the IDE, which would probably make using the assembler a lot more pleasant.

    Also, I just added ~ to the compiler, and fixed another issue (it wasn't inlining the peek/poke because it wasn't sure the address was an integer).

    You initial code:

    function rclr2(addr,mask){    
      "compiled";
      poke32( addr, peek32(addr) & ~mask);
    }
    

    Should be much better now. However it's not perfect because the argument still comes in as a JsVar and has to be converted in the code each time it's used.

    This one's very slightly better, but again not great.

    function rclr2(addr,mask){    
      "compiled";
      var a = 0|addr;
      poke32( a, peek32(a) & ~mask);
    }
    

    Honestly if you're happy with writing Assembler then that's definitely best :)

  • ufff - "compiled" is damn fast now. same benchmark as before, but now compiled is even 4ms (~2%) faster than my asm function! seems you implemented some quantum technology ;)

    FYI: the a=0|addr does not improve anything (but when beeing faster than asm, thats ok ;)

  • inlining the peek/poke

    there seems to sit a little bug - this does not work:

    const a = [<address>,<value>];
    poke32( a[0], a[1]);
    

    this is fine:

    const a = [<address>,<value>];
    const x= a[0];
    const y= a[1];
    poke32( x,y);
    

    this is fine, too:

    const a = [<address>,<value>];
    poke32( a[0]|0,a[1]|0);
    

    another - similar? - flaw i have seen:

    const SPI_CR2_TXDMAEN	= 0x0002;
    function rset16( addr, mask){
      "compiled";
      console.log( addr.toString(16), mask.toString(16)); // debug output
      poke16( addr, peek16( addr) | mask);
    }
    function foo( qctl, buf_ptr, byte_cnt) {
        "compiled";
      const SPI_CR1= ...;
       ...
        rset16( SPI_CR1+4, SPI_CR2_TXDMAEN);
    }  
    
    

    generates this output: 40013004 [object Object]

    expected output: 40013004 2

    to achieve the expected behaviour, i have either to

    • remove "compiled" directive from foo, or
    • do rset16( SPI_CR1+4, SPI_CR2_TXDMAEN|0);
About

Avatar for Gordon @Gordon started