ldrex
Load Register Exclusive (Thumb)
LDREX <Rt>, [<Rn>]
Loads word and sets exclusive monitor (Thumb).
Details
Loads a 32-bit word from memory at the address in Rn into Rt and opens the exclusive monitor for that address. The instruction does not modify the condition flags. Execution in Thumb-2 state only; typically paired with STREX for atomic operations.
Pseudocode Operation
address ← Rn
Rt ← [address]
SetExclusiveMonitor(address)
Example
LDREX r3, [r1]
Encoding
Binary Layout
11101000010
1
Rn
Rt
1111
imm8
Operands
-
Rt
Transfer general-purpose register (load/store) -
Rn
First source / base general-purpose register
Reference (Arm AArch32 ISA)
Instruction Forms
| Encoding | Instruction | ISA | Bit pattern | ||
|---|---|---|---|---|---|
| 0x01900F9F | LDREX{<c>}{<q>} <Rt>, [<Rn> {, {#}<imm>}] | A32 | cond | 00011 | 00 | 1 | Rn | Rt | 1 | 1 | 1 | 1 | 1001 | 1111 | ||
| 0xE8500F00 | LDREX{<c>}{<q>} <Rt>, [<Rn> {, #<imm>}] | T32 | 11101000010 | 1 | Rn | Rt | 1111 | imm8 |
Description
Load Register Exclusive calculates an address from a base register value and an immediate offset, loads a word from memory, writes it to a register and:
For more information about support for shared memory see Synchronization and semaphores. For information about memory accesses see Memory accesses.
Operation
if ConditionPassed() then
EncodingSpecificOperations();
address = R[n] + imm32;
AArch32.SetExclusiveMonitors(address,4);
R[t] = MemA[address,4];