stqcx.

Store Quadword Conditional Indexed

stqcx. RS, RA, RB

Stores a quadword from a register to memory if a reservation exists and the conditions are met.

Details

The stqcx. instruction stores a quadword from RSp to memory at the effective address (EA) calculated as RA + RB, but only if a reservation exists for that location and the reservation length is 16 bytes. If the reservation does not exist or the conditions are not met, no store is performed.

Pseudocode Operation

if RA = 0 then
    b ← 0
else
    b ← (RA)
EA ← b + (RB)
if RESERVE then
    if RESERVE_LENGTH = 16 and RESERVE_ADDR = real_addr(EA) then
        MEM(EA, 16) ← (RSp)
        undefined_case ← 0
        store_performed ← 1
    else
        z ← smallest real page size supported by implementation
        if RESERVE_ADDR ÷ z = real_addr(EA) ÷ z then
            undefined_case ← 1
        else
            undefined_case ← 0
            store_performed ← 0
else
    undefined_case ← 0
    store_performed ← 0
if undefined_case then
    u1 ← undefined 1-bit value
    if u1 then
        MEM(EA, 16) ← (RSp)
    u2 ← undefined 1-bit value
    CR0 ← 0b00 || u2 || XERSO
else
    CR0 ← 0b00 || store_performed || XERSO
RESERVE ← 0

Programming Note

Succeeds only if a valid reservation exists on the target address. Sets CR0[EQ] to 1 on success, 0 on failure. Must always be used in a retry loop that re-executes the load-reserve instruction on failure.

Example

stqcx. r3, r4, r5

Encoding

Binary Layout
31
0
RS
6
RA
11
RB
16
182
1
 
Format X-form
Opcode 0x7C00016D
Extension Base
Registers Altered CR0, XER

Operands

  • RS
    Src Pair (Even/Odd)
  • RA
    Base
  • RB
    Index
  • RSp
    Source General Purpose Register containing the data to be stored