# Minimize Usage of Pseudo-instructions - Journal

Home | Journal | Software | Bookmarks
# Minimize Usage of Pseudo-instructions First written on Tertle 17th, 10026 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. In X86 Assembly, the `LEAVE` pseudo-instruction expands to just two instructions, which never vary.
    leave
is the same as:
    mov %esp, %ebp
    pop %ebp
This could easily be implemented with a macro. The `ENTER` 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. In ARM Assembly, the `LDR` 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.
    label:
      .long 0
      ldr r0, =label
is the same as:
    label:
      .long 0
      ldr r0, label_adr
    label_adr:
      .long label
This is stupid. Write all the labels yourself; it isn't hard and it hides less. 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. Print this entry