Propeller Assembly Code (COGINIT) (Syntax 2)

To run Propeller Assembly code in a specific cog, the COGINIT command needs the cog ID, the address of the assembly routine, and a value that can optionally be used by the assembly routine. For example:

coginit(2, @Toggle, 0)

This example launches the Propeller Assembly routine, Toggle, into Cog 2 with a PAR parameter of 0. See the example in the assembly syntax description of COGNEW for a more detailed example keeping in mind that the above COGINIT command can be used in place of COGNEW in that example.

The Parameter Field

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 lower two bits are always cleared to zero to ensure it's a long-aligned address. A value other than a long address can still be passed via the Parameter field, but will have to be limited to 14 bits, must be shifted left by two bits (for the COGNEW/COGINIT command), and will have to be shifted right by two bits by the assembly program that receives it.

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