Propeller Manual

Table Of Contents
PAR – Spin Language Reference
Page 178 · Propeller Manual v1.1
PAR
Register: Cog Boot Parameter register.
((PUB PRI))
PAR
Returns: Address value passed during launch of assembly code with COGINIT or COGNEW.
Explanation
The
PAR register contains the address value passed into the Parameter field of a COGINIT or
COGNEW command; see COGINIT, page 76 and COGNEW, page 78. The PAR register’s contents are
used by Propeller Assembly code to locate and operate on memory shared between Spin code
and assembly code.
Since the PAR register is intended to contain an address upon cog launch, the value stored into
it via
COGINIT and T COGNEW is limited to 14 bits: a 16-bit word with the lower two bits cleared
to zero.
Using PAR
PAR is affected by Spin code and is used by assembly code as a memory pointer mechanism to
point to shared main memory between the two. Either the
COGINIT or T COGNEW command, when
launching Propeller Assembly into a cog, affects the
PAR register. For example:
VAR
long Shared 'Shared variable (Spin & Assy)
PUB Main | Temp
cognew(@Process, @Shared) 'Launch assy, pass Shared addr
repeat
<do something with Shared vars>
DAT
org 0
Process mov Mem, PAR 'Retrieve shared memory addr
:loop <do something>
wrlong ValReg, Mem 'Move ValReg value to Shared
jmp #:loop
Mem res 1
ValReg res 1