SimpleIDE Cogc and Arrays
greybeard
Posts: 65
in Propeller 1
I would LIKE to use an array in a cog using a .COGC file and have the values stored in the cog for rapid access. The normal way is to declare the array with something like int Tmp[10]; Unfortunately, this type of declaration causes the array to be stored in the HUB and results in numerous rd/wrlong instructions that takes many clock cycles to retrieve each value. Doesn't make for efficient code. Applying the _COGMEM attribute to the declaration generates an error message that the variable is not suitable to a single register. I have tried to initialize a contiguous set of values using the _COGMEM attribute then take the address of the first one but the compiler complains that a HUB variable is required. (NOTE: I realize the compiler may not store them as contiguous values I didn't get to the point that would be a problem).
Anyone have a suggestion for using a SimpleIDE .COGC file with data arrays where the array is stored in the Cog??
Anyone have a suggestion for using a SimpleIDE .COGC file with data arrays where the array is stored in the Cog??
Comments
I'm not familiar with the process but can learn. I was trying to get away from using assembly and stick with the C syntax.
Thanks.
1) Arrays are all about eating space with data. There is precious little space in COG.
2) Accessing arrays in COG can be done with self-modifying code. But then the overheads of doing that mean that using [RD,WR][BYTE, WORD, LONG] is about as quick. Especially if your array is actually bytes or words, which means you need to do shift/mask operations and such to get what you want.
3) Like 2) but the code size overhead is intolerable.
All in all, keep arrays in HUB.