Propeller Manual

Table Of Contents
3: Assembly Language Reference – WR
WR
Effect: Cause assembly instruction to write a result.
Label Condition Instruction Operands WR
Result: Instruction’s destination register is changed to the result value.
Label is an optional statement label. See Common Syntax Elements on page 250.
Condition is an optional execution condition. See Common Syntax Elements on page 250.
Instruction is the desired assembly instruction.
Operands is zero, one, or two operands as required by the Instruction.
Explanation
WR (Write Result) is one of four optional effects (WC, WZ, NR, and WR) that influence the
behavior of assembly instructions.
WR causes an executing assembly instruction to write its
result value to the destination register.
For example, by default the
COGINIT (Cog Initialize) instruction does not write a result to the
destination register. This is fine when wanting to start a cog with a specific ID, but when
asking to start the next available cog (i.e., destination register value bit 3 is high) you may
like to know what cog was actually started, by ID. You can get the new cog’s ID from the
COGINIT instruction by using the WR effect:
coginit launch_value WR 'Launch new cog, get ID back
Assuming launch_value points to a register that contained a high (1) in bit 3, the COGINIT
instruction starts the next available cog and writes its ID back to the
launch_value register.
See Effects on page 291 for more information.
Propeller Manual v1.1 · Page 373