Propeller Manual

Table Of Contents
3: Assembly Language Reference – PAR
Propeller Manual v1.1 · Page 331
PAR
Register: Cog boot parameter register.
DAT
Label Condition Instruction DestOperand, PAR Effects
Label is an optional statement label. See Common Syntax Elements, page 250.
Condition is an optional execution condition. See Common Syntax Elements, page 250.
Instruction is the desired assembly instruction. PAR is a read-only register and thus
should only be used in the instruction’s source operand.
DestOperand is a constant expression indicating the register that is operated on, and
optionally written to, by the value of
PAR in the instruction’s source operand.
Explanation
The
PAR register contains the address value passed into the Parameter field of a Spin-based
COGINIT or T COGNEW command, or into the upper bits of the Destination field of an assembly-
based
COGINITT command. When the cog starts up, its Propeller Assembly code can use the
PAR register’s contents to locate and operate on main memory shared between it and the
calling code.
It’s important to note that the value passed into
PAR is intended to be a long address, so only
14-bits (bits 2 through 15) are retained; the lower two bits are cleared to zero to ensure that
it’s a long-aligned address. Values other than long addresses can still be passed, but must be
14 bits or less and shifted left and right appropriately by both caller and newly started cog.
PAR is a read-only pseudo-register; when used as an instruction’s source operand, it reads the
value passed to the cog upon launch. Do not use
PAR as the destination operand; that only
results in reading and modifying the shadow register whose address
PAR occupies.
The following code moves the value of
PAR into the register Addr for further use later in code.
See Registers, page 338, and the Spin language
PAR section, page 178, for more information.
DAT
org 0 'Reset assembly pointer
AsmCode mov Addr, par 'Get shared address
'<more code here> 'Perform operation
Addr res 1