LOCKNEW

Instruction: Check out a new lock and get its ID.

LOCKNEW NewID


Result: The new lock's ID (0-7) is written to NewID.

  • NewID (d-field) is the register where the newly checked-out lock's ID is written.

Opcode Table:

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

Z Result

C Result

Result

Clocks

  000011    0011    1111    ddddddddd    ------100

ID = 0

No Lock Free

Written

8..23

Concise Truth Table:

In

Out

Destination

Source1

Z

C

Effects

Destination

Z

C

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0000; 0

1

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0001; 1

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0002; 2

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0003; 3

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0004; 4

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0005; 5

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0006; 6

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0007; 7

0

0

$----_----; -

%0_00000100; 4

-

-

wz wc

$0000_0007; 7

0

1

1 Source is automatically set to immediate value 4 by the assembler to indicate that this is the LOCKNEW hub instruction.

Explanation

LOCKNEW is one of four lock instructions (LOCKNEW, LOCKRET, LOCKSET, and LOCKCLR) used to manage resources that are user-defined and deemed mutually exclusive. LOCKNEW checks out a unique lock, from the hub, and retrieves the ID of that lock. The LOCKNEW instruction behaves similar to Spin's LOCKNEW command; see LOCKNEW.

If the WZ effect is specified, the Z flag is set (1) if the returned ID is zero (0). If the WC effect is specified, the C flag is set (1) if no lock was available for checking out. The ID of the newly checked-out lock is written to NewID unless the NR effect is specified.

LOCKNEW 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.