After the first 4 values, they get put on the stack and you have to copy them off. But first you have to save the value of any registers above r3 that you might overwrite!
It's all getting quite complicated by that point.
Accessing the JsVars from assembler is going to be really difficult too I'm afraid - I wouldn't advise it. For now it's probably best just to call with:
for(var i in a) adder(a[i]);
Annoyingly map and forEach don't work on Typed Arrays. I'm quite tempted to add support though :/
EDIT: It's been pointed out to me that you can re-purpose the existing map function:
[].forEach.call(a, adder);
This won't work in 1v60, but I've just fixed map/forEach so that they will work on the latest build (or when 1v61 comes out). Note that map will create an old-style array from the result, so you'll run out of memory pretty quickly. forEach is fine though.
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.
After the first 4 values, they get put on the stack and you have to copy them off. But first you have to save the value of any registers above r3 that you might overwrite!
It's all getting quite complicated by that point.
Accessing the JsVars from assembler is going to be really difficult too I'm afraid - I wouldn't advise it. For now it's probably best just to call with:
Annoyingly
map
andforEach
don't work on Typed Arrays. I'm quite tempted to add support though :/EDIT: It's been pointed out to me that you can re-purpose the existing map function:
This won't work in 1v60, but I've just fixed
map/forEach
so that they will work on the latest build (or when 1v61 comes out). Note thatmap
will create an old-style array from the result, so you'll run out of memory pretty quickly.forEach
is fine though.