title: ARM assembler instruction "ADDS Rn, #1" versus "ADDS Rd, Rn, #1"
body: <ol>
  <li><code>ADDS Rn, #1</code></li>
  <li><code>ADDS Rd, Rn, #1</code></li>
  </ol>
  <p>The ARM documentation specifies that in the first instruction if the Rd is optional and if ommitted Rd equals Rn. So both instructions should be the same when compiled.
  But our compiler is generating:</p>
  <p>binary <strong>0x3F01</strong> for <code>SUBS R7,#1</code>
  and
  binary <strong>0x1E7F</strong> for <code>SUBS R7,R7,#1</code></p>
  <p>using the instruction decoding
  0x3F01 equals to 001 11 111 00000001 001</p>
  <blockquote>
  <p>001 -&gt; add/substract/compare/move immediate</p>
  <p>11 -&gt; opcode is substract imm</p>
  <p>111 -&gt; R7</p>
  <p>00000001 -&gt; value 1</p>
  </blockquote>
  <p>using the instruction decoding</p>
  <p>0x1E7F equals 000111 1 001 111 111</p>
  <blockquote>
  <p>000111 -&gt; add/substract register</p>
  <p>1 -&gt; substract immediate</p>
  <p>001 -&gt; value 1</p>
  <p>111 -&gt; R7</p>
  <p>111 -&gt; R7</p>
  </blockquote>
  <p>So both instructions are performing the same action. Any idea why the the compiler might generate different binary?</p>