Passing data in PAR rather than a pointer
BradC
Posts: 2,601
Just been playing with PAR and using it to pass data to a cog rather than a pointer.
We all know it zero's bits [noparse][[/noparse]0..1], (Propeller Tricks & Traps page 7)
but did anyone know it only passes the next 14 bits? Bits 16..31 seem to be masked.
(Or they were in my tests here).
ie
COGNEW(@asm_prog, 1 << 15) shows what it should in the COG, $00008000 while
COGNEW(@asm_prog, 1 << 16) shows PAR == 0
Can someone point me to the bit in the doc where it says this?
We all know it zero's bits [noparse][[/noparse]0..1], (Propeller Tricks & Traps page 7)
but did anyone know it only passes the next 14 bits? Bits 16..31 seem to be masked.
(Or they were in my tests here).
ie
COGNEW(@asm_prog, 1 << 15) shows what it should in the COG, $00008000 while
COGNEW(@asm_prog, 1 << 16) shows PAR == 0
Can someone point me to the bit in the doc where it says this?
Comments
It’s important to note that the Parameter field is intended to pass a long address, so only 14-
bits (bits 2 through 15) are passed into the cog’s PAR register.
The very deep rational behind this becomes totally obvious when you look at Table 5.1 on page 366 in the Manual. There is just no more space in a 32 bit word.
"Of course, this effectively limits argument size to 30 bits, instead of 32"
And also remember: VARs are re-sorted by the compiler according to size!
-Phil
I was under the understanding that Var Memory was continous and·I am banking on that being true in a project of my. Are you saying that if I pass an assembly routine an Array, that using " sub par_,#4" may or may not get me the var declared before the array?
That should work. All long variables in an object are allocated in the order declared, so a long variable declared just before a long word array should be located just before the array in memory. Subtracting 4 from PAR should give you the address of this long variable.
Another Disaster avoided. Thanks.
True, true ... but not if it were a WORD or a BYTE.
BTW: The complete VAR area of all objects is assembled all together to be located at the end of the binary.
16 "special bytes", then DAT then code then VAR...
As there can be no preset with VAR this area is NOT transmitted when loading the RAM from the PC, the bootstrap loader seems to look after a preset of the complete RAM. It is however stored into the EEPROM (always 32k!)
Post Edited (deSilva) : 9/30/2007 7:16:26 AM GMT