stbcx.
Store Byte Conditional Indexed
stbcx. RS, RA, RB
Stores a byte from a register to memory if the reservation is valid and matches the address.
Details
The stbcx. instruction stores a byte from the specified source register (RS) into memory at an effective address calculated by adding the contents of two registers (RA and RB). The operation is conditional on whether a reservation exists and matches the target address.
Pseudocode Operation
if RA = 0 then
b ← 0
else
b ← (RA)
EA ← b + (RB)
if RESERVE then
if RESERVE_LENGTH = 1 &
RESERVE_ADDR = real_addr(EA) then
MEM(EA, 1) ← (RS)56:63
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, 1) ← (RS)56:63
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
stbcx. r3, r4, r5
Encoding
Binary Layout
31
0
RS
16
RA
6
RB
11
694
1
Operands
-
RS
Source -
RA
Base -
RB
Index