Home/Instructions/Atomic OR Doubleword
AMOOR.D

RISC-V AMOOR.D Instruction Details

Instruction ManualR-type

RV64 atomic 64-bit doubleword bitwise OR: rd returns the old memory value, while memory receives oldDoubleword | rs2Doubleword

Instruction Syntax

amoor.d rd, rs2, (rs1)
Operand Breakdown
rd: receives the old memory value read atomically; for AMOCAS, its pre-execution value also supplies the compare value.
rs1: directly supplies the atomic-memory address; AMO assembly syntax has no offset immediate field.
rs2: supplies the AMO source data; for AMOCAS, it is the swap value stored when the comparison matches.
AMO-type is this site's presentation label for the AMO-specific R-type field layout: funct5, aq, rl, rs2, rs1, funct3, rd, and the AMO opcode encode the operation.
AZaamoAtomic Operation

Instruction Behavior

The following semantics assume the target region supports this AMO width and operation and the access succeeds. AMOOR.D performs an atomic read-modify-write on the 64-bit doubleword addressed by rs1: it first reads the old memory doubleword into rd, then computes oldDoubleword | rs2Doubleword using bitwise OR semantics and writes the 64-bit result back to the same address. The operation uses matching bit positions from the old doubleword and the rs2 doubleword. aq/rl add ordering only in the accessed memory or I/O address domain and do not change the data result; ordering across both domains still needs FENCE. rs2 uses its pre-execution value; rd=x0 discards only the old-value register writeback, while the memory operation still occurs.

AMOOR.D Atomic Decode And Execute Animation

Shows A / Zaamo doubleword atomic field decode, aq/rl ordering bits, a memory read, and RMW state update.

rd
rs2
rs1
amoor.d
,
,(
)
Execution Context
31..27
26
25
24..20
19..15
14..12
11..7
6..0
01000
funct5
0
aq
0
rl
01011
rs2
01010
rs1
011
funct3
00101
rd
0101111
opcode
Atomic Data Path
instruction
0x40B532AF
opcode
0101111 -> AMO
funct3
011 -> doubleword width
funct5
01000 -> AMOOR.D
aq / rl
0/0 -> unordered
rd / rs2 / rs1
t0(x5) / a1(x11)=0x000000000000FFF0 / a0(x10)=0x0000000000001000
memory read
mem[0x0000000000001000] -> old doubleword 0xF00000000000000F
RMW
0xF00000000000000F | 0x000000000000FFF0 -> 0xF00000000000FFFF
rd / memory
t0(x5) = 0xF00000000000000F; mem[0x0000000000001000] = 0xF00000000000FFFF
Current Step

Concept Step: receive the 32-bit atomic instruction encoding

A / Zaamo-extension doubleword atomic instructions use a 32-bit encoding; the animation starts by splitting the fields.

encoding: 0x40B532AF
syntax : amoor.d t0(x5), a1(x11), (a0(x10))
result : t0(x5) = 0xF00000000000000F; mem[0x0000000000001000] = 0xF00000000000FFFF
64-bit Doubleword Result View
63
62
61
60
59
58
57
56
55
54
53
52
51
50
49
48
47
46
45
44
43
42
41
40
39
38
37
36
35
34
33
32
31
30
29
28
27
26
25
24
23
22
21
20
19
18
17
16
15
14
13
12
11
10
9
8
7
6
5
4
3
2
1
0
1
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
old doubleword
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
1
1
1
1
1
1
1
1
1
0
0
0
0
rs2 doubleword
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-

Assumes the region supports this AMO and the access succeeds. Shows the operation, old-value return, memory update and aq/rl ordering in the accessed domain. Steps are a teaching sequence; access faults, CPU cache coherence, pipelines and timing are not modeled.

Quick Understanding & Search Notes

AMOOR.D is an RV64 64-bit AMO.D read-modify-write instruction. On successful access with rd≠x0, rd returns the old doubleword before the operation; only the result of oldDoubleword | rs2Doubleword is written back to memory, so keep old-value return separate from memory update.

funct5=01000, funct3=011, and opcode=0101111 identify AMOOR.D; aq/rl bits do not change the data calculation.
rd receives the old 64-bit memory doubleword before the operation; memory receives the 64-bit result computed by this AMO.D instruction.
AMOOR.D is an RV64-only doubleword AMO and normally requires an 8-byte naturally aligned address. A misaligned atomicity granule PMA avoids an address-alignment exception when all accessed bytes lie in one granule.
AMOOR.D is a 64-bit bitwise logical AMO; each result bit comes from the same bit position of the old doubleword and the rs2 doubleword.

Common Usage Scenarios

Bit Operations & Masks

Successful 64-bit access example: a2=0x1000, old memory=5, a1=3; amoor.d a0, a1, (a2) returns a0=5 and updates memory to 7. The address is naturally aligned and the region supports this AMO.

Atomic & Sync

Successful 64-bit access example: a2=0x1000, old memory=5, a1=3; amoor.d a0, a1, (a2) returns a0=5 and updates memory to 7. The address is naturally aligned and the region supports this AMO.

RV64 Operations

Successful 64-bit access example: a2=0x1000, old memory=5, a1=3; amoor.d a0, a1, (a2) returns a0=5 and updates memory to 7. The address is naturally aligned and the region supports this AMO.

Pre-Use Checklist

Syntax Check
  • rd, rs2, and rs1 select x0–x31 or their ABI names; syntax is rd, rs2, (rs1), with no rs3 or offset immediate.
  • Check funct5 for the operation and funct3 for access width; aq/rl are separate ordering bits, not a fixed funct7 constant.
Semantic Check
  • Check natural alignment or the misaligned atomicity granule PMA condition; the target region must support this AMO width and operation.
  • On success, rd receives old memory and the computed result goes to memory; rd=x0 discards only register writeback. On RV64, AMO.W sign-extends the old word and uses only rs2[31:0].

Pitfalls / Common Confusions

rd holds the old 64-bit memory value before the operation, not the new bitwise OR memory result.
AMOOR.D is an RV64-only doubleword AMO and normally requires an 8-byte naturally aligned address. A misaligned atomicity granule PMA avoids an address-alignment exception when all accessed bytes lie in one granule.
Memory receives the 64-bit result of oldDoubleword | rs2Doubleword; do not apply the 32-bit AMO.W sign-extension rule.
aq/rl constrain memory ordering only; they do not change this AMO.D instruction's data result.

FAQ

Does AMOOR.D place the new memory result in rd?

No. AMOOR.D places the old 64-bit memory value before the operation in rd; the result of oldDoubleword | rs2Doubleword is written back to memory.

Do aq/rl bits change the bitwise OR result of AMOOR.D?

No. aq/rl only affect memory-ordering constraints; they do not change this AMO.D instruction's 64-bit data result.