PAR

Register: Cog boot parameter register.

DAT
Label > < Condition > Instruction DestOperandPAR Effects >

  • Label is an optional statement label. See Common Syntax Elements.
  • Condition is an optional execution condition. See Common Syntax Elements.
  • 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 COGNEW command, or into the upper bits of the Destination field of an assembly-based COGINIT 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 14bits (bits 15 through 2) 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 and the Spin language PAR for more information.

DAT
           org 0               'Reset assembly pointer
AsmCode    mov Addr, par       'Get shared address
           '<more code here>   'Perform operation 

Addr       res 1

Unless otherwise noted, content on this site is licensed under the
Creative Commons Attribution-ShareAlike 4.0 International License.