<?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="LDRSH_imm" title="LDRSH (immediate) -- A64" type="instruction">
  <docvars>
    <docvar key="instr-class" value="general"/>
    <docvar key="isa" value="A64"/>
    <docvar key="mnemonic" value="LDRSH"/>
  </docvars>
  <heading>LDRSH (immediate)</heading>
  <desc>
    <brief>
      <para>Load register signed halfword (immediate)</para>
    </brief>
    <authored>
      <para>This instruction loads a halfword from
memory, sign-extends it to 32 bits or 64 bits, and writes the result
to a register.
The address that is used for the load is calculated from a
base register and an immediate offset.
For information about addressing modes, see
<xref linkend="ARMARM_CHDIIIBB">Load/Store addressing modes</xref>.</para>
    </authored>
    <encodingnotes>
      <para>For information about the <arm-defined-word>CONSTRAINED UNPREDICTABLE</arm-defined-word> behavior of this instruction, see <xref linkend="CJAEGDJC">Architectural Constraints on UNPREDICTABLE behaviors</xref>, and particularly <xref linkend="CHDBIBAE">LDRSH (immediate)</xref>.</para>
    </encodingnotes>
  </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="0"/>
  <classes>
    <classesintro count="3">
      <txt>It has encodings from 3 classes:</txt>
      <a href="#iclass_post_index">Post-index</a>
      <txt>, </txt>
      <a href="#iclass_pre_index">Pre-index</a>
      <txt> and </txt>
      <a href="#iclass_unsigned_offset">Unsigned offset</a>
    </classesintro>
    <iclass name="Post-index" oneof="3" id="iclass_post_index" no_encodings="2" isa="A64">
      <docvars>
        <docvar key="address-form" value="post-indexed"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="LDRSH"/>
        <docvar key="offset-type" value="off9s_u"/>
      </docvars>
      <iclassintro count="2"/>
      <regdiagram form="32" psname="A64.ldst.ldst_immpost.LDRSH_32_ldst_immpost" tworows="1">
        <box hibit="31" width="2" name="size" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>1</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="2" name="opc" usename="1" settings="1" psbits="xx">
          <c>1</c>
          <c>x</c>
        </box>
        <box hibit="21" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="20" width="9" name="imm9" usename="1">
          <c colspan="9"/>
        </box>
        <box hibit="11" width="2" settings="2">
          <c>0</c>
          <c>1</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="LDRSH_32_ldst_immpost" oneofinclass="2" oneof="6" label="32-bit" bitdiffs="opc == 11">
        <docvars>
          <docvar key="address-form" value="post-indexed"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off9s_u"/>
          <docvar key="datatype" value="32"/>
          <docvar key="mnemonic" value="LDRSH"/>
        </docvars>
        <box hibit="23" width="2" name="opc">
          <c/>
          <c>1</c>
        </box>
        <asmtemplate><text>LDRSH  </text><a hover="Is the 32-bit name of the general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="WtOrWZR__4">&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><a hover="Is the signed immediate byte offset, in the range -256 to 255, encoded in the &quot;imm9&quot; field." link="simm__3">&lt;simm&gt;</a></asmtemplate>
      </encoding>
      <encoding name="LDRSH_64_ldst_immpost" oneofinclass="2" oneof="6" label="64-bit" bitdiffs="opc == 10">
        <docvars>
          <docvar key="isa" value="A64"/>
          <docvar key="address-form" value="post-indexed"/>
          <docvar key="datatype" value="64"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="offset-type" value="off9s_u"/>
          <docvar key="mnemonic" value="LDRSH"/>
        </docvars>
        <box hibit="23" width="2" name="opc">
          <c/>
          <c>0</c>
        </box>
        <asmtemplate><text>LDRSH  </text><a hover="Is the 64-bit name of the general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="XtOrXZR__11">&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><a hover="Is the signed immediate byte offset, in the range -256 to 255, encoded in the &quot;imm9&quot; field." link="simm__3">&lt;simm&gt;</a></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.ldst_immpost.LDRSH_32_ldst_immpost" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">var wback : boolean = TRUE;
let postindex : boolean = TRUE;
let offset : bits(64) = SignExtend{}(imm9);</pstext></ps>
      </ps_section>
    </iclass>
    <iclass name="Pre-index" oneof="3" id="iclass_pre_index" no_encodings="2" isa="A64">
      <docvars>
        <docvar key="address-form" value="pre-indexed"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="LDRSH"/>
        <docvar key="offset-type" value="off9s_u"/>
      </docvars>
      <iclassintro count="2"/>
      <regdiagram form="32" psname="A64.ldst.ldst_immpre.LDRSH_32_ldst_immpre" tworows="1">
        <box hibit="31" width="2" name="size" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>1</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="2" name="opc" usename="1" settings="1" psbits="xx">
          <c>1</c>
          <c>x</c>
        </box>
        <box hibit="21" width="1" settings="1">
          <c>0</c>
        </box>
        <box hibit="20" width="9" name="imm9" usename="1">
          <c colspan="9"/>
        </box>
        <box hibit="11" width="2" settings="2">
          <c>1</c>
          <c>1</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="LDRSH_32_ldst_immpre" oneofinclass="2" oneof="6" label="32-bit" bitdiffs="opc == 11">
        <docvars>
          <docvar key="address-form" value="pre-indexed"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off9s_u"/>
          <docvar key="datatype" value="32"/>
          <docvar key="mnemonic" value="LDRSH"/>
        </docvars>
        <box hibit="23" width="2" name="opc">
          <c/>
          <c>1</c>
        </box>
        <asmtemplate><text>LDRSH  </text><a hover="Is the 32-bit name of the general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="WtOrWZR__4">&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><a hover="Is the signed immediate byte offset, in the range -256 to 255, encoded in the &quot;imm9&quot; field." link="simm__3">&lt;simm&gt;</a><text>]!</text></asmtemplate>
      </encoding>
      <encoding name="LDRSH_64_ldst_immpre" oneofinclass="2" oneof="6" label="64-bit" bitdiffs="opc == 10">
        <docvars>
          <docvar key="isa" value="A64"/>
          <docvar key="address-form" value="pre-indexed"/>
          <docvar key="datatype" value="64"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="offset-type" value="off9s_u"/>
          <docvar key="mnemonic" value="LDRSH"/>
        </docvars>
        <box hibit="23" width="2" name="opc">
          <c/>
          <c>0</c>
        </box>
        <asmtemplate><text>LDRSH  </text><a hover="Is the 64-bit name of the general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="XtOrXZR__11">&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><a hover="Is the signed immediate byte offset, in the range -256 to 255, encoded in the &quot;imm9&quot; field." link="simm__3">&lt;simm&gt;</a><text>]!</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.ldst_immpre.LDRSH_32_ldst_immpre" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">var wback : boolean = TRUE;
let postindex : boolean = FALSE;
let offset : bits(64) = SignExtend{}(imm9);</pstext></ps>
      </ps_section>
    </iclass>
    <iclass name="Unsigned offset" oneof="3" id="iclass_unsigned_offset" no_encodings="2" isa="A64">
      <docvars>
        <docvar key="address-form" value="unsigned-scaled-offset"/>
        <docvar key="instr-class" value="general"/>
        <docvar key="isa" value="A64"/>
        <docvar key="mnemonic" value="LDRSH"/>
        <docvar key="offset-type" value="off12u_s"/>
      </docvars>
      <iclassintro count="2"/>
      <regdiagram form="32" psname="A64.ldst.ldst_pos.LDRSH_32_ldst_pos" tworows="1">
        <box hibit="31" width="2" name="size" usename="1" settings="2" psbits="xx">
          <c>0</c>
          <c>1</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>1</c>
        </box>
        <box hibit="23" width="2" name="opc" usename="1" settings="1" psbits="xx">
          <c>1</c>
          <c>x</c>
        </box>
        <box hibit="21" width="12" name="imm12" usename="1">
          <c colspan="12"/>
        </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="LDRSH_32_ldst_pos" oneofinclass="2" oneof="6" label="32-bit" bitdiffs="opc == 11">
        <docvars>
          <docvar key="address-form" value="unsigned-scaled-offset"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off12u_s"/>
          <docvar key="datatype" value="32"/>
          <docvar key="mnemonic" value="LDRSH"/>
        </docvars>
        <box hibit="23" width="2" name="opc">
          <c/>
          <c>1</c>
        </box>
        <asmtemplate><text>LDRSH  </text><a hover="Is the 32-bit name of the general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="WtOrWZR__4">&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><a hover="For the &quot;16-bit&quot; variant: is the optional positive immediate byte offset, a multiple of 2 in the range 0 to 8190, defaulting to 0 and encoded in the &quot;imm12&quot; field as &lt;pimm&gt;/2." link="pimm__4">&lt;pimm&gt;</a><text>}]</text></asmtemplate>
      </encoding>
      <encoding name="LDRSH_64_ldst_pos" oneofinclass="2" oneof="6" label="64-bit" bitdiffs="opc == 10">
        <docvars>
          <docvar key="address-form" value="unsigned-scaled-offset"/>
          <docvar key="instr-class" value="general"/>
          <docvar key="isa" value="A64"/>
          <docvar key="offset-type" value="off12u_s"/>
          <docvar key="datatype" value="64"/>
          <docvar key="mnemonic" value="LDRSH"/>
        </docvars>
        <box hibit="23" width="2" name="opc">
          <c/>
          <c>0</c>
        </box>
        <asmtemplate><text>LDRSH  </text><a hover="Is the 64-bit name of the general-purpose register to be transferred, encoded in the &quot;Rt&quot; field." link="XtOrXZR__11">&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><a hover="For the &quot;16-bit&quot; variant: is the optional positive immediate byte offset, a multiple of 2 in the range 0 to 8190, defaulting to 0 and encoded in the &quot;imm12&quot; field as &lt;pimm&gt;/2." link="pimm__4">&lt;pimm&gt;</a><text>}]</text></asmtemplate>
      </encoding>
      <ps_section howmany="1">
        <ps name="A64.ldst.ldst_pos.LDRSH_32_ldst_pos" sections="1" secttype="noheading">
          <pstext mayhavelinks="1" section="Decode" rep_section="decode">var wback : boolean = FALSE;
let postindex : boolean = FALSE;
let offset : bits(64) = LSL(ZeroExtend{64}(imm12), 1);</pstext></ps>
      </ps_section>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="LDRSH_32_ldst_immpost, LDRSH_32_ldst_immpre, LDRSH_32_ldst_pos" symboldefcount="1">
      <symbol link="WtOrWZR__4">&lt;Wt&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 32-bit name of the general-purpose register to be transferred, encoded in the "Rt" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDRSH_32_ldst_immpost, LDRSH_64_ldst_immpost, LDRSH_32_ldst_immpre, LDRSH_64_ldst_immpre, LDRSH_32_ldst_pos, LDRSH_64_ldst_pos" 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 "Rn" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDRSH_32_ldst_immpost, LDRSH_64_ldst_immpost, LDRSH_32_ldst_immpre, LDRSH_64_ldst_immpre" symboldefcount="1">
      <symbol link="simm__3">&lt;simm&gt;</symbol>
      <account encodedin="imm9">
        <intro>
          <para>Is the signed immediate byte offset, in the range -256 to 255, encoded in the "imm9" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDRSH_64_ldst_immpost, LDRSH_64_ldst_immpre, LDRSH_64_ldst_pos" symboldefcount="1">
      <symbol link="XtOrXZR__11">&lt;Xt&gt;</symbol>
      <account encodedin="Rt">
        <intro>
          <para>Is the 64-bit name of the general-purpose register to be transferred, encoded in the "Rt" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="LDRSH_32_ldst_pos, LDRSH_64_ldst_pos" symboldefcount="1">
      <symbol link="pimm__4">&lt;pimm&gt;</symbol>
      <account encodedin="imm12">
        <intro>
          <para>Is the optional positive immediate byte offset, a multiple of 2 in the range 0 to 8190, defaulting to 0 and encoded in the "imm12" field as &lt;pimm&gt;/2.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
  <ps_section howmany="1">
    <ps name="A64.ldst.ldst_immpost.LDRSH_32_ldst_immpost" sections="1" secttype="Shared Decode">
      <pstext mayhavelinks="1" section="Postdecode" rep_section="postdecode">let t : integer{} = UInt(Rt);
let n : integer{} = UInt(Rn);
let regsize : integer{} = 64 &gt;&gt; UInt(opc[0]);
let nontemporal : boolean = FALSE;
let tagchecked : boolean = wback || n != 31;

var c : Constraint;
var wb_unknown : boolean = FALSE;
if wback &amp;&amp; n == t &amp;&amp; n != 31 then
    c = ConstrainUnpredictable(Unpredictable_WBOVERLAPLD);
    assert c IN {Constraint_WBSUPPRESS, Constraint_UNKNOWN, Constraint_UNDEF, Constraint_NOP};
    case c of
        when Constraint_WBSUPPRESS =&gt; wback = FALSE;       // Writeback is suppressed
        when Constraint_UNKNOWN =&gt;    wb_unknown = TRUE;   // Writeback is UNKNOWN
        when Constraint_UNDEF =&gt;      EndOfDecode(Decode_UNDEF);
        when Constraint_NOP =&gt;        EndOfDecode(Decode_NOP);
    end;
end;</pstext></ps>
  </ps_section>
  <ps_section howmany="1">
    <ps name="A64.ldst.ldst_immpost.LDRSH_32_ldst_immpost" sections="1" secttype="Operation">
      <pstext mayhavelinks="1" section="Execute" rep_section="execute">var address : bits(64);

let privileged : boolean = PSTATE.EL != EL0;
let accdesc : AccessDescriptor = CreateAccDescGPR(MemOp_LOAD, nontemporal, privileged,
                                                  tagchecked, t);

if n == 31 then
    CheckSPAlignment();
    address = SP{64}();
else
    address = X{64}(n);
end;

if !postindex then
    address = AddressAdd(address, offset, accdesc);
end;

let data : bits(16) = Mem{16}(address, accdesc);
X{regsize}(t) = SignExtend{regsize}(data);

if wback then
    if wb_unknown then
        address = ARBITRARY : bits(64);
    elsif postindex then
        address = AddressAdd(address, offset, accdesc);
    end;
    if n == 31 then
        SP{64}() = address;
    else
        X{64}(n) = address;
    end;
end;</pstext></ps>
  </ps_section>
  <timestamp>2026-03-12 12:23:09</timestamp>
  <commit_id>2025-09_rel_asl1</commit_id>
</instructionsection>
