COGID

Instruction: Get current cog's ID.

COGID Destination


Result: The current cog's ID (0-7) is written to Destination.

  • Destination (d-field) is the register to write the cog's ID into.

Opcode Table:

 –INSTR–       ZCRI      –CON–        –DEST–              –SRC–

Z Result

C Result

Result

Clocks

 000011    0011    1111    ddddddddd    ------001

ID = 0

0

Written

8..23

Concise Truth Table:

In

Out

Destination

Source1

Z

C

Effects

Destination2

Z

C

$----_----; -
%0_00000001; 1
-
-
wz wc
$0000_0000; 0
1
0
$----_----; -
%0_00000001; 1
-
-
wz wc
$1; 1 .. $7; 7
0
0

1 Source is automatically set to immediate value 1 by the assembler to indicate that this is the COGID hub instruction.
2 Destination Out (written Destination) will be 0 through 7, depending on which cog executed the instruction.

Explanation

COGID returns the ID of the cog that executed the command. The COGID instruction behaves similar to the Spin command of the same name; see COGID.

If the WZ effect is specified, the Z flag is set if the cog ID is zero. The result is written to Destination unless the NR effect is specified.

COGID is a hub instruction. Hub instructions require 8 to 23 clock cycles to execute depending on the relation between the cog's hub access window and the instruction's moment of execution. See Hub for more information.

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