Just to add that in 1v61 you'll be able to use Array.reduce too - which will be extremely useful if you want to do some analysis on an ArrayBuffer with inline assembler.
For instance maybe you want to sum up all the values in an ArrayBuffer...
// effectively function (a,b) { return a+b; }
var adder = E.asm("int(int,int)",
"adds r0, r0, r1",
"bx lr");
// fill up array buffer
var a = new Int16Array(100);
for (var i in a) a[i]=i;
// Call our assembler on every item
var sum = [].reduce.call(a, adder);
console.log(sum); // 4950
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Just to add that in 1v61 you'll be able to use
Array.reduce
too - which will be extremely useful if you want to do some analysis on an ArrayBuffer with inline assembler.For instance maybe you want to sum up all the values in an ArrayBuffer...