You are reading a single comment by @mrQ and its replies.
Click here to read the full conversation.
-
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);
- remove "compiled" directive from foo, or
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:strh/ldrh
? any others I should add?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:
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.
Honestly if you're happy with writing Assembler then that's definitely best :)