<?xml version="1.0" encoding="utf-8"?>
<?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-2022 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="ASRS_MOV_r" title="ASRS (immediate) -- AArch32" type="alias">
  <docvars>
    <docvar key="alias_mnemonic" value="ASRS" />
    <docvar key="instr-class" value="general" />
  </docvars>
  <heading>ASRS (immediate)</heading>
  <desc>
    <brief>
      <para>Arithmetic Shift Right, setting flags (immediate)</para>
    </brief>
    <authored>
      <para>Arithmetic Shift Right, setting flags (immediate) shifts a register value right by an immediate number of bits, shifting in copies of its sign bit, and writes the result to the destination register.</para>
      <para>If the destination register is not the PC, this instruction updates the condition flags based on the result.</para>
      <para>The field descriptions for <syntax>&lt;Rd&gt;</syntax> identify the encodings where the PC is permitted as the destination register. Arm deprecates any use of these encodings. However, when the destination register is the PC:</para>
      <list type="unordered">
        <listitem><content>The PE branches to the address written to the PC, and restores <xref linkend="BEIDIGBH">PSTATE</xref> from SPSR_&lt;current_mode&gt;.</content></listitem>
        <listitem><content>The PE checks SPSR_&lt;current_mode&gt; for an illegal return event. See <xref linkend="CHDDDJDB">Illegal return events from AArch32 state</xref>.</content></listitem>
        <listitem><content>The instruction is <arm-defined-word>undefined</arm-defined-word> in Hyp mode.</content></listitem>
        <listitem><content>The instruction is <arm-defined-word>constrained unpredictable</arm-defined-word> in User mode and System mode.</content></listitem>
      </list>
    </authored>
  </desc>
  <aliasto refiform="mov_r.xml" iformid="MOV_r">MOV, MOVS (register)</aliasto>
  <classes>
    <classesintro count="3">
      <txt>It has encodings from the following instruction sets:</txt>
      <txt> A32 (</txt>
      <a href="#iclass_a1">A1</a>
      <txt>)</txt>
      <txt> and </txt>
      <txt> T32 (</txt>
      <a href="#iclass_t2">T2</a>
      <txt> and </txt>
      <a href="#iclass_t3">T3</a>
      <txt>)</txt>
      <txt>.</txt>
    </classesintro>
    <iclass name="A1" oneof="3" 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" />
      </docvars>
      <iclassintro count="1"></iclassintro>
      <regdiagram form="32" psname="" 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="5" settings="5">
          <c>0</c>
          <c>0</c>
          <c>0</c>
          <c>1</c>
          <c>1</c>
        </box>
        <box hibit="22" width="2" name="opc" settings="2">
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="20" name="S" usename="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="19" width="4" name="Rn" settings="4">
          <c>(0)</c>
          <c>(0)</c>
          <c>(0)</c>
          <c>(0)</c>
        </box>
        <box hibit="15" width="4" name="Rd" usename="1">
          <c colspan="4"></c>
        </box>
        <box hibit="11" width="5" name="imm5" usename="1">
          <c colspan="5"></c>
        </box>
        <box hibit="6" width="2" name="stype" usename="1" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="4" settings="1">
          <c>0</c>
        </box>
        <box hibit="3" width="4" name="Rm" usename="1">
          <c colspan="4"></c>
        </box>
      </regdiagram>
      <encoding name="ASRS_MOVS_r_A1" oneofinclass="1" oneof="3" label="MOVS, shift or rotate by value">
        <docvars>
          <docvar key="alias_mnemonic" value="ASRS" />
          <docvar key="armarmheading" value="A1" />
          <docvar key="instr-class" value="general" />
          <docvar key="isa" value="A32" />
          <docvar key="mnemonic" value="MOVS" />
          <docvar key="mnemonic-shift-type" value="MOVS-shift-no-rrx" />
          <docvar key="shift-type" value="shift-no-rrx" />
        </docvars>
        <asmtemplate><text>ASRS</text><text>{</text><a link="sa_c" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a><text>}</text><text>{</text><a link="sa_q" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a><text>}</text><text> </text><text>{</text><a link="sa_rd_4" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>,</text><text>}</text><text> </text><a link="sa_rm_2" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, #</text><a link="sa_imm_1" hover="Shift amount [1-32] (field &quot;imm5&quot;)">&lt;imm&gt;</a></asmtemplate>
        <equivalent_to>
          <asmtemplate><a href="mov_r.xml#MOVS_r_A1">MOVS</a><text>{</text><a link="sa_c" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a><text>}</text><text>{</text><a link="sa_q" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a><text>}</text><text> </text><a link="sa_rd_4" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>, </text><a link="sa_rm_2" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, ASR #</text><a link="sa_imm_1" hover="Shift amount [1-32] (field &quot;imm5&quot;)">&lt;imm&gt;</a></asmtemplate>
          <aliascond>Unconditionally</aliascond>
        </equivalent_to>
      </encoding>
    </iclass>
    <iclass name="T2" oneof="3" id="iclass_t2" no_encodings="1" isa="T32">
      <docvars>
        <docvar key="armarmheading" value="T2" />
        <docvar key="instr-class" value="general" />
        <docvar key="isa" value="T32" />
        <docvar key="mnemonic" value="MOV" />
      </docvars>
      <iclassintro count="1"></iclassintro>
      <regdiagram form="16" psname="" tworows="1">
        <box hibit="31" width="3" settings="3">
          <c>0</c>
          <c>0</c>
          <c>0</c>
        </box>
        <box hibit="28" width="2" name="op" usename="1" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="26" width="5" name="imm5" usename="1">
          <c colspan="5"></c>
        </box>
        <box hibit="21" width="3" name="Rm" usename="1">
          <c colspan="3"></c>
        </box>
        <box hibit="18" width="3" name="Rd" usename="1">
          <c colspan="3"></c>
        </box>
      </regdiagram>
      <encoding name="ASRS_MOV_r_T2" oneofinclass="1" oneof="3" label="T2">
        <docvars>
          <docvar key="alias_mnemonic" value="ASRS" />
          <docvar key="armarmheading" value="T2" />
          <docvar key="instr-class" value="general" />
          <docvar key="isa" value="T32" />
          <docvar key="mnemonic" value="MOV" />
        </docvars>
        <asmtemplate comment="Outside IT block"><text>ASRS</text><text>{</text><a link="sa_q" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a><text>}</text><text> </text><text>{</text><a link="sa_rd_1" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>,</text><text>}</text><text> </text><a link="sa_rm_1" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, #</text><a link="sa_imm_1" hover="Shift amount [1-32] (field &quot;imm5&quot;)">&lt;imm&gt;</a></asmtemplate>
        <equivalent_to>
          <asmtemplate><a href="mov_r.xml#MOV_r_T2">MOVS</a><text>{</text><a link="sa_q" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a><text>}</text><text> </text><a link="sa_rd_1" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>, </text><a link="sa_rm_1" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, ASR #</text><a link="sa_imm_1" hover="Shift amount [1-32] (field &quot;imm5&quot;)">&lt;imm&gt;</a></asmtemplate>
          <aliascond>!<a link="impl-aarch32.InITBlock.0" file="shared_pseudocode.xml" hover="function: boolean InITBlock()">InITBlock</a>()</aliascond>
        </equivalent_to>
      </encoding>
    </iclass>
    <iclass name="T3" oneof="3" id="iclass_t3" no_encodings="1" isa="T32">
      <docvars>
        <docvar key="armarmheading" value="T3" />
        <docvar key="instr-class" value="general" />
        <docvar key="isa" value="T32" />
      </docvars>
      <iclassintro count="1"></iclassintro>
      <regdiagram form="16x2" psname="" tworows="1">
        <box hibit="31" width="7" settings="7">
          <c>1</c>
          <c>1</c>
          <c>1</c>
          <c>0</c>
          <c>1</c>
          <c>0</c>
          <c>1</c>
        </box>
        <box hibit="24" width="4" name="op1" settings="4">
          <c>0</c>
          <c>0</c>
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="20" name="S" usename="1" settings="1">
          <c>1</c>
        </box>
        <box hibit="19" width="4" name="Rn" settings="4">
          <c>1</c>
          <c>1</c>
          <c>1</c>
          <c>1</c>
        </box>
        <box hibit="15" settings="1">
          <c>(0)</c>
        </box>
        <box hibit="14" width="3" name="imm3" usename="1">
          <c colspan="3"></c>
        </box>
        <box hibit="11" width="4" name="Rd" usename="1">
          <c colspan="4"></c>
        </box>
        <box hibit="7" width="2" name="imm2" usename="1">
          <c colspan="2"></c>
        </box>
        <box hibit="5" width="2" name="stype" usename="1" settings="2">
          <c>1</c>
          <c>0</c>
        </box>
        <box hibit="3" width="4" name="Rm" usename="1">
          <c colspan="4"></c>
        </box>
      </regdiagram>
      <encoding name="ASRS_MOVS_r_T3" oneofinclass="1" oneof="3" label="MOVS, shift or rotate by value">
        <docvars>
          <docvar key="alias_mnemonic" value="ASRS" />
          <docvar key="armarmheading" value="T3" />
          <docvar key="instr-class" value="general" />
          <docvar key="isa" value="T32" />
          <docvar key="mnemonic" value="MOVS" />
          <docvar key="mnemonic-shift-type" value="MOVS-shift-no-rrx" />
          <docvar key="shift-type" value="shift-no-rrx" />
        </docvars>
        <asmtemplate comment="Outside IT block, and &lt;Rd&gt;, &lt;Rm&gt;, &lt;imm&gt; can be represented in T2"><text>ASRS.W </text><text>{</text><a link="sa_rd_1" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>,</text><text>}</text><text> </text><a link="sa_rm_1" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, #</text><a link="sa_imm_2" hover="Shift amount [1-32] (field &quot;imm3:imm2&quot;)">&lt;imm&gt;</a></asmtemplate>
        <asmtemplate><text>ASRS</text><text>{</text><a link="sa_c" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a><text>}</text><text>{</text><a link="sa_q" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a><text>}</text><text> </text><text>{</text><a link="sa_rd_1" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>,</text><text>}</text><text> </text><a link="sa_rm_1" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, #</text><a link="sa_imm_2" hover="Shift amount [1-32] (field &quot;imm3:imm2&quot;)">&lt;imm&gt;</a></asmtemplate>
        <equivalent_to>
          <asmtemplate><a href="mov_r.xml#MOVS_r_T3">MOVS</a><text>{</text><a link="sa_c" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a><text>}</text><text>{</text><a link="sa_q" hover="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a><text>}</text><text> </text><a link="sa_rd_1" hover="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a><text>, </text><a link="sa_rm_1" hover="General-purpose source register (field &quot;Rm&quot;)">&lt;Rm&gt;</a><text>, ASR #</text><a link="sa_imm_2" hover="Shift amount [1-32] (field &quot;imm3:imm2&quot;)">&lt;imm&gt;</a></asmtemplate>
          <aliascond>Unconditionally</aliascond>
        </equivalent_to>
      </encoding>
    </iclass>
  </classes>
  <explanations scope="all">
    <explanation enclist="ASRS_MOVS_r_A1, ASRS_MOVS_r_T3" symboldefcount="1">
      <symbol link="sa_c">&lt;c&gt;</symbol>
      <account encodedin="">
        <intro>
          <para>See <xref linkend="Babbefhf">Standard assembler syntax fields</xref>.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOVS_r_A1, ASRS_MOV_r_T2, ASRS_MOVS_r_T3" symboldefcount="1">
      <symbol link="sa_q">&lt;q&gt;</symbol>
      <account encodedin="">
        <intro>
          <para>See <xref linkend="Babbefhf">Standard assembler syntax fields</xref>.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOVS_r_A1" symboldefcount="1">
      <symbol link="sa_rd_4">&lt;Rd&gt;</symbol>
      <account encodedin="Rd">
        <docvars>
          <docvar key="armarmheading" value="A1" />
          <docvar key="shift-type" value="shift-no-rrx" />
        </docvars>
        <intro>
          <para>For encoding A1: is the general-purpose destination register, encoded in the "Rd" field. Arm deprecates using the PC as the destination register, but if the PC is used, the instruction performs an exception return, that restores <xref linkend="BEIDIGBH">PSTATE</xref> from SPSR_&lt;current_mode&gt;.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOV_r_T2, ASRS_MOVS_r_T3" symboldefcount="2">
      <symbol link="sa_rd_1">&lt;Rd&gt;</symbol>
      <account encodedin="Rd">
        <intro>
          <para>For encoding T2 and T3: is the general-purpose destination register, encoded in the "Rd" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOVS_r_A1" symboldefcount="1">
      <symbol link="sa_rm_2">&lt;Rm&gt;</symbol>
      <account encodedin="Rm">
        <docvars>
          <docvar key="armarmheading" value="A1" />
          <docvar key="shift-type" value="shift-no-rrx" />
        </docvars>
        <intro>
          <para>For encoding A1: is the general-purpose source register, encoded in the "Rm" field. The PC can be used, but this is deprecated.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOV_r_T2, ASRS_MOVS_r_T3" symboldefcount="2">
      <symbol link="sa_rm_1">&lt;Rm&gt;</symbol>
      <account encodedin="Rm">
        <intro>
          <para>For encoding T2 and T3: is the general-purpose source register, encoded in the "Rm" field.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOVS_r_A1, ASRS_MOV_r_T2" symboldefcount="1">
      <symbol link="sa_imm_1">&lt;imm&gt;</symbol>
      <account encodedin="imm5">
        <intro>
          <para>For encoding A1 and T2: is the shift amount, in the range 1 to 32, encoded in the "imm5" field as &lt;imm&gt; modulo 32.</para>
        </intro>
      </account>
    </explanation>
    <explanation enclist="ASRS_MOVS_r_T3" symboldefcount="2">
      <symbol link="sa_imm_2">&lt;imm&gt;</symbol>
      <account encodedin="imm3:imm2">
        <docvars>
          <docvar key="armarmheading" value="T3" />
          <docvar key="shift-type" value="shift-no-rrx" />
        </docvars>
        <intro>
          <para>For encoding T3: is the shift amount, in the range 1 to 32, encoded in the "imm3:imm2" field as &lt;imm&gt; modulo 32.</para>
        </intro>
      </account>
    </explanation>
  </explanations>
</instructionsection>
