Propeller Manual

Table Of Contents
COGINIT – Assembly Language Reference
Page 284 · Propeller Manual v1.1
COGINIT
Instruction: Start or restart a cog, optionally by ID, to run Propeller Assembly or Spin code.
COGINIT Destination
Result: Optionally, the started/restarted cog’s ID (0-7) is written to Destination.
Destination (d-field) is the register containing startup information for the target cog
and optionally becomes the destination of the started cog’s ID if a new cog is started.
Opcode Table:
–INSTR– ZCRI –CON– –DEST– –SRC– Z Result C Result Result Clocks
000011 0001 1111 ddddddddd ------010
ID = 0 No Cog Free Not Written 7..22
Concise Truth Table:
In Out
Destination
1
Source
2
Z
C
Effects
Destination
3
Z C
$0000_0000; 0 %0_00000010; 2 -
-
wr wz wc
$0000_0000; 0
4
1 0
$0000_0001; 1 %0_00000010; 2 -
-
wr wz wc
$0000_0001; 1
4
0 0
$0000_0008; 8 %0_00000010; 2 -
-
wr wz wc
$0000_0000; 0
5
1 0
$0000_0008; 8 %0_00000010; 2 -
-
wr wz wc
$1; 1 .. $7; 7
5
0 0
$0000_0008; 8 %0_00000010; 2 -
-
wr wz wc
$0000_0007; 7
5
0 1
1
Destination In must be a PAR value (bits 31:18), an assembly code address (bits 17:4), and a new cog / cog ID indicator (bits 3:0).
2
Source is automatically set to immediate value 2 by the assembler to indicate that this is the COGINIT hub instruction.
3
Destination is not written unless the WR effect is given.
4
When Destination In indicates to start a specific cog, Destination Out (written Destination) indicates that cog’s ID; it is always
started or restarted.
5
When Destination In indicates to start a new (next available) cog, Destination Out (written Destination) indicates the ID of the cog
that was started, or 7 (with C set) if no cog available.
Explanation
The
COGINIT instruction behaves similar to two Spin commands, T COGNEW and COGINITT, put
together. Propeller Assembly’s
COGINIT instruction can be used to start a new cog or restart
an active cog. The Destination register has four fields that determine which cog is started,
where its program begins in main memory, and what its
T
PAR register will contain. The table
below describes these fields.