Question about cogram
JaanDoh
Posts: 129
in Propeller 1
Hi again all,
Today I have a question about cog ram...
Why do some of the programs I've seen declare cogid as a long? when a byte would suffice?
'instead of this Byte Cogid 'I see this more often Long Cogid
Comments
There's two reasons:
tl;dr; use a long to store cogid, it's fine.
I've always added 1 to whatever cognew returns and stored it in a byte. I think that's pretty much standard procedure across the board.
-Phil
That makes the code future proof for the 4294967295 cog Propeller. ;-)
@Wuerfel_21, Thank you, I came across mention of the first 8 longs declared in a program? (program or object I don't know), and also the first 8 parameters in a function call, and how access was faster to those.
Right now i have a mixture of bytes and longs for storing the cogid, this difference is in the various objects, where in one it maybe long and in another it maybe byte.
I had thought initially that it had something to do with accessing that register from within pasm programs and then I realised you can address any register via Byte[address], Word[address] and Long[address] so that made me ask here in the forum.
I'd like to use a byte field for the cogid an wonder if the sample programs from the library would be affected if I change the field type for cogid from Long to Byte.
Its crazy because one question leads to two or more new ones lol...
@"Phil Pilgrim (PhiPi)" , Thank you, That sounds like how I wish to implement the cogid into my program, as byte not long, once i get it work, i'll try and look at changing the ones currently defined as long to byte. I'm a little unsure if it will break the existing code (from the samples in the library)...u
@Ariba , Thank you, I'd best get a move on if I'm to get the hang of this, All the time I read about other members exploits, tests and research into the P2 and I'm just amazed at some of the stuff and wish desperately to master spin, and then move on pasm (I wish..) lol