LOCKCLR
Instruction: Clear lock to false and get its previous state.
LOCKCLR ID
Result: Optionally, previous state of lock is written to C flag.
- ID (d-field) is the register containing the ID (0 – 7) of the lock to clear.
Opcode Table:
–INSTR– ZCRI –CON– –DEST– –SRC– | Z Result | C Result | Result | Clocks |
000011 0001 1111 ddddddddd ------111 | ID = 0 | Prior Lock State | Not Written | 8..23 |
Concise Truth Table:
In | Out | ||||||
Destination | Source1 | Z | C | Effects | Destination2, 3 | Z | C |
$0000_0005; 5 | %0_00000111; 7 | - | - | wr wz wc | $0000_0005; 5 | 0 | 14 |
$0000_0005; 5 | %0_00000111; 7 | - | - | wr wz wc | $0000_0005; 5 | 0 | 0 |
$0000_0000; 0 | %0_00000111; 7 | - | - | wr wz wc | $0000_0000; 0 | 1 | 14 |
$0000_0000; 0 | %0_00000111; 7 | - | - | wr wz wc | $0000_0000; 0 | 1 | 0 |
$0000_0008; 8 5 | %0_00000111; 7 | - | - | wr wz wc | $0000_0000; 0 | 1 | 0 |
1 Source is automatically set to immediate value 7 by the assembler to indicate that this is the LOCKCLR hub instruction.
2 Destination is not written unless the WR effect is given.
3 Destination Out (written Destination) indicates the ID of the lock bit that was cleared.
4 The C flag indicates the previous state of the lock bit; in these cases the lock bit was previously set by a formerly executed LOCKSET instruction (not shown). The next example clears the C flag because the lock bit was just cleared by the previous example.
5 Only the lowest 3 bits of Destination In are utilized, so a value of 8 is seen as lock bit ID 0.
Explanation
LOCKCLR is one of four lock instructions (LOCKNEW, LOCKRET, LOCKSET, and LOCKCLR) used to manage resources that are user-defined and deemed mutually exclusive. LOCKCLR clears the lock described by the register ID to zero (0) and returns the previous state of that lock in the C flag; if the WC effect is specified. The LOCKCLR instruction behaves similar to Spin's LOCKCLR command; see LOCKCLR.
If the WZ effect is specified, the Z flag is set (1) if the ID of the cleared lock is zero (0). If the WC effect is specified, the C flag is set equal to the previous state of the lock. If the WR effect is specified, the ID of the cleared lock is written to ID.
LOCKCLR 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.