collab/polyglot-riscv-arm

what if the same machine code was valid riscv and arm asm

git clone https://git.julia.blue/collab/polyglot-riscv-arm

Jonathan Dönszelmannwebsite start885cc4e

main
13.8 KiB115 linesraw
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
3<html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="insn.css"/><meta name="generator" content="iform.xsl"/><title>ADD (immediate, to PC) -- AArch32</title></head><body><table style="margin: 0 auto;"><tr><td><div class="topbar"><a href="index.html">Base Instructions</a></div></td><td><div class="topbar"><a href="fpsimdindex.html">SIMD&amp;FP Instructions</a></div></td><td><div class="topbar"><a href="a32_encindex.html">A32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="t32_encindex.html">T32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="shared_pseudocode.html">Shared Pseudocode</a></div></td><td><div class="topbar"><a href="notice.html">Proprietary Notice</a></div></td></tr></table><hr/><h2 class="instruction-section">ADD (immediate, to PC)</h2><p>Add to PC adds an immediate value to the Align(PC, 4) value to form a PC-relative address, and writes the result to the destination register.  Arm recommends that, where possible, software avoids using this alias.</p><p>
4        This is a pseudo-instruction of
5        <a href="adr.html">ADR</a>.
6        This means:
7      </p><ul><li>
8          The encodings in this description are named to match the encodings of
9          <a href="adr.html">ADR</a>.
10        </li><li>
11            The assembler syntax is used only for assembly, and is not used on disassembly.
12          </li><li>The description of <a href="adr.html">ADR</a> gives the operational pseudocode, any <span class="arm-defined-word">constrained unpredictable</span> behavior, and any operational information for this instruction.</li></ul>
13    <p class="desc">
14      It has encodings from the following instruction sets:
15       A32 (
16      <a href="#iclass_a1">A1</a>
17      )
18       and 
19       T32 (
20      <a href="#iclass_t1">T1</a>
21       and 
22      <a href="#iclass_t3">T3</a>
23      )
24      .
25    </p>
26    <h3 class="classheading"><a id="iclass_a1"/>A1</h3><div class="regdiagram-32"><table class="regdiagram"><thead><tr><td>31</td><td>30</td><td>29</td><td>28</td><td>27</td><td>26</td><td>25</td><td>24</td><td>23</td><td>22</td><td>21</td><td>20</td><td>19</td><td>18</td><td>17</td><td>16</td><td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>9</td><td>8</td><td>7</td><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td><td>0</td></tr></thead><tbody><tr class="firstrow"><td colspan="4" class="lr">!= 1111</td><td class="l">0</td><td>0</td><td>1</td><td class="r">0</td><td class="l">1</td><td>0</td><td class="r">0</td><td class="lr">0</td><td class="l">1</td><td>1</td><td>1</td><td class="r">1</td><td colspan="4" class="lr">Rd</td><td colspan="12" class="lr">imm12</td></tr><tr class="secondrow"><td colspan="4" class="droppedname">cond</td><td colspan="4"/><td colspan="3"/><td/><td colspan="4"/><td colspan="4"/><td colspan="12"/></tr></tbody></table></div><div class="encoding"><h4 class="encoding">A1</h4><a id="ADD_ADR_A1"/><p class="asm-code">ADD{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd_1" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, PC, #<a href="#sa_const" title="An immediate value">&lt;const&gt;</a></p><p class="equivto">
27      is equivalent to
28    </p>
29          <p class="asm-code"><a href="adr.html#ADR_A1">ADR</a>{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd_1" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, <a href="#sa_label_2" title="The label of an instruction or literal data item whose address is to be loaded into {syntax{&lt;Rd&gt;}}">&lt;label&gt;</a></p>
30          
31        </div>
32    <h3 class="classheading"><a id="iclass_t1"/>T1</h3><div class="regdiagram-16"><table class="regdiagram"><thead><tr><td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>9</td><td>8</td><td>7</td><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td><td>0</td></tr></thead><tbody><tr class="firstrow"><td class="l">1</td><td>0</td><td>1</td><td class="r">0</td><td class="lr">0</td><td colspan="3" class="lr">Rd</td><td colspan="8" class="lr">imm8</td></tr></tbody></table></div><div class="encoding"><h4 class="encoding">T1</h4><a id="ADD_ADR_T1"/><p class="asm-code">ADD{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, PC, #<a href="#sa_imm8" title="Unsigned immediate, multiple of 4 [0-1020] (field &quot;imm8&quot;)">&lt;imm8&gt;</a></p><p class="equivto">
33      is equivalent to
34    </p>
35          <p class="asm-code"><a href="adr.html#ADR_T1">ADR</a>{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, <a href="#sa_label" title="The label of an instruction or literal data item whose address is to be loaded into {syntax{&lt;Rd&gt;}}">&lt;label&gt;</a></p>
36          
37        </div>
38    <h3 class="classheading"><a id="iclass_t3"/>T3</h3><div class="regdiagram-16x2"><table class="regdiagram"><thead><tr><td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>9</td><td>8</td><td>7</td><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td><td>0</td><td>15</td><td>14</td><td>13</td><td>12</td><td>11</td><td>10</td><td>9</td><td>8</td><td>7</td><td>6</td><td>5</td><td>4</td><td>3</td><td>2</td><td>1</td><td>0</td></tr></thead><tbody><tr class="firstrow"><td class="l">1</td><td>1</td><td>1</td><td>1</td><td class="r">0</td><td class="lr">i</td><td class="l">1</td><td class="r">0</td><td class="lr">0</td><td class="lr">0</td><td class="lr">0</td><td class="lr">0</td><td class="l">1</td><td>1</td><td>1</td><td class="r">1</td><td class="lr">0</td><td colspan="3" class="lr">imm3</td><td colspan="4" class="lr">Rd</td><td colspan="8" class="lr">imm8</td></tr></tbody></table></div><div class="encoding"><h4 class="encoding">T3</h4><a id="ADD_ADR_T3"/><p class="asm-code">ADDW{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, PC, #<a href="#sa_imm12" title="12-bit unsigned immediate [0-4095] (field &quot;i:imm3:imm8&quot;)">&lt;imm12&gt;</a>
39        //
40      
41        (&lt;Rd&gt;, &lt;imm12&gt; can be represented in T1)
42      </p><p class="asm-code">ADD{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, PC, #<a href="#sa_imm12" title="12-bit unsigned immediate [0-4095] (field &quot;i:imm3:imm8&quot;)">&lt;imm12&gt;</a></p><p class="equivto">
43      is equivalent to
44    </p>
45          <p class="asm-code"><a href="adr.html#ADR_T3">ADR</a>{<a href="#sa_c" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;c&gt;</a>}{<a href="#sa_q" title="See {xref{ARMARM_Babbefhf}{Standard assembler syntax fields}}">&lt;q&gt;</a>} <a href="#sa_rd" title="General-purpose destination register (field &quot;Rd&quot;)">&lt;Rd&gt;</a>, <a href="#sa_label_1" title="The label of an instruction or literal data item whose address is to be loaded into {syntax{&lt;Rd&gt;}}">&lt;label&gt;</a></p>
46          
47        </div>
48  <div class="encoding-notes"/><h3 class="explanations">Assembler Symbols</h3><div class="explanations"><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;c&gt;</td><td><a id="sa_c"/>
49        
50          <p class="aml">See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="Babbefhf">Standard assembler syntax fields</a>.</p>
51        
52      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;q&gt;</td><td><a id="sa_q"/>
53        
54          <p class="aml">See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="Babbefhf">Standard assembler syntax fields</a>.</p>
55        
56      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;Rd&gt;</td><td><a id="sa_rd_1"/>
57        
58          
59        
60        
61          <p class="aml">For encoding A1: is the general-purpose destination register, encoded in the "Rd" field. If the PC is used, the instruction is a branch to the address calculated by the operation. This is an interworking branch, see <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BEICJFEH">Pseudocode description of operations on the AArch32 general-purpose registers and the PC</a>.</p>
62        
63      </td></tr><tr><td/><td><a id="sa_rd"/>
64        
65          <p class="aml">For encoding T1 and T3: is the general-purpose destination register, encoded in the "Rd" field.</p>
66        
67      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;label&gt;</td><td><a id="sa_label_2"/>
68        
69          
70          
71        
72        
73          <p class="aml">For encoding A1: the label of an instruction or literal data item whose address is to be loaded into &lt;Rd&gt;. The assembler calculates the required value of the offset from the Align(PC, 4) value of the <span class="asm-code">ADR</span> instruction to this label.</p>
74          <p class="aml">If the offset is zero or positive, encoding A1 is used, with imm32 equal to the offset.</p>
75          <p class="aml">If the offset is negative, encoding A2 is used, with imm32 equal to the size of the offset. That is, the use of encoding A2 indicates that the required offset is minus the value of imm32.</p>
76          <p class="aml">Permitted values of the size of the offset are any of the constants described in <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BABHDAJF">Modified immediate constants in A32 instructions</a>.</p>
77        
78      </td></tr><tr><td/><td><a id="sa_label"/>
79        
80          
81          
82        
83        
84          <p class="aml">For encoding T1: the label of an instruction or literal data item whose address is to be loaded into &lt;Rd&gt;. The assembler calculates the required value of the offset from the Align(PC, 4) value of the <span class="asm-code">ADR</span> instruction to this label. Permitted values of the size of the offset are multiples of 4 in the range 0 to 1020.</p>
85        
86      </td></tr><tr><td/><td><a id="sa_label_1"/>
87        
88          
89          
90        
91        
92          <p class="aml">For encoding T3: the label of an instruction or literal data item whose address is to be loaded into &lt;Rd&gt;. The assembler calculates the required value of the offset from the Align(PC, 4) value of the <span class="asm-code">ADR</span> instruction to this label.</p>
93          <p class="aml">If the offset is zero or positive, encoding T3 is used, with imm32 equal to the offset.</p>
94          <p class="aml">If the offset is negative, encoding T2 is used, with imm32 equal to the size of the offset. That is, the use of encoding T2 indicates that the required offset is minus the value of imm32.</p>
95          <p class="aml">Permitted values of the size of the offset are 0-4095.</p>
96        
97      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;imm8&gt;</td><td><a id="sa_imm8"/>
98        
99          <p class="aml">Is an unsigned immediate, a multiple of 4, in the range 0 to 1020, encoded in the "imm8" field as &lt;imm8&gt;/4.</p>
100        
101      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;imm12&gt;</td><td><a id="sa_imm12"/>
102        
103          <p class="aml">Is a 12-bit unsigned immediate, in the range 0 to 4095, encoded in the "i:imm3:imm8" field.</p>
104        
105      </td></tr></table><table><col class="asyn-l"/><col class="asyn-r"/><tr><td>&lt;const&gt;</td><td><a id="sa_const"/>
106        
107          <p class="aml">An immediate value. See <a class="armarm-xref" title="Reference to Armv8 ARM section" data-linkend="BABHDAJF">Modified immediate constants in A32 instructions</a> for the range of values.</p>
108        
109      </td></tr></table></div><div class="syntax-notes"/><div class="alias_ps_section"><h3 class="pseudocode">Operation</h3><p>The description of <a href="adr.html">ADR</a> gives the operational pseudocode for this instruction.</p></div><hr/><table style="margin: 0 auto;"><tr><td><div class="topbar"><a href="index.html">Base Instructions</a></div></td><td><div class="topbar"><a href="fpsimdindex.html">SIMD&amp;FP Instructions</a></div></td><td><div class="topbar"><a href="a32_encindex.html">A32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="t32_encindex.html">T32 Instructions by Encoding</a></div></td><td><div class="topbar"><a href="shared_pseudocode.html">Shared Pseudocode</a></div></td><td><div class="topbar"><a href="notice.html">Proprietary Notice</a></div></td></tr></table><p class="versions">
110      Internal version only: isa v01_31, pseudocode v2024-09_rel
111      ; Build timestamp: 2024-09-26T13:26
112    </p><p class="copyconf">
113      Copyright © 2010-2024 Arm Limited or its affiliates. All rights reserved.
114      This document is Non-Confidential.
115    </p></body></html>