<?xml version="1.0" ?><?xml-stylesheet type="text/xsl" encoding="UTF-8" href="iform.xsl" version="1.0"?><!DOCTYPE instructionsection  PUBLIC '-//ARM//DTD instructionsection //EN'  'iform-p.dtd'><!-- Copyright (c) 2010-2026 Arm Limited or its affiliates. All rights reserved. --><!-- This document is Non-Confidential. This document may only be used and distributed in accordance with the terms of the agreement entered into by Arm and the party that Arm delivered this document to. --><instructionsection id="LDSET" title="LDSET, LDSETA, LDSETAL, LDSETL -- A64" type="instruction">
  <docvars>
    <docvar key="instr-class" value="general"/>
    <docvar key="isa" value="A64"/>
  </docvars>
  <heading>LDSET, LDSETA, LDSETAL, LDSETL</heading>
  <desc>
    <brief>
      <para>Atomic bit set on word or doubleword</para>
    </brief>
    <authored>
      <para>This instruction
atomically loads a 32-bit word or 64-bit doubleword from memory, performs a
bitwise OR with the value held in a register on
it, and stores the result back to memory.
The value initially loaded from memory is returned in the destination register.</para>
      <list type="unordered">
        <listitem>
          <content>If the destination register is not one of <value>WZR</value> or
        <value>XZR</value>, <instruction>LDSETA</instruction> and <instruction>LDSETAL</instruction> load from memory with acquire semantics.</content>
        </listitem>
        <listitem>
          <content>
            <instruction>LDSETL</instruction> and <instruction>LDSETAL</instruction> store to memory with release semantics.</content>
        </listitem>
        <listitem>
          <content>
            <instruction>LDSET</instruction> has neither acquire nor release semantics.</content>
        </listitem>
      </list>
      <para>For more information about memory ordering semantics, see <xref linkend="ARMARM_BEIHCHEF">Load-Acquire, Store-Release</xref>.</para>
      <para>For information about addressing modes, see
<xref linkend="ARMARM_CHDIIIBB">Load/Store addressing modes</xref>.</para>
    </authored>
  </desc>
  <operationalnotes>
    <operationalnote>
      <operationalnote_content>
        <para>This instruction is a data-independent-time instruction as described in <xref linkend="ARMARM_BEICCDDAB3">About PSTATE.DIT</xref>.</para>
      </operationalnote_content>
    </operationalnote>
  </operationalnotes>
  <alias_list howmany="1">
    <alias_list_intro>This instruction is used by the alias </alias_list_intro>
    <aliasref aliaspageid="STSET_LDSET" aliasfile="stset_ldset.xml" hover="Atomic bit set on word or doubleword, without return" punct=".">
      <text>STSET, STSETL</text>
      <aliaspref>A == '0' &amp;&amp; Rt == '11111'</aliaspref>
    </aliasref>
    <alias_list_outro>
      <text>  See </text>
      <aliastablelink/>
      <text> below for details of when the alias is preferred.</text>
    </alias_list_outro>
  </alias_list>
  <classes>
    <iclass name="Integer" oneof="1" id="iclass_integer" no_encodings="8" isa="A64">
      <docvars>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
      </docvars>
      <iclassintro count="8"/>
      <arch_variants>
        <arch_variant feature="FEAT_LSE" name="v8Ap1"/>
      </arch_variants>
      <regdiagram form="32" psname="A64.ldst.memop.LDSET_32_memop" tworows="1">
        <box hibit="31" width="2" name="size" usename="1" settings="1" psbits="xx">
          <c>1</c>
          <c>x</c>
        </box>
        <box hibit="29" width="3" settings="3">
          <c>1</c>
          <c>1</c>
          <c>1</c>
        </box>
        <box hibit="26" name="VR" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="25" width="2" settings="2">
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="22" width="1" name="R" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="21" width="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="20" width="5" name="Rs" usename="1">
          <c colspan="5"/>
        </box>
        <box hibit="15" name="o3" usename="1" settings="1" psbits="x">
          <c>0</c>
        </box>
        <box hibit="14" width="3" name="opc" usename="1" settings="3" psbits="xxx">
          <c>0</c>
          <c>1</c>
          <c>1</c>
        </box>
        <box hibit="11" width="2" settings="2">
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="9" width="5" name="Rn" usename="1">
          <c colspan="5"/>
        </box>
        <box hibit="4" width="5" name="Rt" usename="1">
          <c colspan="5"/>
        </box>
      </regdiagram>
      <encoding name="LDSET_32_memop" oneofinclass="8" oneof="8" label="32-bit no memory ordering" bitdiffs="size == 10 &amp;&amp; A == 0 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSET-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="LDSET"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>LDSET  </text><a hover="Is the 32-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="WsOrWZR">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSETA_32_memop" oneofinclass="8" oneof="8" label="32-bit acquire" bitdiffs="size == 10 &amp;&amp; A == 1 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSETA-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="LDSETA"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>LDSETA  </text><a hover="Is the 32-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="WsOrWZR">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSETAL_32_memop" oneofinclass="8" oneof="8" label="32-bit acquire-release" bitdiffs="size == 10 &amp;&amp; A == 1 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSETAL-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="LDSETAL"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>LDSETAL  </text><a hover="Is the 32-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="WsOrWZR">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSETL_32_memop" oneofinclass="8" oneof="8" label="32-bit release" bitdiffs="size == 10 &amp;&amp; A == 0 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSETL-32-reg"/>
          <docvar key="reg-type" value="32-reg"/>
          <docvar key="mnemonic" value="LDSETL"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>0</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>LDSETL  </text><a hover="Is the 32-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="WsOrWZR">&lt;Ws&gt;</a><text>, </text><a hover="Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="WtOrWZR__2">&lt;Wt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSET_64_memop" oneofinclass="8" oneof="8" label="64-bit no memory ordering" bitdiffs="size == 11 &amp;&amp; A == 0 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSET-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="LDSET"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>LDSET  </text><a hover="Is the 64-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="XsOrXZR__2">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSETA_64_memop" oneofinclass="8" oneof="8" label="64-bit acquire" bitdiffs="size == 11 &amp;&amp; A == 1 &amp;&amp; R == 0">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSETA-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="LDSETA"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>0</c>
        </box>
        <asmtemplate><text>LDSETA  </text><a hover="Is the 64-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="XsOrXZR__2">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSETAL_64_memop" oneofinclass="8" oneof="8" label="64-bit acquire-release" bitdiffs="size == 11 &amp;&amp; A == 1 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSETAL-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="LDSETAL"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>1</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>LDSETAL  </text><a hover="Is the 64-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="XsOrXZR__2">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <encoding name="LDSETL_64_memop" oneofinclass="8" oneof="8" label="64-bit release" bitdiffs="size == 11 &amp;&amp; A == 0 &amp;&amp; R == 1">
        <docvars>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="atomic-ops" value="LDSETL-64-reg"/>
          <docvar key="reg-type" value="64-reg"/>
          <docvar key="mnemonic" value="LDSETL"/>
        </docvars>
        <box hibit="31" width="2" name="size">
          <c/>
          <c>1</c>
        </box>
        <box hibit="23" width="1" name="A">
          <c>0</c>
        </box>
        <box hibit="22" width="1" name="R">
          <c>1</c>
        </box>
        <asmtemplate><text>LDSETL  </text><a hover="Is the 64-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field." link="XsOrXZR__2">&lt;Xs&gt;</a><text>, </text><a hover="Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field." link="XtOrXZR__8">&lt;Xt&gt;</a><text>, [</text><a hover="Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field." link="XnSP_option">&lt;Xn|SP&gt;</a><text>]</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.memop.LDSET_32_memop" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">if !IsFeatureImplemented(FEAT_LSE) then <a link="func_EndOfDecode_1" file="shared_pseudocode.xml">EndOfDecode</a>(<a link="enum_Decode_UNDEF" file="shared_pseudocode.xml">Decode_UNDEF</a>); end;
let s : integer{} = UInt(Rs);
let t : integer{} = UInt(Rt);
let n : integer{} = UInt(Rn);

let datasize : integer{} = 8 &lt;&lt; UInt(size);
let regsize : integer{} = if datasize == 64 then 64 else 32;

let acquire : boolean = A == '1' &amp;&amp; Rt != '11111';
let release : boolean = R == '1';
let tagchecked : boolean = n != 31;</pstext></ps>
      </ps_section>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="LDSET_32_memop, LDSETA_32_memop, LDSETAL_32_memop, LDSETL_32_memop" symboldefcount="1">
      <symbol link="WsOrWZR">&lt;Ws&gt;</symbol>
      <account encodedin="Rs">
        <intro>
          <para>Is the 32-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDSET_32_memop, LDSETA_32_memop, LDSETAL_32_memop, LDSETL_32_memop" symboldefcount="1">
      <symbol link="WtOrWZR__2">&lt;Wt&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 32-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDSET_32_memop, LDSETA_32_memop, LDSETAL_32_memop, LDSETL_32_memop, LDSET_64_memop, LDSETA_64_memop, LDSETAL_64_memop, LDSETL_64_memop" symboldefcount="1">
      <symbol link="XnSP_option">&lt;Xn|SP&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the 64-bit name of the general-purpose base register or stack pointer, encoded in the &quot;Rn&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDSET_64_memop, LDSETA_64_memop, LDSETAL_64_memop, LDSETL_64_memop" symboldefcount="1">
      <symbol link="XsOrXZR__2">&lt;Xs&gt;</symbol>
      <account encodedin="Rs">
        <intro>
          <para>Is the 64-bit name of the general-purpose register holding the data value to be operated on with the contents of the memory location, encoded in the &quot;Rs&quot; field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDSET_64_memop, LDSETA_64_memop, LDSETAL_64_memop, LDSETL_64_memop" symboldefcount="1">
      <symbol link="XtOrXZR__8">&lt;Xt&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 64-bit name of the general-purpose register to be loaded, encoded in the &quot;Rt&quot; field.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <aliastablehook anchor="aliasconditions">Alias Conditions</aliastablehook>
  <ps_section howmany="1">
    <ps name="A64.ldst.memop.LDSET_32_memop" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute">var address : bits(64);

let privileged : boolean = <a link="global_PSTATE" file="shared_pseudocode.xml">PSTATE</a>.EL != <a link="global_EL0" file="shared_pseudocode.xml">EL0</a>;
let accdesc : <a link="type_AccessDescriptor" file="shared_pseudocode.xml">AccessDescriptor</a> = <a link="func_CreateAccDescAtomicOp_7" file="shared_pseudocode.xml">CreateAccDescAtomicOp</a>(<a link="enum_MemAtomicOp_ORR" file="shared_pseudocode.xml">MemAtomicOp_ORR</a>, acquire, release,
                                                       tagchecked, privileged, t, s);

if n == 31 then
    <a link="func_CheckSPAlignment_0" file="shared_pseudocode.xml">CheckSPAlignment</a>();
    address = <a link="accessor_SP_1" file="shared_pseudocode.xml">SP</a>{64}();
else
    address = <a link="accessor_X_2" file="shared_pseudocode.xml">X</a>{64}(n);
end;

let comparevalue : bits(datasize) = ARBITRARY : bits(datasize); // Irrelevant when not executing CAS
let value : bits(datasize) = <a link="accessor_X_2" file="shared_pseudocode.xml">X</a>{datasize}(s);
let data : bits(datasize) = MemAtomic{}(address, comparevalue, value, accdesc);

if t != 31 then
    <a link="accessor_X_2" file="shared_pseudocode.xml">X</a>{regsize}(t) = ZeroExtend{regsize}(data);
end;</pstext></ps>
  </ps_section>
  <timestamp>2026-03-26 20:27:25</timestamp>
  <commit_id>2026-03_rel</commit_id>
</instructionsection>