lwarx
Load Word and Reserve Indexed
lwarx EH=0 RT,RA,D
lwarx EH=1 RT,RA,D
Loads a word and creates a reservation for use with 'stwcx.'. Critical for implementing atomic primitives (mutexes).
Details
The lwarx instruction loads a word from memory into a target general-purpose register (RT) and reserves the storage location for exclusive access. The effective address is calculated by adding the contents of the base register (RA) to the offset specified in the immediate field (D).
Pseudocode Operation
Programming Note
EH = 0 should be used when all accesses to a mutex variable are performed using an instruction sequence with Load And Reserve followed by Store Conditional. EH = 1 should be used when the program is obtaining a lock variable which it will subsequently release before another program attempts to perform a store to it.
Extended Mnemonics
| Extended Mnemonic | Equivalent Instruction |
|---|---|
| lwarx |
Example
Encoding
Operands
-
RT
Target Register -
RA
Base Register -
RB
Index Register -
D
Immediate Displacement -
EH
Hint for subsequent store operation