Propeller Manual

Table Of Contents
3: Assembly Language Reference – LOCKRET
Propeller Manual v1.1 · Page 305
LOCKRET
Instruction: Release lock back for future “new lock” requests.
LOCKRET ID
ID (d-field) is the register containing the ID (0 – 7) of the lock to return to the lock
pool.
Opcode Table:
–INSTR– ZCRI –CON– –DEST– –SRC– Z Result C Result Result Clocks
000011 0001 1111 ddddddddd ------101
ID = 0 No Lock Free Not Written 7..22
Concise Truth Table:
In Out
Destination Source
1
Z
C
Effects
Destination
2
Z C
3
$0000_0000; 0
%0_00000101; 5 -
-
wr wz wc
$0000_0000; 0 1 0
$0000_0005; 5
%0_00000101; 5 -
-
wr wz wc
$0000_0005; 5 0 0
$0000_0008; 8
4
%0_00000101; 5 -
-
wr wz wc
$0000_0000; 0 1 0
1
Source is automatically set to immediate value 5 by the assembler to indicate that this is the LOCKRET hub instruction.
2
Destination is not written unless the WR effect is given.
3
The C flag will be set (1) if all lock bits were allocated prior to executing the LOCKRET instruction.
4
Only the lowest 3 bits of Destination In are utilized, so a value of 8 is seen as lock bit ID 0.
Explanation
LOCKRET is one of four lock instructions (T LOCKNEW, LOCKRETT, LOCKSET, and LOCKCLR) used to
manage resources that are user-defined and deemed mutually exclusive.
LOCKRET returns a
lock, by ID, back to the Hub’s lock pool so that it may be reused by other cogs at a later time.
The
LOCKRET instruction behaves similar to Spin’s T LOCKRET command; see LOCKRET
125
T on page
.
If the
WZ effect is specified, the Z flag is set (1) if the ID of the returned lock is zero (0). If the
WC effect is specified, the C flag is set (1) if all lock bits were allocated prior to executing this
instruction. If the
WR effect is specified, the ID of the returned lock is written to ID.
LOCKRET is a hub instruction. Hub instructions require 7 to 22 clock cycles to execute
depending on the relation between the cog’s hub access window and the instruction’s moment
of execution. See on page for more information.
T
Hub 24