<?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-2025 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="LDM_e" title="LDM (exception return) -- AArch32" type="instruction">
  <docvars>
    <docvar key="armarmheading" value="A1"/>
    <docvar key="instr-class" value="general"/>
    <docvar key="isa" value="A32"/>
    <docvar key="mnemonic" value="LDM"/>
  </docvars>
  <heading>LDM (exception return)</heading>
  <desc>
    <brief>
      <para>Load Multiple (exception return)</para>
    </brief>
    <authored>
      <para>Load Multiple (exception return) loads multiple registers from
consecutive memory locations using an address from a base register.
The <xref linkend="ARMARM_CHDDAABB">SPSR</xref>
of the current mode is copied to the <xref linkend="ARMARM_CIHJBHJA">CPSR</xref>.
An address adjusted by the size of the data loaded can optionally be
written back to the base register.</para>
      <para>The registers loaded include the PC. The word loaded for the PC is
treated as an address and a branch occurs to that address.</para>
      <para>The PE checks the encoding that is copied to the
<xref linkend="ARMARM_CIHJBHJA">CPSR</xref> for an illegal return event.
See <xref linkend="ARMARM_CHDDDJDB">Illegal return events from AArch32 state</xref>.</para>
      <para>Load Multiple (exception return) is:</para>
      <list type="unordered">
        <listitem>
          <content>
            <arm-defined-word>UNDEFINED</arm-defined-word> in Hyp mode.</content>
        </listitem>
        <listitem>
          <content>
            <arm-defined-word>UNPREDICTABLE</arm-defined-word> in debug state, and in User mode and System mode.</content>
        </listitem>
      </list>
    </authored>
    <encodingnotes>
      <para>For more information about the <arm-defined-word>CONSTRAINED UNPREDICTABLE</arm-defined-word> behavior of this instruction, see <xref linkend="ARMARM_CJAEGDJC">Architectural Constraints on UNPREDICTABLE behaviors</xref>.</para>
    </encodingnotes>
    <syntaxnotes>
      <para>Instructions with similar syntax but without the PC included in the registers list are described in <xref linkend="ARMARM_A32T32-base.instructions.LDM_u">LDM (User registers)</xref>.</para>
    </syntaxnotes>
  </desc>
  <operationalnotes>
    <operationalnote>
      <operationalnote_content>
        <para>This instruction is a data-independent-time instruction as described in <xref linkend="ARMARM_BEIIDCEG">About the DIT bit</xref>.</para>
      </operationalnote_content>
    </operationalnote>
  </operationalnotes>
  <alias_list howmany="0"/>
  <classes>
    <iclass name="A1" oneof="1" id="iclass_a1" no_encodings="1" isa="A32">
      <docvars>
        <docvar key="armarmheading" value="A1"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A32"/>
        <docvar key="mnemonic" value="LDM"/>
      </docvars>
      <iclassintro count="1"/>
      <regdiagram form="32" psname="A32.brblk.ldstm.LDM_e_A1_AS" tworows="1">
        <box hibit="31" width="4" name="cond" usename="1" settings="4" constraint="!= 1111">
          <c colspan="4">!= 1111</c>
        </box>
        <box hibit="27" width="2" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="25" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="24" width="1" name="P" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="23" width="1" name="U" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="22" name="op" usename="1" settings="1" psbits="x">
          <c>1</c>
        </box>
        <box hibit="21" width="1" name="W" usename="1">
          <c colspan="1"/>
        </box>
        <box hibit="20" name="L" usename="1" settings="1" psbits="x">
          <c>1</c>
        </box>
        <box hibit="19" width="4" name="Rn" usename="1">
          <c colspan="4"/>
        </box>
        <box hibit="15" width="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="14" width="15" name="register_list" usename="1">
          <c colspan="15"/>
        </box>
      </regdiagram>
      <encoding name="LDM_e_A1_AS" oneofinclass="1" oneof="1" label="">
        <docvars>
          <docvar key="armarmheading" value="A1"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A32"/>
          <docvar key="mnemonic" value="LDM"/>
        </docvars>
        <asmtemplate><text>LDM{</text><a hover="is one of:&#10;&#10;&#10;DA&#10;: Decrement After. The consecutive memory addresses end at the address in the base register. Encoded as P = 0, U = 0.&#10;&#10;FA&#10;: Full Ascending. For this instruction, a synonym for DA.&#10;&#10;DB&#10;: Decrement Before. The consecutive memory addresses end one word below the address in the base register. Encoded as P = 1, U = 0.&#10;&#10;EA&#10;: Empty Ascending. For this instruction, a synonym for DB.&#10;&#10;IA&#10;: Increment After. The consecutive memory addresses start at the address in the base register. This is the default. Encoded as P = 0, U = 1.&#10;&#10;FD&#10;: Full Descending. For this instruction, a synonym for IA.&#10;&#10;IB&#10;: Increment Before. The consecutive memory addresses start one word above the address in the base register. Encoded as P = 1, U = 1.&#10;&#10;ED&#10;: Empty Descending. For this instruction, a synonym for IB." link="amode__2">&lt;amode&gt;</a><text>}{</text><a hover="See x[Standard assembler syntax fields](Babbefhf)." link="cond__2">&lt;c&gt;</a><text>}{</text><a hover="See x[Standard assembler syntax fields](Babbefhf)." link="qw_option">&lt;q&gt;</a><text>}  </text><a hover="Is the general-purpose base register, encoded in the &quot;Rn&quot; field." link="Rn__12">&lt;Rn&gt;</a><text>{</text><a hover="The address adjusted by the size of the data loaded is written back to the base register. If specified, it is encoded in the &quot;W&quot; field as 1, otherwise this field defaults to 0." link="bang_choice">!</a><text>}, </text><a hover="Is a list of one or more registers, separated by commas and surrounded by { and }. It specifies the set of registers to be loaded. The registers are loaded with the lowest-numbered register from the lowest memory address, through to the highest-numbered register from the highest memory address. The PC must be specified in the register list, and the instruction causes a branch to the address (data) loaded into the PC. See also x[Encoding of lists of general-purpose registers and the PC](CHDDBEDG)." link="register_list__9">&lt;registers_with_pc&gt;</a><text>^</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A32.brblk.ldstm.LDM_e_A1_AS" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">let n : integer = UInt(Rn);
let registers : bits(15) = register_list;
let wback : boolean = (W == '1');
let increment : boolean = (U == '1');
let wordhigher : boolean = (P == U);
if n == 15 then UnpredictableProcedure(); end;
if wback &amp;&amp; registers[n] == '1' then UnpredictableProcedure(); end;</pstext></ps>
      </ps_section>
      <constrained_unpredictables encoding="A1" ps_block="Decode">
        <cu_case>
          <cu_cause>
            <pstext mayhavelinks="1">wback &amp;&amp; registers&lt;n&gt; == '1'</pstext></cu_cause>
          <cu_type constraint="Constraint_UNDEF"/>
          <cu_type constraint="Constraint_NOP"/>
          <cu_type>
            <cu_type_text>The instruction performs all the loads using the specified addressing mode and the content of the register being written back is UNKNOWN. In addition, if an exception occurs during the execution of this instruction, the base address might be corrupted so that the instruction cannot be repeated.</cu_type_text>
          </cu_type>
        </cu_case>
      </constrained_unpredictables>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="LDM_e_A1_AS" symboldefcount="1">
      <symbol link="amode__2">&lt;amode&gt;</symbol>
      <account encodedin="(U :: P)">
        <intro>
          <para>is one of:</para>
          <list type="param">
            <listitem>
              <param>DA</param>
              <content>Decrement After. The consecutive memory addresses end at the address in the base register. Encoded as P = 0, U = 0.</content>
            </listitem>
            <listitem>
              <param>FA</param>
              <content>Full Ascending. For this instruction, a synonym for <value>DA</value>.</content>
            </listitem>
            <listitem>
              <param>DB</param>
              <content>Decrement Before. The consecutive memory addresses end one word below the address in the base register. Encoded as P = 1, U = 0.</content>
            </listitem>
            <listitem>
              <param>EA</param>
              <content>Empty Ascending. For this instruction, a synonym for <value>DB</value>.</content>
            </listitem>
            <listitem>
              <param>IA</param>
              <content>Increment After. The consecutive memory addresses start at the address in the base register. This is the default. Encoded as P = 0, U = 1.</content>
            </listitem>
            <listitem>
              <param>FD</param>
              <content>Full Descending. For this instruction, a synonym for <value>IA</value>.</content>
            </listitem>
            <listitem>
              <param>IB</param>
              <content>Increment Before. The consecutive memory addresses start one word above the address in the base register. Encoded as P = 1, U = 1.</content>
            </listitem>
            <listitem>
              <param>ED</param>
              <content>Empty Descending. For this instruction, a synonym for <value>IB</value>.</content>
            </listitem>
          </list>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDM_e_A1_AS" symboldefcount="1">
      <symbol link="cond__2">&lt;c&gt;</symbol>
      <account encodedin="cond">
        <intro>
          <para>See <xref linkend="Babbefhf">Standard assembler syntax fields</xref>.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDM_e_A1_AS" symboldefcount="1">
      <symbol link="qw_option">&lt;q&gt;</symbol>
      <account encodedin="">
        <intro>
          <para>See <xref linkend="Babbefhf">Standard assembler syntax fields</xref>.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDM_e_A1_AS" symboldefcount="1">
      <symbol link="Rn__12">&lt;Rn&gt;</symbol>
      <account encodedin="Rn">
        <intro>
          <para>Is the general-purpose base register, encoded in the "Rn" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDM_e_A1_AS" symboldefcount="1">
      <symbol link="bang_choice">!</symbol>
      <account encodedin="W">
        <intro>
          <para>The address adjusted by the size of the data loaded is written back to the base register. If specified, it is encoded in the "W" field as 1, otherwise this field defaults to 0.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDM_e_A1_AS" symboldefcount="1">
      <symbol link="register_list__9">&lt;registers_with_pc&gt;</symbol>
      <account encodedin="">
        <intro>
          <para>Is a list of one or more registers, separated by commas and surrounded by { and }. It specifies the set of registers to be loaded. The registers are loaded with the lowest-numbered register from the lowest memory address, through to the highest-numbered register from the highest memory address. The PC must be specified in the register list, and the instruction causes a branch to the address (data) loaded into the PC. See also <xref linkend="CHDDBEDG">Encoding of lists of general-purpose registers and the PC</xref>.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <ps_section howmany="1">
    <ps name="A32.brblk.ldstm.LDM_e_A1_AS" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute">if ConditionPassed() then
    EncodingSpecificOperations();
    if PSTATE.EL == EL2 then
        Undefined();
    elsif PSTATE.M IN {M32_User,M32_System} then
        UnpredictableProcedure();                        // UNDEFINED or NOP
    else
        let length : integer = 4*BitCount(registers) + 4;
        var address : bits(32) = if increment then R(n) else R(n)-length;
        if wordhigher then address = address+4; end;
        var data : bits(32);

        for i = 0 to 14 do
            if registers[i] == '1' then
                if i != n then
                    R(i) = MemS{32}(address);
                else
                    data = MemS{32}(address);
                end;
                address = address + 4;
            end;
        end;
        let new_pc_value : bits(32) = MemS{32}(address);

        if wback &amp;&amp; registers[n] == '1' then
            R(n) = ARBITRARY : bits(32);
        end;
        if wback &amp;&amp; registers[n] == '0' then
            R(n) = if increment then R(n)+length else R(n)-length;
        end;
        if !wback &amp;&amp; registers[n] == '1' then
            R(n) = data;
        end;

        AArch32_ExceptionReturn(new_pc_value, SPSR_curr());
    end;
end;</pstext></ps>
  </ps_section>
  <constrained_unpredictables ps_block="Operation">
    <cu_case>
      <cu_cause>
        <pstext mayhavelinks="1">PSTATE.M IN {M32_User,M32_System}</pstext></cu_cause>
      <cu_type constraint="Constraint_UNDEF"/>
      <cu_type constraint="Constraint_NOP"/>
    </cu_case>
  </constrained_unpredictables>
  <timestamp>2026-03-12 12:23:09</timestamp>
  <commit_id>2025-09_rel_asl1</commit_id>
</instructionsection>
