#set TITLE Minimize Usage of Pseudo-instructions - Journal
#set DIRECTORY journal
#set FILE minimize-usage-of-pseudo-instructions.ps
#set PRINT 1
#include "header.xhtml"
  <h1>Minimize Usage of Pseudo-instructions</h1>
  <ul>
    <li>First written on Tertle 17th, 10026</li>
  </ul>
  <p>The GNU Assembler, and probably many other assemblers, implements pseudo-instructions for
    convenience. In some instances it would require manual calculation of address to use
    instruction directly. This is justified, for your well on your way to writing human-readable
    machine code if you do that. But many pseudo-instructions save no more than a couple lines
    that are easy to write. These are not good, because they create an unnecessary abstraction.
    It cannot be stressed enough that convenience is good only in moderation.</p>
  <p>In X86 Assembly, the <code>LEAVE</code> pseudo-instruction expands to just two instructions,
    which never vary.</p>
  <pre><code>
leave
  </code></pre>
  <p>is the same as:</p>
  <pre><code>
mov %esp, %ebp
pop %ebp
  </code></pre>
  <p>This could easily be implemented with a macro. The <code>ENTER</code> pseudo-instruction
    does the reverse operation. Use macros or type the intructions yourself so you depend less
    on Intel micro code and actually understand what is happending.</p>
  <p>In ARM Assembly, the <code>LDR</code> pseudo-instruction calculates the PC offset for you;
    this is good. But you can add another abtraction on top of this by using the equal sign.</p>
  <pre><code>
label:
  .long 0
  ldr r0, =label
  </code></pre>
  <p>is the same as:</p>
  <pre><code>
label:
  .long 0
  ldr r0, label_adr
label_adr:
  .long label
  </code></pre>
  <p>This is stupid. Write all the labels yourself; it isn't hard and it hides less.</p>
  <p>By using only the pseudo-instructions that save significant time you can understand the
    Assembly language better and your code will be slightly less bloated. All with little
    effort.</p>
  <a class="button" type="application/postscript" rel="alternate" href="/DIRECTORY/FILE">Print this entry</a>
#include "footer.xhtml"
