How to access a byte from COG RAM?
DragonRaider5
Posts: 13
in Propeller 1
Hey there,
I've got a quiet simple question which I don't know the answer to: I have reserved an amount of _SOME_CONSTANT longs in my COG RAM inside a DAT block. Now I wan't to check the value of the bytes at certain indexes(if you think off it as an array of bytes). My question simply is, if I do something like this:
Thanks in advance,
DragonRaider5
I've got a quiet simple question which I don't know the answer to: I have reserved an amount of _SOME_CONSTANT longs in my COG RAM inside a DAT block. Now I wan't to check the value of the bytes at certain indexes(if you think off it as an array of bytes). My question simply is, if I do something like this:
DAT org 0 ' fill SomeLongs with values add CompareLSB, #DestInc CompareLSB cmp SomeLongs, #0 DestInc long (%10_0000_0000 * (_SOME_SIZE * 4 - 1)) SomeLongs res _SOME_SIZEwill it only compare the byte which ends at the LSB or what will it do - and is there a better way of doing what I'm trying to achieve?
Thanks in advance,
DragonRaider5
Comments
To treat part of the COG RAM as an array you have to use self modifying code, changing the DST field of the instruction. So test index i of the array at SomeLongs you'd do something like: Again, that's to access longs; accessing bytes would be considerably more complicated, you'd have to mask out the low bits of the index, load the whole long, and use those low bits to select a byte within the long.
If the array is in HUB RAM you can just use rdbyte, which is a lot easier.