Memory block transfer
nrandal
Posts: 5
I was attempting to transfer a block of memory values from one cog to another. I was expecting my VAR variables to be kept in order by they are optimized and grouped into similar structure.
Say I was going to transfer 1 long, 2 words and 8 bytes from by source cog to the calling cog, I was hoping to do a longmove(dst, src, 3) but that doesn't work.
Is there a way to force VAR to not reorganize variables in memory? Is there another way I should be doing this?
Do I need to pass in the start address for my long, word and byte values? 3 memory address variables isn't bad but would be nice to do it with 1.
Say I was going to transfer 1 long, 2 words and 8 bytes from by source cog to the calling cog, I was hoping to do a longmove(dst, src, 3) but that doesn't work.
Is there a way to force VAR to not reorganize variables in memory? Is there another way I should be doing this?
Do I need to pass in the start address for my long, word and byte values? 3 memory address variables isn't bad but would be nice to do it with 1.
Comments
You can declare variables using a DAT section and that will maintain the order that you define like:
var1 byte 0
var2 byte 0
var3 word 0
var4 long 0
Note that the compiler will properly align the different sizes adding padding bytes as needed if you don't keep them aligned to the right boundaries.
You can access different subportions of variables like this:
var4.word[0]
var4.word[1]
var4.byte[3]
Remember that the move operations require addresses, so you'd need
LONGMOVE(@dst, @src, 3)
where "dst" is the name of the destination variable(s) and "src" is the name of the source variable(s).
Longmove and its ilk don't move data from one cog to another.
-Phil