-
• #2
Sun 2018.10.07
Well, it is amazing how a fresh look at things may solve an issue.
It was the second example as I expected it should be
int nRGBCur = *(datasrc+i); *(datadest++) = *(datag+nRGBCur);
The issue was option base one rather than zero, which made the size of the array one too large. Amazing what happens when one marches off the end of an array by one byte!!
-
• #3
Off by one, the rue of existence ...
-
• #4
@Robin, you may take a look at the https://www.espruino.com/Internals page that talks about variables and memory layout - and btw, there you also find how ESPRUINO JavaScript is processed: Parser (regarding 'byte code' mentioned in a different conversation of yours. Conversation about memory usage (google for Espruino Internals Variables, Memory, Storage) are a good information source as well.
There are certain types of objects - pointed to by variables - that have all their bytes as ducks in a row, where others have them in units of a few daisy chained - latter was first and only way Espruino handled memory for a long time, until performance hit the ceiling, mainly by trying to drive these colored RGB LED strips, and it was not enough, so the module became built-in natively implemented...
Looking at the interpreter's source may help you as well with understanding to take advantage of your C desires and skills..
Sat 2018.10.06
Not strong enough with Espruino debugger to solve this, as my pointer offsets appear to be the culprits
Trying to convert this working code block to inlineC
Leaving out the overhead ex:
Have tried
and
but both corrupt memory as can be seen by viewing 'this' and instantiated variable contents in IDE console.
My belief is the arrangement of the JSVars in memory, thus the offsets are off. e.g. what the pointers point to
I am able to walk the array one element at a time in succession (not what I'm after)
I understand the pointer points to the address and the address value is incremented to the next higher address.
What I need is the pointer points to the address and the address is incremented to an offset into that array at that address.
Any insight greatly appreciated.